An item with the same key has already been added.

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
surf
Ensign (ENS)
Ensign (ENS)
Posts: 19
Joined: Fri Dec 05, 2008 10:33 am

An item with the same key has already been added.

Post by surf » Fri Feb 24, 2012 1:24 pm

Message: An error has occured at http://www.fencesource.com/Vinyl-Adhesi ... 80C22.aspx
Debug Data: An item with the same key has already been added.

I have a ton of these error messages since I upgraded to the last version. The web pages pull up just fine. I don't see an error.

Any help would be apprecaited.
Thanks!!

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: An item with the same key has already been added.

Post by AbleMods » Fri Feb 24, 2012 8:11 pm

I noticed the same thing tonight in my 7.0.7 site. But only infrequently, tons of them like yours. I'm not sure where it's coming from unless it's the page views.

You might try turning off page view tracking just for a little while to see if the messages go away.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
RichWendrock
Commander (CMDR)
Commander (CMDR)
Posts: 134
Joined: Sat Apr 05, 2008 12:55 am
Location: Austin Texas
Contact:

Re: An item with the same key has already been added.

Post by RichWendrock » Thu May 02, 2013 2:02 pm

We are getting a lot of these errors. Did anyone determine what is causing the problem? Did anyone find a fix?

HERE IS ONE OF THE ERRORS; THE ONLY REFERENCE TO Dictionary`2 IS IN THE FILE Newtoosoft.jSON.xml
wnn280 :: ERROR :: An error has occured at https://www.hillcountrycustomcycles.com/Basket.aspx
Logger: System.Object
Thread: 7
Date: 2013-05-02 11:08:43,968
NDC: (null)

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 System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Seo.RedirectService.InitializeCache()
at CommerceBuilder.Seo.RedirectService.LocateRedirect(String sourceUrl)
at CommerceBuilder.Services.c.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

HERE IS ANOTHER ONE
wnn280 :: INFO :: Running maintenance routines
Logger: System.Object
Thread: 10
Date: 2013-05-02 11:08:43,765
NDC: (null)

wnn280 :: ERROR :: An error has occured at http://www.hillcountrycustomcycles.com/default.aspx
Logger: System.Object
Thread: 19
Date: 2013-05-02 11:08:43,968
NDC: (null)

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 System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Catalog.DefaultUrlRewriter.InitializeCache()
at CommerceBuilder.Catalog.DefaultUrlRewriter.a(String A_0)
at CommerceBuilder.Catalog.DefaultUrlRewriter.RewriteUrl(String sourceUrl)
at CommerceBuilder.Services.c.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Regards,
Richard

http://www.TheHomePageStore.com

AbleCommerce
VERSION: 7.0.7.14588
MSSQL v2005
AC SCHEMA v2005
.NET CLR v2.0.50727.3634

User avatar
ForumsAdmin
AbleCommerce Moderator
AbleCommerce Moderator
Posts: 399
Joined: Wed Mar 13, 2013 7:19 am

Re: An item with the same key has already been added.

Post by ForumsAdmin » Fri May 03, 2013 5:15 am

By any chance do you have multiple entries for the same custom URL in your system?

User avatar
RichWendrock
Commander (CMDR)
Commander (CMDR)
Posts: 134
Joined: Sat Apr 05, 2008 12:55 am
Location: Austin Texas
Contact:

Re: An item with the same key has already been added.

Post by RichWendrock » Fri May 03, 2013 5:36 am

That is a good question, I was not sure how to verify this without editing every custom page until I displayed the ac_CustomUrls table. There are eight entries and each one has a different URL.
Regards,
Richard

http://www.TheHomePageStore.com

AbleCommerce
VERSION: 7.0.7.14588
MSSQL v2005
AC SCHEMA v2005
.NET CLR v2.0.50727.3634

User avatar
efficiondave
Commander (CMDR)
Commander (CMDR)
Posts: 151
Joined: Tue Dec 02, 2008 10:20 am
Location: St. Louis Missouri
Contact:

Re: An item with the same key has already been added.

Post by efficiondave » Tue May 14, 2013 8:42 pm

I'm seeing this error a lot too. There are no duplicate URLs in my ac_CustomUrls table.

User avatar
RichWendrock
Commander (CMDR)
Commander (CMDR)
Posts: 134
Joined: Sat Apr 05, 2008 12:55 am
Location: Austin Texas
Contact:

Re: An item with the same key has already been added.

Post by RichWendrock » Wed May 15, 2013 4:25 am

I am still getting these errors. I hope that AbleCommerce will respond to this question soon.

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 System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Seo.RedirectService.InitializeCache()
at CommerceBuilder.Seo.RedirectService.LocateRedirect(String sourceUrl)
at CommerceBuilder.Services.c.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Regards,
Richard

http://www.TheHomePageStore.com

AbleCommerce
VERSION: 7.0.7.14588
MSSQL v2005
AC SCHEMA v2005
.NET CLR v2.0.50727.3634

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: An item with the same key has already been added.

Post by compunerdy » Wed May 15, 2013 11:41 am

This has been posted on since 2010..

viewtopic.php?f=42&t=14576&p=72233&hili ... key#p72233

User avatar
ForumsAdmin
AbleCommerce Moderator
AbleCommerce Moderator
Posts: 399
Joined: Wed Mar 13, 2013 7:19 am

Re: An item with the same key has already been added.

Post by ForumsAdmin » Fri May 17, 2013 9:16 am

I am investigatin this. Can you confirm you are using version 7.0.7 Build 14588?

User avatar
efficiondave
Commander (CMDR)
Commander (CMDR)
Posts: 151
Joined: Tue Dec 02, 2008 10:20 am
Location: St. Louis Missouri
Contact:

Re: An item with the same key has already been added.

Post by efficiondave » Fri May 17, 2013 9:30 am

I'm running 7.0.7 Build 14600 and get an error in a similar vein...

I've seen this error 11 time in the last month:
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 System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at CommerceBuilder.Catalog.DefaultUrlRewriter.InitializeCache()
at CommerceBuilder.Catalog.DefaultUrlRewriter.a(String A_0)
at CommerceBuilder.Catalog.DefaultUrlRewriter.RewriteUrl(String sourceUrl)
at CommerceBuilder.Services.b.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

User avatar
RichWendrock
Commander (CMDR)
Commander (CMDR)
Posts: 134
Joined: Sat Apr 05, 2008 12:55 am
Location: Austin Texas
Contact:

Re: An item with the same key has already been added.

Post by RichWendrock » Fri May 17, 2013 9:41 am

Yes, the versions are correct for my system.
Regards,
Richard

http://www.TheHomePageStore.com

AbleCommerce
VERSION: 7.0.7.14588
MSSQL v2005
AC SCHEMA v2005
.NET CLR v2.0.50727.3634

User avatar
deverill
Lieutenant (LT)
Lieutenant (LT)
Posts: 64
Joined: Tue Jan 06, 2009 11:58 am
Location: Key West, FL
Contact:

Re: An item with the same key has already been added.

Post by deverill » Thu Jun 13, 2013 12:38 pm

I see these often in our 7.0.6 store when developing. In my case it's when the page is loaded and I change the code. When I refresh the page I get this error but it is usually on the page in the browser and not just the event log.

On my production server I am also seeing them in the event logs but no reports of customers seeing the error. Here's a partial example:

Exception information:
Exception type: ArgumentException
Exception message: An item with the same key has already been added.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Catalog.DefaultUrlRewriter.InitializeCache()

It seems it's starting in the URLRewriter and we have a ton of redirects and custom URLs so it's possible we have a dupe there.

Hope it helps someone.
Jim

User avatar
RichWendrock
Commander (CMDR)
Commander (CMDR)
Posts: 134
Joined: Sat Apr 05, 2008 12:55 am
Location: Austin Texas
Contact:

Re: An item with the same key has already been added.

Post by RichWendrock » Thu Jun 13, 2013 1:08 pm

I have noticed that strange errors occur when maintenance starts up. I have seen this particular error occur around the same time as maintenance starting. I see the error occurred yesterday when a customer was trying to display products in a category. I assume the customer clicked a menu category link. I know that AbleCommerce will not allow you to create a duplicate redirect. You can have many URLs redirecting to the same target URL but you can not have duplicate Request Paths. As for the duplicate custom URLs, I do not see how you can have a duplicate custom URL if there is no duplicate in the ac_CustomUrls table. Display the records in that table to confirm. I am suspicious of the maintenance routines some how causing functions to fail. Functions like the customer displaying a product or category.
Regards,
Richard

http://www.TheHomePageStore.com

AbleCommerce
VERSION: 7.0.7.14588
MSSQL v2005
AC SCHEMA v2005
.NET CLR v2.0.50727.3634

User avatar
RichWendrock
Commander (CMDR)
Commander (CMDR)
Posts: 134
Joined: Sat Apr 05, 2008 12:55 am
Location: Austin Texas
Contact:

Re: An item with the same key has already been added.

Post by RichWendrock » Mon Jun 17, 2013 7:35 am

Here is an example of an error that occurred this morning.

wnn280 :: INFO :: Running maintenance routines
Logger: System.Object
Thread: 20
Date: 2013-06-17 06:38:36,633
NDC: (null)

wnn280 :: ERROR :: An error has occured at http://www.hillcountrycustomcycles.com/ ... =0601-0779
Logger: System.Object
Thread: 16
Date: 2013-06-17 06:38:36,711
NDC: (null)

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 System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Catalog.DefaultUrlRewriter.InitializeCache()
at CommerceBuilder.Catalog.DefaultUrlRewriter.a(String A_0)
at CommerceBuilder.Catalog.DefaultUrlRewriter.RewriteUrl(String sourceUrl)
at CommerceBuilder.Services.c.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

AND THEN THIS ERROR IMMEDIATELY AFTER

wnn280 :: ERROR :: An error has occured at http://www.hillcountrycustomcycles.com/ ... P2186.aspx
Logger: System.Object
Thread: 7
Date: 2013-06-17 06:38:36,711
NDC: (null)

System.NullReferenceException: Object reference not set to an instance of an object.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at CommerceBuilder.Catalog.DefaultUrlRewriter.InitializeCache()
at CommerceBuilder.Catalog.DefaultUrlRewriter.a(String A_0)
at CommerceBuilder.Catalog.DefaultUrlRewriter.RewriteUrl(String sourceUrl)
at CommerceBuilder.Services.c.c(Object A_0, EventArgs A_1)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Regards,
Richard

http://www.TheHomePageStore.com

AbleCommerce
VERSION: 7.0.7.14588
MSSQL v2005
AC SCHEMA v2005
.NET CLR v2.0.50727.3634

User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

Re: An item with the same key has already been added.

Post by crockettdunn » Thu Oct 24, 2013 1:44 pm

I've experienced similar issues, and I have the same hunch that they're tied to maintenance. In fact, my customURL maintenance times out, so I was hoping to get an answer here to the following:

In what file(s) does the custom URL maintenance occur? I'd like to disable this and run it offline, but I don't want to disable anonymous user maintenance.

User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

Re: An item with the same key has already been added.

Post by crockettdunn » Thu Oct 22, 2015 8:46 am

Found the problem. Does anyone know if this is resolved in GOLD? There is a huge sql query failing:

Code: Select all

DELETE FROM CUSTOM_Urls where ID not in (1,2,3,4,5...)

and the comma separated string goes on for over a megabyte. It seems to be listing every non-orphaned customUrl in the store. Wouldn't this be better handled as a nested query rather than enumerating the results of the subquery as a giant list of IDs?

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: An item with the same key has already been added.

Post by Katie » Fri Oct 23, 2015 5:57 am

I could check, but I need some kind of reference to a file first. Where did you copy this code snipet from?
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

Re: An item with the same key has already been added.

Post by crockettdunn » Fri Oct 23, 2015 8:00 am

Hi Katie,

The code snippet came from the app.log. Here is the info preceding it:

Code: Select all

ERROR 2015-10-23 12:02:09,045 28924657ms Object                 RunMaintenance     - Error maintaining custom urls
System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at CommerceBuilder.Data.Database.a(DbCommand A_0)
   at CommerceBuilder.Data.Database.ExecuteNonQuery(DbCommand command)
   at CommerceBuilder.Utility.MaintenanceWorker.a(List`1 A_0, CatalogNodeType A_1)
   at CommerceBuilder.Utility.MaintenanceWorker.i()
   at CommerceBuilder.Utility.MaintenanceWorker.RunMaintenance()
ClientConnectionId:a047ed57-cfc2-4032-b518-f8d222e49370
Error Number:-2,State:0,Class:11
INFO  2015-10-23 12:02:09,060 28924673ms Object                 RunMaintenance     - Maintenance routines complete
INFO  2015-10-23 13:00:05,701 32401313ms Object                 RunMaintenance     - Running maintenance routines
INFO  2015-10-23 13:00:05,717 32401329ms Object                 f                  - User maintenance cleared 1 expired anonymous users, last active before 9/22/2015 5:00:05 PM
INFO  2015-10-23 13:00:07,121 32402733ms Object                 f                  - User maintenance cleared 282 expired affiliate anonymous users, last active before 9/22/2015 5:00:05 PM
INFO  2015-10-23 13:00:07,121 32402733ms Object                 d                  - Payment maintenance cleared 2 expired payments, completed before 8/24/2015 5:00:07 PM
WARN  2015-10-23 13:02:09,024 32524636ms Object                 a                  -  DELETE FROM ac_CustomUrls WHERE...
giant list of customURL IDs here, then:

Code: Select all

System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at CommerceBuilder.Data.Database.a(DbCommand A_0)
ClientConnectionId:6b9d2882-4e80-4bdf-acfd-d2a51bc92b65
Error Number:-2,State:0,Class:11
Not exactly a filename, but I hope that g ives you enough context.

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: An item with the same key has already been added.

Post by Katie » Mon Oct 26, 2015 5:47 am

I did a bit of searching around, and it seems this issue only exists in AC7. Gold has been out for over 3 years now and no one has reported the issue.

It's not easy to do much troubleshooting because I would need to be able to replicate the issue in a stock installation. The error alone doesn't give me all the information needed to generate a bug report that can be used to test.
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

Re: An item with the same key has already been added.

Post by crockettdunn » Mon Oct 26, 2015 10:06 am

If it's fixed in Gold, that's all I need to know. Thanks, Katie!

Post Reply