OrderTracking Row Insert Unsuccessful Under Stress and Commerce Server Event 4104 Logged (320781)



The information in this article applies to:

  • Microsoft Commerce Server 2002

This article was previously published under Q320781

SYMPTOMS

Intermittently, the following event is logged on the Commerce Server computer:
Event Type:      Error
Event Source:    Commerce Server 2000
Event Category:  None
Event ID:        4104
Date:            3/13/2002
Time:            3:18:53 PM
User:            N/A
Computer:        <Machine_Name>
Description:
Pipeline Error:  Component Execution failed for component[0x8]  hr: 0x80020101
ProgID: Commerce.Scriptor.1
MscsExecute() failed.
Script invocation failed.
Violation of PRIMARY KEY constraint 'PK_counters'. Cannot insert duplicate key in object 'counters'.
Line: 5.
				
The following type of error occurs in the browser upon checkout:
2002-03-13 20:27:57 157.59.127.25 - 157.59.127.25 443 POST /payment.asp
|217|80040e2f|Violation_of_PRIMARY_KEY_constraint_'PK_counters'.
_Cannot_insert_duplicate_key_in_object_'counters'. 500 702 1520 
				
The following error is logged in the pipeline log:
PIPELINE:-- component [0x8] returned hr: 0x80020101, IErrorLevel=4 
in 36125 milliseconds
Error Description: Component Execution failed for component[0x8]  
hr: 0x80020101ProgID: Commerce.Scriptor.1MscsExecute() failed.Script
invocation failed.Violation of PRIMARY KEY constraint 'PK_counters'. 
Cannot insert duplicate key in object 'counters'.Line: 5.
PIPELINE:-- 2002/03/20 13:44:41.0025 Pipeline Execution completed 
returning hr: 0x80020101              i:  0x9         hrLoop:  
0x80020101  *plErrorLevel:  1000(=====MTS ABORTed=====)
Sink stopped at 2002/03/20 13:44:41.0025
				
The following statements are logged in a Microsoft SQL Server trace log around the time the error occurs:
exec sp_cursor 180150000, 4, 0, N'counters', @next = 1, @countername = N'OrderTracking'
SELECT next, countername FROM counters WHERE countername = 'OrderTracking'
				

CAUSE

SaveAsOrder is implementing the counter saving operations. The SQL Server routine has the command that results in a timeout and then an attempt to insert a row that already exists. SQL Server returns the error as a result.

RESOLUTION

To resolve this contention issue, do one of the following:
  1. Set DTCTimeout to be less than CommandTimeout. In this way a Microsoft Distributed Transaction Coordinator (DTC) timeout may occur and be handled instead of the silent lock-timeout in which the SQL Server processing fails. Verify that the following setting (default) is set:
    1. Open Administrative Tools.
    2. For IIS, click Component Services.
    3. COM+ Packages.
    4. Click Local Computer.
    5. Click Properties.
    6. Click the Options tab.
    7. Specify 60 (seconds) for the DTC timeout.
  2. Configure the site code for each site to use a unique counter. To do this, explicitly set OrderGroup.OrderTrackingNumber in the site code and use a different counter name for each Web site. This will reduce the lock contention and thereby resolve this problem. For example, use the following sample code as a basis for modifying the Include\Payment.asp code:
    If IsNull(mscsOrderGrp.Value("order_number")) 
        set objGenID = Server.CreateObject("Commerce.GenID")
        mscsOrderGrp.Value("order_number") = objGenID.GetCounterValue("OrderTracking<SiteName/Number>", 0) 
    End If
    mscsOrderGrp.SaveAsOrder()
    					
  3. Use dedicated transaction databases for each site. To do this, divide the one transaction database into multiple transaction databases. You can create one database for each site. When you do this, each site does not share resources, which helps to stop the contention of the OrderTracking SQL Server row that is used for the counter.

STATUS

Microsoft has confirmed that this is a problem in Microsoft Commerce Server 2002.

MORE INFORMATION

The GenID object is used to create and maintain global sequential counters that are persisted in the database. The OrderGroup component uses GenID to generate a unique order ID when you call SaveAsOrder. The GenID component performs an insert in the Counters table in the transactions database when an existing row for a particular counter name is not found. If a row for that counter name ("OrderTracking" by default) already exists, an update occurs.

Modification Type:MajorLast Reviewed:10/30/2002
Keywords:kbbug kbCommServ2000preSP2fix kbCommServ2000SP2fix KB320781