Does CAPI.StartTransaction() and CAPI.EndTransaction() functions help to avoid database deadlocks, while updating table? Thanks
Eugene
While content server uses implicit transactions, the use of the transaction mechanisms in the code is essential. That being said, the CAPI.*Transaction calls are lower level calls and should not be used by solutions. I have seen code that does execute SQL without transactions, this usually leads to inconsistent data and lockup’s :-) The recommended method where possible is to use the dapiCtx or similar higher level transaction API’s such as:
Object dapiCtx = prgCtx.DSession()
if( dapiCtx.StartTrans() )
//
// Your code here
//end the transaction.
if ( ( dapiCtx.EndTrans( ok ) != TRUE ) && ok )
ok = FALSE
errMsg = “Could not end transaction”
end
else
errMsg = [LLIAPI_ERRMSG.UnableToStartTransaction_]
By using these, nesting of these blocks set up a reference count that will then issue a single transaction commit at the top level ( reference count = 0 ).
For the deadlocks there are a couple of items to check on:
<![if !supportLists]>1. <![endif]>For MSSQL, ensure the read committed snapshot is set.
<![if !supportLists]>2. <![endif]>For updates to tables where multiple changes are required that the same order of SQL is being executed. For instance this will cause a deadlockJ:
<![if !supportLists]>a. <![endif]>Table one update
<![if !supportLists]>b. <![endif]>CAPI.iniput
<![if !supportLists]>c. <![endif]>Capi.inidelete
<![if !supportLists]>d. <![endif]>Table one update
<![if !supportLists]>3. <![endif]>Use the database tracing to pinpoint the deadlocks…
Does that help?
Regards
David Templeton
OpenText Corporation
From: eLink Entry: Content Server Development Forum [mailto:development@elinkkc.opentext.com]Sent: Sunday, February 03, 2013 3:38 AMTo: eLink RecipientSubject: CAPI.StartTransaction() and CAPI.EndTransaction question
CAPI.StartTransaction() and CAPI.EndTransaction question
Posted bye.ochkurov@sibcon-soft.ru (Ochkurov, Eugene) On 02-03-2013 03:33
[To post a comment, use the normal reply function]
Forum:
Content Server Development Forum
Content Server:
Knowledge Center
Thanks, David