Skip to content

Bug: duplicate key value violates unique constraint "PK_SMStreams" #12

Open
@Aandree5

Description

@Aandree5

Describe the Bug

I've noticed this a few times, I just updated the container to use the 0.7.3 version, and got this error and cannot start up. I has happened in the past, not necessarely when updating but when restarting it.

Could this be because a migration is not compatible with 0.3.1 (the one I was on), or was there duplicate data, and if so, how was it allowed?

Stream Master Version

0.7.3

Relevant Logs

2025-02-20 09:13:02.766 UTC [83] ERROR:  duplicate key value violates unique constraint "PK_SMStreams"
2025-02-20 09:13:02.766 UTC [83] DETAIL:  Key ("Id")=(dfbfc4a9ddfbf50d6b3349e7a97f0101) already exists.
2025-02-20 09:13:02.766 UTC [83] CONTEXT:  SQL statement "INSERT INTO "SMStreams" ("Id", "ClientUserAgent", "FilePosition", "IsHidden", 
                                         "IsUserCreated", "M3UFileId", "ChannelNumber", 
                                         "M3UFileName", "Group", "EPGID", "Logo", "Name", 
                                         "Url", "StationId", "IsSystem", "CUID", "SMStreamType", 
                                         "NeedsDelete", "ChannelName", "ChannelId", 
                                         "CommandProfileName", "TVGName", "ExtInf")
                SELECT t.new_id, s."ClientUserAgent", s."FilePosition", s."IsHidden", 
                       s."IsUserCreated", t.m3ufileid, s."ChannelNumber", s."M3UFileName", 
                       s."Group", s."EPGID", s."Logo", s."Name", s."Url", s."StationId", 
                       s."IsSystem", s."CUID", s."SMStreamType", s."NeedsDelete", s."ChannelName", 
                       s."ChannelId", s."CommandProfileName", s."TVGName", s."ExtInf"
                FROM temp_batch_update t
                INNER JOIN "SMStreams" s ON t.old_id = s."Id""
        PL/pgSQL function inline_code_block line 28 at SQL statement
2025-02-20 09:13:02.766 UTC [83] STATEMENT:  DO $$
        DECLARE
            duplicate_count INTEGER;
        BEGIN
            -- Only proceed if migration hasn't been done
            IF NOT EXISTS (SELECT 1 FROM "SystemKeyValues" WHERE "Key" = 'didIDMigration') THEN
                -- Create temporary tables for streams and m3ufiles data
                CREATE TEMP TABLE temp_SMStreams AS
                SELECT "Id", "Url", "CUID", "ChannelId", "EPGID", "TVGName", "Name", "M3UFileId"
                FROM "SMStreams";

                CREATE TEMP TABLE temp_M3UFiles AS
                SELECT "Id", COALESCE("M3UKey", 0) AS "M3UKey"
                FROM "M3UFiles";

                -- Create a temporary table for batch processing
                CREATE TEMP TABLE temp_batch_update (old_id TEXT, new_id TEXT, m3ufileid INT);

                -- Insert new IDs into the batch update table
                INSERT INTO temp_batch_update (old_id, new_id, m3ufileid)
                SELECT s."Id", generate_m3u_key_value(f."M3UKey", s."M3UFileId", s."Url", s."CUID", 
                                                      s."ChannelId", s."EPGID", s."TVGName", s."Name"), s."M3UFileId"
                FROM temp_SMStreams s
                LEFT JOIN temp_M3UFiles f ON s."M3UFileId" = f."Id"
                WHERE s."M3UFileId" IS NOT NULL AND s."M3UFileId" >= 0;

                -- Update SMStreams with new IDs
                INSERT INTO "SMStreams" ("Id", "ClientUserAgent", "FilePosition", "IsHidden", 
                                         "IsUserCreated", "M3UFileId", "ChannelNumber", 
                                         "M3UFileName", "Group", "EPGID", "Logo", "Name", 
                                         "Url", "StationId", "IsSystem", "CUID", "SMStreamType", 
                                         "NeedsDelete", "ChannelName", "ChannelId", 
                                         "CommandProfileName", "TVGName", "ExtInf")
                SELECT t.new_id, s."ClientUserAgent", s."FilePosition", s."IsHidden", 
                       s."IsUserCreated", t.m3ufileid, s."ChannelNumber", s."M3UFileName", 
                       s."Group", s."EPGID", s."Logo", s."Name", s."Url", s."StationId", 
                       s."IsSystem", s."CUID", s."SMStreamType", s."NeedsDelete", s."ChannelName", 
                       s."ChannelId", s."CommandProfileName", s."TVGName", s."ExtInf"
                FROM temp_batch_update t
                INNER JOIN "SMStreams" s ON t.old_id = s."Id";

                -- Update SMChannelStreamLinks with new IDs
                INSERT INTO "SMChannelStreamLinks" ("SMStreamId", "SMChannelId", "Rank")
                SELECT t.new_id, l."SMChannelId", l."Rank"
                FROM temp_batch_update t
                INNER JOIN "SMChannelStreamLinks" l ON t.old_id = l."SMStreamId";

                -- Delete old SMChannelStreamLinks
                DELETE FROM "SMChannelStreamLinks"
                WHERE "SMStreamId" IN (SELECT old_id FROM temp_batch_update);

                -- Delete old SMStreams
                DELETE FROM "SMStreams"
                WHERE "Id" IN (SELECT old_id FROM temp_batch_update);

                -- Drop temporary tables
                DROP TABLE temp_batch_update;
                DROP TABLE temp_SMStreams;
                DROP TABLE temp_M3UFiles;

                -- Add the didIDMigration entry to SystemKeyValues
                INSERT INTO "SystemKeyValues" ("Key", "Value") VALUES ('didIDMigration', 'true');

                RAISE NOTICE 'Migration completed successfully.';
            ELSE
                -- Check for duplicate didIDMigration entries
                SELECT COUNT(*) INTO duplicate_count
                FROM "SystemKeyValues"
                WHERE "Key" = 'didIDMigration';

                IF duplicate_count > 1 THEN
                    -- Keep the first entry and delete the rest
                    WITH ordered_keys AS (
                        SELECT ctid
                        FROM "SystemKeyValues"
                        WHERE "Key" = 'didIDMigration'
                        ORDER BY ctid
                        LIMIT 1
                    )
                    DELETE FROM "SystemKeyValues"
                    WHERE "Key" = 'didIDMigration'
                    AND ctid NOT IN (SELECT ctid FROM ordered_keys);

                    RAISE NOTICE 'Cleaned up % duplicate didIDMigration entries.', duplicate_count - 1;
                END IF;

                RAISE NOTICE 'Migration has already been performed. No action needed.';
            END IF;
        END $$
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
      Failed executing DbCommand (27ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      BEGIN;
      
      -- Function to generate MD5 hash
      CREATE OR REPLACE FUNCTION generate_md5(key TEXT, M3UFileId INT)
      RETURNS TEXT AS $$
      DECLARE
          hash TEXT;
      BEGIN
          SELECT md5(concat(key, '_', M3UFileId)) INTO hash;
          RETURN hash;
      END;
      $$ LANGUAGE plpgsql;
      
      -- Function to generate M3UKey value
      CREATE OR REPLACE FUNCTION generate_m3u_key_value(M3UKey INT, M3UFileId INT, Url TEXT, 
                                                        CUID TEXT, ChannelId TEXT, EPGID TEXT, 
                                                        TVGName TEXT, Name TEXT)
      RETURNS TEXT AS $$
      DECLARE
          key TEXT;
      BEGIN
          CASE M3UKey
              WHEN 0 THEN key := Url;
              WHEN 1 THEN key := CUID;
              WHEN 2 THEN key := ChannelId;
              WHEN 3 THEN key := EPGID;
              WHEN 4 THEN key := COALESCE(TVGName, Name);
              WHEN 5 THEN 
                  IF TVGName IS NOT NULL AND EPGID IS NOT NULL THEN
                      key := TVGName || '_' || EPGID;
                  END IF;
              WHEN 6 THEN key := Name;
              WHEN 7 THEN 
                  IF Name IS NOT NULL AND EPGID IS NOT NULL THEN
                      key := Name || '_' || EPGID;
                  END IF;
              ELSE
                  RAISE EXCEPTION 'Invalid M3UKey value: %', M3UKey;
          END CASE;
          
          IF key IS NOT NULL THEN
              RETURN generate_md5(key, M3UFileId);
          ELSE
              RETURN NULL;
          END IF;
      END;
      $$ LANGUAGE plpgsql;
      
      DO $$
      DECLARE
          duplicate_count INTEGER;
      BEGIN
          -- Only proceed if migration hasn't been done
          IF NOT EXISTS (SELECT 1 FROM "SystemKeyValues" WHERE "Key" = 'didIDMigration') THEN
              -- Create temporary tables for streams and m3ufiles data
              CREATE TEMP TABLE temp_SMStreams AS
              SELECT "Id", "Url", "CUID", "ChannelId", "EPGID", "TVGName", "Name", "M3UFileId"
              FROM "SMStreams";
      
              CREATE TEMP TABLE temp_M3UFiles AS
              SELECT "Id", COALESCE("M3UKey", 0) AS "M3UKey"
              FROM "M3UFiles";
      
              -- Create a temporary table for batch processing
              CREATE TEMP TABLE temp_batch_update (old_id TEXT, new_id TEXT, m3ufileid INT);
      
              -- Insert new IDs into the batch update table
              INSERT INTO temp_batch_update (old_id, new_id, m3ufileid)
              SELECT s."Id", generate_m3u_key_value(f."M3UKey", s."M3UFileId", s."Url", s."CUID", 
                                                    s."ChannelId", s."EPGID", s."TVGName", s."Name"), s."M3UFileId"
              FROM temp_SMStreams s
              LEFT JOIN temp_M3UFiles f ON s."M3UFileId" = f."Id"
              WHERE s."M3UFileId" IS NOT NULL AND s."M3UFileId" >= 0;
      
              -- Update SMStreams with new IDs
              INSERT INTO "SMStreams" ("Id", "ClientUserAgent", "FilePosition", "IsHidden", 
                                       "IsUserCreated", "M3UFileId", "ChannelNumber", 
                                       "M3UFileName", "Group", "EPGID", "Logo", "Name", 
                                       "Url", "StationId", "IsSystem", "CUID", "SMStreamType", 
                                       "NeedsDelete", "ChannelName", "ChannelId", 
                                       "CommandProfileName", "TVGName", "ExtInf")
              SELECT t.new_id, s."ClientUserAgent", s."FilePosition", s."IsHidden", 
                     s."IsUserCreated", t.m3ufileid, s."ChannelNumber", s."M3UFileName", 
                     s."Group", s."EPGID", s."Logo", s."Name", s."Url", s."StationId", 
                     s."IsSystem", s."CUID", s."SMStreamType", s."NeedsDelete", s."ChannelName", 
                     s."ChannelId", s."CommandProfileName", s."TVGName", s."ExtInf"
              FROM temp_batch_update t
              INNER JOIN "SMStreams" s ON t.old_id = s."Id";
      
              -- Update SMChannelStreamLinks with new IDs
              INSERT INTO "SMChannelStreamLinks" ("SMStreamId", "SMChannelId", "Rank")
              SELECT t.new_id, l."SMChannelId", l."Rank"
              FROM temp_batch_update t
              INNER JOIN "SMChannelStreamLinks" l ON t.old_id = l."SMStreamId";
      
              -- Delete old SMChannelStreamLinks
              DELETE FROM "SMChannelStreamLinks"
              WHERE "SMStreamId" IN (SELECT old_id FROM temp_batch_update);
      
              -- Delete old SMStreams
              DELETE FROM "SMStreams"
              WHERE "Id" IN (SELECT old_id FROM temp_batch_update);
      
              -- Drop temporary tables
              DROP TABLE temp_batch_update;
              DROP TABLE temp_SMStreams;
              DROP TABLE temp_M3UFiles;
      
              -- Add the didIDMigration entry to SystemKeyValues
              INSERT INTO "SystemKeyValues" ("Key", "Value") VALUES ('didIDMigration', 'true');
      
              RAISE NOTICE 'Migration completed successfully.';
          ELSE
              -- Check for duplicate didIDMigration entries
              SELECT COUNT(*) INTO duplicate_count
              FROM "SystemKeyValues"
              WHERE "Key" = 'didIDMigration';
      
              IF duplicate_count > 1 THEN
                  -- Keep the first entry and delete the rest
                  WITH ordered_keys AS (
                      SELECT ctid
                      FROM "SystemKeyValues"
                      WHERE "Key" = 'didIDMigration'
                      ORDER BY ctid
                      LIMIT 1
                  )
                  DELETE FROM "SystemKeyValues"
                  WHERE "Key" = 'didIDMigration'
                  AND ctid NOT IN (SELECT ctid FROM ordered_keys);
      
                  RAISE NOTICE 'Cleaned up % duplicate didIDMigration entries.', duplicate_count - 1;
              END IF;
      
              RAISE NOTICE 'Migration has already been performed. No action needed.';
          END IF;
      END $$;
      
      COMMIT;
Error executing script 012_migrate_new_channel_ids.sql: 23505: duplicate key value violates unique constraint "PK_SMStreams"

DETAIL: Detail redacted as it may contain sensitive data. Specify 'Include Error Detail' in the connection string to include this information.
fail: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      An error occurred during database initialization
      Npgsql.PostgresException (0x80004005): 23505: duplicate key value violates unique constraint "PK_SMStreams"
      
      DETAIL: Detail redacted as it may contain sensitive data. Specify 'Include Error Detail' in the connection string to include this information.
         at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
         at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
         at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
         at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
         at Npgsql.NpgsqlDataReader.NextResult()
         at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
         at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
         at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
         at Npgsql.NpgsqlCommand.ExecuteNonQuery()
         at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
         at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(DatabaseFacade databaseFacade, String sql, IEnumerable`1 parameters)
         at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(DatabaseFacade databaseFacade, String sql, Object[] parameters)
         at StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext.ApplyCustomSqlScripts() in /src/StreamMaster.Infrastructure.EF.PGSQL/PGSQLRepositoryContext.cs:line 74
         at StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext.MigrateDatabaseAsync() in /src/StreamMaster.Infrastructure.EF.PGSQL/PGSQLRepositoryContext.cs:line 34
        Exception data:
          Severity: ERROR
          SqlState: 23505
          MessageText: duplicate key value violates unique constraint "PK_SMStreams"
          Detail: Detail redacted as it may contain sensitive data. Specify 'Include Error Detail' in the connection string to include this information.
          Where: SQL statement "INSERT INTO "SMStreams" ("Id", "ClientUserAgent", "FilePosition", "IsHidden", 
                                       "IsUserCreated", "M3UFileId", "ChannelNumber", 
                                       "M3UFileName", "Group", "EPGID", "Logo", "Name", 
                                       "Url", "StationId", "IsSystem", "CUID", "SMStreamType", 
                                       "NeedsDelete", "ChannelName", "ChannelId", 
                                       "CommandProfileName", "TVGName", "ExtInf")
              SELECT t.new_id, s."ClientUserAgent", s."FilePosition", s."IsHidden", 
                     s."IsUserCreated", t.m3ufileid, s."ChannelNumber", s."M3UFileName", 
                     s."Group", s."EPGID", s."Logo", s."Name", s."Url", s."StationId", 
                     s."IsSystem", s."CUID", s."SMStreamType", s."NeedsDelete", s."ChannelName", 
                     s."ChannelId", s."CommandProfileName", s."TVGName", s."ExtInf"
              FROM temp_batch_update t
              INNER JOIN "SMStreams" s ON t.old_id = s."Id""
      PL/pgSQL function inline_code_block line 28 at SQL statement
          SchemaName: public
          TableName: SMStreams
          ConstraintName: PK_SMStreams
          File: nbtinsert.c
          Line: 664
          Routine: _bt_check_unique
fail: Microsoft.Extensions.Hosting.Internal.Host[9]
      BackgroundService failed
      Npgsql.PostgresException (0x80004005): 23505: duplicate key value violates unique constraint "PK_SMStreams"
      
      DETAIL: Detail redacted as it may contain sensitive data. Specify 'Include Error Detail' in the connection string to include this information.
         at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
         at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
         at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
         at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
         at Npgsql.NpgsqlDataReader.NextResult()
         at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
         at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
         at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
         at Npgsql.NpgsqlCommand.ExecuteNonQuery()
         at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
         at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(DatabaseFacade databaseFacade, String sql, IEnumerable`1 parameters)
         at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(DatabaseFacade databaseFacade, String sql, Object[] parameters)
         at StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext.ApplyCustomSqlScripts() in /src/StreamMaster.Infrastructure.EF.PGSQL/PGSQLRepositoryContext.cs:line 74
         at StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext.MigrateDatabaseAsync() in /src/StreamMaster.Infrastructure.EF.PGSQL/PGSQLRepositoryContext.cs:line 34
         at StreamMaster.API.Services.PostStartup.ExecuteAsync(CancellationToken cancellationToken) in /src/StreamMaster.API/Services/PostStartup.cs:line 40
         at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
        Exception data:
          Severity: ERROR
          SqlState: 23505
          MessageText: duplicate key value violates unique constraint "PK_SMStreams"
          Detail: Detail redacted as it may contain sensitive data. Specify 'Include Error Detail' in the connection string to include this information.
          Where: SQL statement "INSERT INTO "SMStreams" ("Id", "ClientUserAgent", "FilePosition", "IsHidden", 
                                       "IsUserCreated", "M3UFileId", "ChannelNumber", 
                                       "M3UFileName", "Group", "EPGID", "Logo", "Name", 
                                       "Url", "StationId", "IsSystem", "CUID", "SMStreamType", 
                                       "NeedsDelete", "ChannelName", "ChannelId", 
                                       "CommandProfileName", "TVGName", "ExtInf")
              SELECT t.new_id, s."ClientUserAgent", s."FilePosition", s."IsHidden", 
                     s."IsUserCreated", t.m3ufileid, s."ChannelNumber", s."M3UFileName", 
                     s."Group", s."EPGID", s."Logo", s."Name", s."Url", s."StationId", 
                     s."IsSystem", s."CUID", s."SMStreamType", s."NeedsDelete", s."ChannelName", 
                     s."ChannelId", s."CommandProfileName", s."TVGName", s."ExtInf"
              FROM temp_batch_update t
              INNER JOIN "SMStreams" s ON t.old_id = s."Id""
      PL/pgSQL function inline_code_block line 28 at SQL statement
          SchemaName: public
          TableName: SMStreams
          ConstraintName: PK_SMStreams
          File: nbtinsert.c
          Line: 664
          Routine: _bt_check_unique
crit: Microsoft.Extensions.Hosting.Internal.Host[10]
      The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted.
      Npgsql.PostgresException (0x80004005): 23505: duplicate key value violates unique constraint "PK_SMStreams"
      
      DETAIL: Detail redacted as it may contain sensitive data. Specify 'Include Error Detail' in the connection string to include this information.
         at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
         at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
         at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
         at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
         at Npgsql.NpgsqlDataReader.NextResult()
         at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
         at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
         at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
         at Npgsql.NpgsqlCommand.ExecuteNonQuery()
         at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
         at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(DatabaseFacade databaseFacade, String sql, IEnumerable`1 parameters)
         at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(DatabaseFacade databaseFacade, String sql, Object[] parameters)
         at StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext.ApplyCustomSqlScripts() in /src/StreamMaster.Infrastructure.EF.PGSQL/PGSQLRepositoryContext.cs:line 74
         at StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext.MigrateDatabaseAsync() in /src/StreamMaster.Infrastructure.EF.PGSQL/PGSQLRepositoryContext.cs:line 34
         at StreamMaster.API.Services.PostStartup.ExecuteAsync(CancellationToken cancellationToken) in /src/StreamMaster.API/Services/PostStartup.cs:line 40
         at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
        Exception data:
          Severity: ERROR
          SqlState: 23505
          MessageText: duplicate key value violates unique constraint "PK_SMStreams"
          Detail: Detail redacted as it may contain sensitive data. Specify 'Include Error Detail' in the connection string to include this information.
          Where: SQL statement "INSERT INTO "SMStreams" ("Id", "ClientUserAgent", "FilePosition", "IsHidden", 
                                       "IsUserCreated", "M3UFileId", "ChannelNumber", 
                                       "M3UFileName", "Group", "EPGID", "Logo", "Name", 
                                       "Url", "StationId", "IsSystem", "CUID", "SMStreamType", 
                                       "NeedsDelete", "ChannelName", "ChannelId", 
                                       "CommandProfileName", "TVGName", "ExtInf")
              SELECT t.new_id, s."ClientUserAgent", s."FilePosition", s."IsHidden", 
                     s."IsUserCreated", t.m3ufileid, s."ChannelNumber", s."M3UFileName", 
                     s."Group", s."EPGID", s."Logo", s."Name", s."Url", s."StationId", 
                     s."IsSystem", s."CUID", s."SMStreamType", s."NeedsDelete", s."ChannelName", 
                     s."ChannelId", s."CommandProfileName", s."TVGName", s."ExtInf"
              FROM temp_batch_update t
              INNER JOIN "SMStreams" s ON t.old_id = s."Id""
      PL/pgSQL function inline_code_block line 28 at SQL statement
          SchemaName: public
          TableName: SMStreams
          ConstraintName: PK_SMStreams
          File: nbtinsert.c
          Line: 664
          Routine: _bt_check_unique
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...
info: StreamMaster.Application.Statistics.Commands.SetIsSystemReadyRequest[0]
      System build 0.7.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds more detailsUnclear or needing more details

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions