K2 Five Upgrade fails with "An item with the same key has already been added"

  • 16 February 2021
  • 0 replies

Userlevel 4
Badge +16


K2 Five upgrade fails with "An item with the same key has already been added"

This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.


When upgrading from 4.7 to K2 5.3, if duplicate attributes LogLevel=Error;LogSize=0;LogLevel=Error;LogSize=0; are detected in the [RoleInit] column for the K2 SecurityLabel:

The upgrade would fail with the following error:

16:52:31:>> MigrateDatabase.Execute: Logged Error: Failed: System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at SourceCode.Sync.Storage.Sql.SyncEngineContext.GetADUMProviderInstances(XElement roleInit)
at SourceCode.Sync.Storage.Sql.SyncEngineContext.GetRoleInitProviderInstances(String roleInitValue, Boolean& adumInstancesExist)
at SourceCode.Sync.Storage.Sql.SyncEngineContext.GetRoleInitProvider(IProviderType legacyProviderType, IProviderType adProviderType, String providerName, String roleInitValue)
at SourceCode.Sync.Storage.Sql.SyncEngineContext.SeedExistingProviders()
at SourceCode.Sync.Storage.Sql.SyncEngineContext.DatabaseMigrate()
at SourceCode.Install.Package.Actions.Database.Migrations.MigrateDatabase.<>c.b__3_0(String connectionString)
at SourceCode.Install.Package.Actions.IsolatedExecution.AppDomainDelegate.Execute[T,TResult](T parameter, Func`2 func)
at SourceCode.Install.Package.Actions.IsolatedExecution.Execute[T,TResult](T parameter, Func`2 func, String privateBinPath, Boolean enableLogging)
at SourceCode.Install.Package.Actions.Database.Migrations.MigrateDatabase.ExecuteMigrateSyncEngine(String dbConnectionString)
at SourceCode.Install.Package.Actions.Database.Migrations.MigrateDatabase.Execute(Target target)
16:52:31:>> Log.WriteUnindent: Finish MigrateDatabase for 'SyncEngine'. Successful: False
16:52:31:>> Target.Execute: !Completed: SyncEngine, Success: False
16:52:31:>> ActionGroup.Execute: Logged Error: Target failed to execute: SyncEngine


Although you can update the K2 Security Label, and remove the duplicate "LogLevel=Error;LogSize=0;" entry from the [RoleInit] column and then successfully re-"Configure" K2 Five.  The installation of the 5.3 New Identity Service Opt-in would be successful.  However, performing the initial sync results in an error:

0 Execute 'RunSyncJob' Error : The Provider Instance with Name or ID 'DENALLIX' was not found.

The applicable entries were not seeded into the [SyncEngine] tables resulting in the error.


1.  If a 4.7 K2 database backup and 4.7 K2 server VM snapshot exists prior to the upgrade:

  1. Revert to the 4.7 snapshot

  2. Restore the 4.7 K2 database backup

  3. Remove the duplicate LogLevel=Error;LogSize=0; entry

  4. Re-perform the upgrade

2.  If a 4.7 VM snapshot does not exist

  1. Uninstall K2 Five

  2. Restore the 4.7 K2 database backup 

  3. Remove the duplicate LogLevel=Error;LogSize=0; entry

  4. Re-install 4.7

  5. Re-perform the upgrade

3.  If neither exists, logging a Support ticket may be necessary.

0 replies

Be the first to reply!