Strange Duplicate Key Error during cart checkout
While doing some testing on my development machine I added 4 items to my shopping cart and checked out. After entering my payment info and clicking the "Place this order" button, the sfMessage div on the checkout page displayed the following:
Insert of '1800978614-e74f77a3-0731-4138-a8cc-5ea40b8458d2' failed: Telerik.OpenAccess.RT.sql.SQLException: Cannot insert duplicate key row in object 'dbo.sf_user_link' with unique index 'idx_sf_user_link'. The statement has been terminated. at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute() at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute() at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes) INSERT INTO [sf_user_link] ([app_name], [id], [last_modified], [membership_info], [role_id], [user_id], [voa_version]) VALUES (?, ?, ?, ?, ?, ?, ?) (set event logging to all to see parameter values)
The items remain in the cart and after 30 seconds or do the div auto hides itself. If I try to click the "Place this order" button again, the div displays the following message:
A duplicate transaction has been submitted.
Again, the div auto hides 30 seconds or so later and if I try clicking the button again, the process repeats with the first message.
Oddly, I get the "Customer Receipt/Purchase Confirmation" email but not the "Confirming Order nn" email. At this point the cart is in limbo and the only way to submit the order is to empty the cart and start from scratch.
I've had a look at the sf_user_link table (see attached image) and there is only one record and none of the columns contain the 1800978614-e74f77a3-0731-4138-a8cc-5ea40b8458d2 value that the message is complaining about.
The sf_ec_order contains a row that matches the date, time, and dollar amount of the order and has an order_attempts value of 5 which matches the number of times I tried to submit the order that resulted in the messages listed above. So it does look like the order was received. On the ecommerce backend, the order shows as "Authorized".
I'm a little puzzled by the multiple emails. When an order goes through successfully, I get 2 emails. One is titled: "Nashoba Learning Group Customer Receipt/Purchase Confirmation" (see receipt1.png). The other is titled; "Confirming Order NN" (where NN is the actual order number). Is the first email being generated by the payment processor?
--Steve
Hi Steve,
The first e-mail shopuld be genereate by the payment processor, since it only outputs emails, but in this case the functionality might encounter a problem.
I have tested the scenario you mentioned and didn`t reproduced the problem.
I am not sure what is causing the products to auto hide after 30 seconds, is this happening every time you purchase ?
Is there javascript loaded on the page with the checkout widget that might interfere with with the button (are there any javascript errors on the page inspecting it with firebug)?
Hi Stanislav,
Sorry, the products aren't autohiding--the div that displays the exception is autohiding. But the question is why exception occuring and why is the order being added to the orders table if there was in fact a problem?
Steve
Hello,
I am not sure why this is happening I was unable to reproduce it on my project.
To better specify why this error is happening and what is causing it can you test creating two pages with out a template (start from scratch). Place product list widget and shopping cart on one of the pages and checkout on the other page (I am not sure how the ecommerce is setup at your end and so I am only refering to the tree widgets that are needed to setup a shop). Are you getting the same error when taking the same steps to checkout on those pages?
If yes then there should be a problem with the ecommerce module.
If not then there is some javascript or page property on the pages where you get the error.
Hi Stanislav,
I'll try your suggestion but the problem is so sporadic that short of submiting dozens of test orders I doubt I'll be able to duplicate it. And if it doesn't reappear on the new pages it's not really a difinitive test--i might have been one test order away from it happening again.
Regarding potential javascript or page properties problems on the existing pages; I haven't added any javascript to these pages so what's there is the javascript being added by SF. As far as page properties go they'd be the same for each order so why the random pattern?
Has anyone else reported or seen this type of error?
Thanks--Steve