Agraell
Agraell

Reputation: 83

An entry with the same key already exists

I am building a site in Umbraco 7. I was on 7.3.x now updated to 7.4.0. On random occasions the site will break and I will get the following message.

 [ArgumentException: An entry with the same key already exists.]
   System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
   System.Collections.Generic.SortedList`2.Add(TKey key, TValue value) +6744873
   Umbraco.Core.MainDom.Register(Action install, Action release, Int32 weight) +128
   Umbraco.Core.Sync.DatabaseServerMessenger.Boot() +55
   Umbraco.Web.BatchedDatabaseServerMessenger.Startup() +186
   Umbraco.Web.BatchedDatabaseServerMessengerStartup.ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) +63
   Umbraco.Core.ApplicationEventHandler.OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) +37
   Umbraco.Core.CoreBootManager.<Complete>b__a(IApplicationEventHandler x) +230
   Umbraco.Core.EnumerableExtensions.ForEach(IEnumerable`1 items, Action`1 action) +141
   Umbraco.Core.CoreBootManager.Complete(Action`1 afterComplete) +293
   Umbraco.Web.WebBootManager.Complete(Action`1 afterComplete) +60
   Umbraco.Core.UmbracoApplicationBase.StartApplication(Object sender, EventArgs e) +234
   Umbraco.Core.UmbracoApplicationBase.Application_Start(Object sender, EventArgs e) +34

I have narrowed the issue and it is related to the Examine index. In the development environment I just need to rebuild and it works fine but on the test we need to stop application pool delete Examine index and restart things.

I also get this from the logs

2016-02-16 08:12:50,006 [P4656/D62/T1] INFO  Umbraco.Core.DatabaseContext - CanConnect = True
 2016-02-16 08:12:50,051 [P4656/D62/T1] INFO  Umbraco.Core.DatabaseContext - CanConnect = True
 2016-02-16 08:12:50,051 [P4656/D62/T1] INFO  Umbraco.Core.DatabaseContext - CanConnect = True
 2016-02-16 08:12:50,072 [P4656/D62/T1] INFO  Umbraco.Core.DatabaseContext - CanConnect = True
 2016-02-16 08:12:50,072 [P4656/D62/T1] ERROR Umbraco.Core.CoreBootManager - An error occurred running OnApplicationStarted for handler Umbraco.Web.BatchedDatabaseServerMessengerStartup
System.ArgumentException: An entry with the same key already exists.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.SortedList`2.Add(TKey key, TValue value)
   at Umbraco.Core.MainDom.Register(Action install, Action release, Int32 weight)
   at Umbraco.Core.Sync.DatabaseServerMessenger.Boot()
   at Umbraco.Web.BatchedDatabaseServerMessenger.Startup()
   at Umbraco.Web.BatchedDatabaseServerMessengerStartup.ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
   at Umbraco.Core.ApplicationEventHandler.OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
   at Umbraco.Core.CoreBootManager.<Complete>b__a(IApplicationEventHandler x)
 2016-02-16 08:12:50,074 [P4656/D62/T1] ERROR Umbraco.Core.UmbracoApplicationBase - An unhandled exception occurred
System.ArgumentException: An entry with the same key already exists.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.SortedList`2.Add(TKey key, TValue value)
   at Umbraco.Core.MainDom.Register(Action install, Action release, Int32 weight)
   at Umbraco.Core.Sync.DatabaseServerMessenger.Boot()
   at Umbraco.Web.BatchedDatabaseServerMessenger.Startup()
   at Umbraco.Web.BatchedDatabaseServerMessengerStartup.ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
   at Umbraco.Core.ApplicationEventHandler.OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
   at Umbraco.Core.CoreBootManager.<Complete>b__a(IApplicationEventHandler x)
   at Umbraco.Core.EnumerableExtensions.ForEach[TItem](IEnumerable`1 items, Action`1 action)
   at Umbraco.Core.CoreBootManager.Complete(Action`1 afterComplete)
   at Umbraco.Web.WebBootManager.Complete(Action`1 afterComplete)
   at Umbraco.Core.UmbracoApplicationBase.StartApplication(Object sender, EventArgs e)
   at Umbraco.Core.UmbracoApplicationBase.Application_Start(Object sender, EventArgs e)

I have read that this could be related to a duplicate user but no such things exists in the database.

Another issue that might be causing this is that the dev site and the test site share the same Umbraco database. I am not sure if that could cause this kind of conflict.

In any case I am really confused about this error and any help would be highly appreciated as it is really critical.

Thanks in advance, Vasilis

Upvotes: 0

Views: 2142

Answers (1)

Jan Bluemink
Jan Bluemink

Reputation: 3487

It is possible to share the database, but you need to setup it as an Load Balanced environment. (caching)

Follow the guide https://our.umbraco.org/documentation/Getting-Started/Setup/Server-Setup/load-balancing/

Upvotes: 1

Related Questions