2941 - Error migrating database after upgrade

Hi
 
Error below after upgrading to 1.0.0.2941. Obviously, this is preventing us from building at the moment (haven’t tried to downgrade - seemed dangerous to me). We’re running on Postgres as installed by the Continua installer.

Cheers

Joel


Log Name:      Application
Source:        Continua
Date:          17/02/2014 9:43:15 AM
Event ID:      0
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      BUILD-MASTER.AGData.local
Description:
Could not initialise database:

System.Exception: An error occurred executing the following sql:
ALTER TABLE core_securityentitygroup ADD CONSTRAINT PK_core_securityentitygroup_securityentityid_groupid PRIMARY KEY (securityentityid, groupid)
The error was ERROR: 42P16: multiple primary keys for table “core_securityentitygroup” are not allowed
 —> Npgsql.NpgsqlException: ERROR: 42P16: multiple primary keys for table “core_securityentitygroup” are not allowed
   at Npgsql.NpgsqlState.<processbackendresponses_ver_3>d__a.MoveNext()
   at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()
   at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
   at Npgsql.ForwardsOnlyDataReader.NextResult()
   at Npgsql.ForwardsOnlyDataReader…ctor(IEnumerable1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError)<br>&nbsp; &nbsp;at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)<br>&nbsp; &nbsp;at Npgsql.NpgsqlCommand.ExecuteNonQuery()<br>&nbsp; &nbsp;at FluentMigrator.Runner.Processors.Postgres.PostgresProcessor.Process(String sql)<br>&nbsp; &nbsp;--- End of inner exception stack trace ---<br>&nbsp; &nbsp;at FluentMigrator.Runner.Processors.Postgres.PostgresProcessor.Process(String sql)<br>&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.AnnounceTime(String message, Action action)<br>&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.ExecuteExpressions(ICollection1 expressions)
   at FluentMigrator.Runner.MigrationRunner.Up(IMigration migration)
   at FluentMigrator.Runner.MigrationRunner.ApplyMigrationUp(Int64 version)
   at FluentMigrator.Runner.MigrationRunner.MigrateUp(Boolean useAutomaticTransactionManagement)
   at FluentMigrator.Runner.Initialization.TaskExecutor.Execute()
   at Continua.Migrations.Runner.Execute(String database, String connectionString, String fileName)
   at Continua.Server.Service.Migrator.Begin()
Exiting…
Event Xml:

 
   
    0
    2
    0
    0x80000000000000
   
    4158405
    Application
    BUILD-MASTER.AGData.local
   
 
 
    Could not initialise database:

System.Exception: An error occurred executing the following sql:
ALTER TABLE core_securityentitygroup ADD CONSTRAINT PK_core_securityentitygroup_securityentityid_groupid PRIMARY KEY (securityentityid, groupid)
The error was ERROR: 42P16: multiple primary keys for table “core_securityentitygroup” are not allowed
 —&gt; Npgsql.NpgsqlException: ERROR: 42P16: multiple primary keys for table “core_securityentitygroup” are not allowed
   at Npgsql.NpgsqlState.&lt;ProcessBackendResponses_Ver_3&gt;d__a.MoveNext()
   at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()
   at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
   at Npgsql.ForwardsOnlyDataReader.NextResult()
   at Npgsql.ForwardsOnlyDataReader…ctor(IEnumerable1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError)<br>&nbsp; &nbsp;at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)<br>&nbsp; &nbsp;at Npgsql.NpgsqlCommand.ExecuteNonQuery()<br>&nbsp; &nbsp;at FluentMigrator.Runner.Processors.Postgres.PostgresProcessor.Process(String sql)<br>&nbsp; &nbsp;--- End of inner exception stack trace ---<br>&nbsp; &nbsp;at FluentMigrator.Runner.Processors.Postgres.PostgresProcessor.Process(String sql)<br>&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.AnnounceTime(String message, Action action)<br>&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.ExecuteExpressions(ICollection1 expressions)
   at FluentMigrator.Runner.MigrationRunner.Up(IMigration migration)
   at FluentMigrator.Runner.MigrationRunner.ApplyMigrationUp(Int64 version)
   at FluentMigrator.Runner.MigrationRunner.MigrateUp(Boolean useAutomaticTransactionManagement)
   at FluentMigrator.Runner.Initialization.TaskExecutor.Execute()
   at Continua.Migrations.Runner.Execute(String database, String connectionString, String fileName)
   at Continua.Server.Service.Migrator.Begin()
Exiting…
 
</processbackendresponses_ver_3>

Hi Joel,

Can you shutdown the continua server service, run the following SQL commands on your postgres database, then restart the server service?

ALTER TABLE core_securityentitygroup DROP CONSTRAINT pk_core_securityentitygroup_securityentityid_groupid;
 
ALTER TABLE core_accesscontrollistentryrole DROP CONSTRAINT pk_core_accesscontrollistentryrole_accesscontrollistentryid_rol;

The latest build adds primary keys which were missing in previous builds. I’m not sure why you already had them -  I’ll investigate

Thanks Dave.

In addition to those two I also had to drop pk_versioninfo_version from versioninfo. After doing that everything starts up as expected (and the keys reappeared). Thanks for helping sort it so quickly!

Joel

Hi Joel, 

Good to know that its now working. I think your Continua server must have started as an early beta version? The primary keys existed in a beta version 16 months ago but were incorrectly commented out from the migration. We will now update the migration code to check if they exist before creating them.

Thanks Dave. Yes, this server has been around since early betas.