I have some problem with the following statement, does anyone have any idea??
Any comments are appreciated!!
UPDATE tableTx
SET tableTx.ResultCode = 0
WHERE tableTx.id in (SELECT tableTxInfo.id
FROM tableTxInfo
WHERE tableTxInfo.messageId = 'john-to-bob'
and tableTx.ResultCode != 1)
id
of tableTx
and tableTxInfo
is the same (it's used as the INTEGER PRIMARY KEY
)
For a new transaction, a new record will be created for both tableTx
and tableTxInfo
with the same id.
I have around 40000 records with messageId = "john-to-bob"
.
When I tries to execute the above SQL statement from two different threads, one hangs for a quite long time and the other thread just get response:
Transaction detected a deadlock, transaction is rolled back.
I am not quite familiar with SQL and database concept. Is there any way to prevent from this kind of error?
my database is IBM soliddb