Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Vasilis 8 posts 118 karma points
    Feb 15, 2016 @ 11:07
    Vasilis
    0

    An entry with the same key already exists

    Hello,

    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 examin 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

    * EDIT / [SOLVED] * The problem was happening because I was using load balanced configuration in the umbracoConfig.settings to the dev server where that was not needed.

  • Braydie 148 posts 346 karma points
    Mar 23, 2016 @ 21:42
    Braydie
    0

    hey @Vasilis, did you get a resolution to this? I've just started working on a site in dev and it's now randomly throwing this exception for me too. I've found an iisreset clears it for me, but obviously that's not workable for live

  • Braydie 148 posts 346 karma points
    Apr 27, 2016 @ 21:17
    Braydie
    0

    @Vasilis? Any joy in resolving this?

  • Vasilis 8 posts 118 karma points
    Oct 05, 2017 @ 12:48
    Vasilis
    100

    Hey there. I am really sorry I didn't see this before. The problem was happening because I was using load balanced configuration in the umbracoConfig.settings to the dev server where that was not needed.

  • Braydie 148 posts 346 karma points
    Apr 27, 2016 @ 21:18
    Braydie
    0

    Full stack trace for me:

    [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) +6694073
       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) +219
       Umbraco.Core.EnumerableExtensions.ForEach(IEnumerable`1 items, Action`1 action) +141
       Umbraco.Core.CoreBootManager.Complete(Action`1 afterComplete) +282
       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
    
    [HttpException (0x80004005): An entry with the same key already exists.]
       System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9907317
       System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
       System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
       System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
       System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
    
    [HttpException (0x80004005): An entry with the same key already exists.]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9920856
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
    
  • Zaid AlSafadi 1 post 71 karma points
    Sep 28, 2016 @ 13:17
    Zaid AlSafadi
    0

    Did anyone find a solution to this issue? I cam in this morning and my application in Dev is giving me the same error and stack trace, everything was good before I left the day before.

    I'm looking at the CMS code for the last two methods in the stack and I can see why the problem can happen but not sure how:

     at Umbraco.Core.**MainDom.Register**(Action install, Action release, Int32 weight)
       at Umbraco.Core.Sync.**DatabaseServerMessenger.Boot**()
    

    The code in the DatabaseServerMessenger.Boot is calling "Register" on the MainDom class with a "wight" parameter value of 10. In the Dom.Register class, this value gets added as a key into a sorted list which is giving the above error, I do not know why this is being added again... _callbacks.Add(weight, release);

      // register a main domain consumer
        public bool Register(Action install, Action release, int weight = 100)
        {
            lock (_locko)
            {
                if (_signaled) return false;
                if (install != null)
                    install();
                if (release != null)
                    _callbacks.Add(weight, release);
                return true;
            }
        }
    

    The "DatabaseServerMessenger.Boot" method has a remarks that it is not thread safe and caller MUST ensure thread safety. Could this be related?

    As I said, the application was running fine without anyone touching it until I came in the morning and I started receiving this error.

  • Paul Trandem 1 post 22 karma points
    Apr 28, 2017 @ 13:50
    Paul Trandem
    0

    I just got this error after I removed my App_Data/umbraco.config file during a troubleshooting session in development.

    The solution that worked for me was to remove the whole App_Data/TEMP folder and allow it all to be regenerated.

    I'm not sure the root cause (I'm guessing it's related to indexing, as Vasilis indicated), but I wanted to post this workaround in case it helps anyone else.

Please Sign in or register to post replies

Write your reply to:

Draft