Hi Everyone,
I am running one batch job which has following code into it,
public void processOperation(MyContract _contract)
{
#OCCRetryCount
try
{
ttsbegin;
// multiple methods being called from here
ttscommit;
}
catch (Exception::Deadlock)
{
retry;
}
catch (Exception::UpdateConflict)
{
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
}
One of the method being called from try..catch loop is as below,
while select myTable
where myTable.DocId == _docId
{
boolean isRecordMatched = //returning boolean from one custome method
if(isRecordMatched)
{
myTable.selectForUpdate(true);
myTable.IsMarked = NoYes::Yes;
myTable.CustTransRefRecId = custTrans.RecId;
myTable.CustTransOpenRefRecId = custTransOpen.RecId;
myTable.update();
}
}In above code MyTable is a custom line table & below are it's properties,
1. Cache lookup :NotInTTS
2. Table group: Worksheet Line
3. OCC enabled : Yes
and it has one index with DocId & Line number..
The above batch job runs for 2-3 hours approx. I have only included TTSBEGIN & TTSCOMMIT only in try..catch loop
However, I have one more functionality, where I click on Custom button and update the data from same MyTable using updateRecordset query but for different DocId.
And it's getting stuck over there. Even if I am trying to update data from same table for different records in SQL server directly, the query gets stuck in executing mode.
Whenever the batch job gets completed, everything works fine. updateRecordset does not get stuck & even I am able to update the data through SQL as well.
What could be the reason behind it? Why it's locking my complete table? How should I modify my code to allow parallel execution of both updates for different records?