db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dag.wan...@oracle.com (Dag H. Wanvik)
Subject Re: Deadlock issue
Date Fri, 13 May 2011 22:46:14 GMT
Hi,

In general, this resource may help you understand how Derby uses locks:

http://db.apache.org/derby/docs/10.8/devguide/cdevconcepts30291.html

and specifically how to debug deadlocks:

http://db.apache.org/derby/docs/10.8/devguide/cdevconcepts50894.html
http://wiki.apache.org/db-derby/LockDebugging

If you feel you understand how Derby takes locks but are seeing Derby
take locks that you feel are not appropriate for your usage and
isolation level, please let us know. If you can provide a lock table
dump, that would be helpful. Please state version of Derby are you
using, too.

Thanks,
Dag

Tim Wu <twu@terracottatech.com> writes:

> Hi All,
>
> We are facing a deadlock while putting entries to a Embedded Derby database.
>
> Some info about the way we use the derby database. We have a
> mapsdatabase, objects and transactions tables in the Derby database.
> Tables info:
> mapsdatabase = (objectid as long, key as byte[], value as byte[]) with
> (objectid, key) being the primary key
> objects = (objectid as long, value as byte[]) with (objectid) being the primary key
> transactions = (transactionid as long, value as byte[]) with
> (transactionid) being the primary key
>
> Within a Derby database transaction changes can go in each of the tables described above.
>
> However we are seeing a deadlock in the "mapsdatabase" table.
>
> I enabled the following properties to debug this issue:
> derby.locks.deadlockTrace=true
> derby.language.logStatementText=true
> derby.locks.monitor=true
>
> We get a deadlock like this:
> (XID = 496), (SESSIONID = 55), (DATABASE =
> C:\hudson\workspace\dso_check_dso2_system_trunk_JDK_1.6_-server\trunk\community\code\base\build\testrun-0001\dso-system-tests\tests.system.temp\MapClearDeadLocksSleepycatTest\objectdb\datadb),
> (DRDAID = null), Failed Statement is: UPDATE mapsdatabase SET
> derbyvalue = ?  WHERE derbykey = ? AND objectid = ?  with 3 parameters
> begin parameter #1: BLOB:Length=17 :end parameter begin parameter #2:
> VARCHAR () FOR BIT DATA:Length=9 :end parameter begin parameter #3:
> 11002 :end parameter
> ERROR 40001: A lock could not be obtained due to a deadlock, cycle of
> locks and waiters is:
> Lock : ROW, MAPSDATABASE, (1,131)
>   Waiting XID : {496, X} , APP, UPDATE mapsdatabase SET derbyvalue = ?
> WHERE derbykey = ? AND objectid = ?
>   Granted XID : {495, X} 
> Lock : ROW, MAPSDATABASE, (1,130)
>   Waiting XID : {495, X} , APP, DELETE FROM mapsdatabase WHERE objectid = ?
>   Granted XID : {496, X} 
>
>
> The log statements for XIDs 495 and 496 are:
> (XID = 495), (SESSIONID = 51), (DATABASE =
> C:\hudson\workspace\dso_check_dso2_system_trunk_JDK_1.6_-server\trunk\community\code\base\build\testrun-0001\dso-system-tests\tests.system.temp\MapClearDeadLocksSleepycatTest\objectdb\datadb),
> (DRDAID = null), Executing prepared statement: INSERT INTO
> transactions VALUES (?, ?) :End prepared statement with 2 parameters
> begin parameter #1: 30 :end parameter begin parameter #2:
> BLOB:Length=17 :end parameter
> (XID = 495), (SESSIONID = 51), (DATABASE =
> C:\hudson\workspace\dso_check_dso2_system_trunk_JDK_1.6_-server\trunk\community\code\base\build\testrun-0001\dso-system-tests\tests.system.temp\MapClearDeadLocksSleepycatTest\objectdb\datadb),
> (DRDAID = null), Executing prepared statement: UPDATE objects SET
> derbyvalue = ?  WHERE derbykey = ? :End prepared statement with 2
> parameters begin parameter #1: BLOB:Length=25 :end parameter begin
> parameter #2: 11000 :end parameter
> (XID = 495), (SESSIONID = 51), (DATABASE =
> C:\hudson\workspace\dso_check_dso2_system_trunk_JDK_1.6_-server\trunk\community\code\base\build\testrun-0001\dso-system-tests\tests.system.temp\MapClearDeadLocksSleepycatTest\objectdb\datadb),
> (DRDAID = null), Executing prepared statement: DELETE FROM
> mapsdatabase WHERE objectid = ? :End prepared statement with 1
> parameters begin parameter #1: 11000 :end parameter
>
> (XID = 496), (SESSIONID = 55), (DATABASE =
> C:\hudson\workspace\dso_check_dso2_system_trunk_JDK_1.6_-server\trunk\community\code\base\build\testrun-0001\dso-system-tests\tests.system.temp\MapClearDeadLocksSleepycatTest\objectdb\datadb),
> (DRDAID = null), Executing prepared statement: INSERT INTO
> transactions VALUES (?, ?) :End prepared statement with 2 parameters
> begin parameter #1: 29 :end parameter begin parameter #2:
> BLOB:Length=17 :end parameter
> (XID = 496), (SESSIONID = 55), (DATABASE =
> C:\hudson\workspace\dso_check_dso2_system_trunk_JDK_1.6_-server\trunk\community\code\base\build\testrun-0001\dso-system-tests\tests.system.temp\MapClearDeadLocksSleepycatTest\objectdb\datadb),
> (DRDAID = null), Executing prepared statement: INSERT INTO
> transactions VALUES (?, ?) :End prepared statement with 2 parameters
> begin parameter #1: 32 :end parameter begin parameter #2:
> BLOB:Length=17 :end parameter
> (XID = 496), (SESSIONID = 55), (DATABASE =
> C:\hudson\workspace\dso_check_dso2_system_trunk_JDK_1.6_-server\trunk\community\code\base\build\testrun-0001\dso-system-tests\tests.system.temp\MapClearDeadLocksSleepycatTest\objectdb\datadb),
> (DRDAID = null), Executing prepared statement: UPDATE objects SET
> derbyvalue = ?  WHERE derbykey = ? :End prepared statement with 2
> parameters begin parameter #1: BLOB:Length=25 :end parameter begin
> parameter #2: 11002 :end parameter
> (XID = 496), (SESSIONID = 55), (DATABASE =
> C:\hudson\workspace\dso_check_dso2_system_trunk_JDK_1.6_-server\trunk\community\code\base\build\testrun-0001\dso-system-tests\tests.system.temp\MapClearDeadLocksSleepycatTest\objectdb\datadb),
> (DRDAID = null), Executing prepared statement: UPDATE mapsdatabase SET
> derbyvalue = ?  WHERE derbykey = ? AND objectid = ?  :End prepared
> statement with 3 parameters begin parameter #1: BLOB:Length=18 :end
> parameter begin parameter #2: VARCHAR () FOR BIT DATA:Length=9 :end
> parameter begin parameter #3: 11002 :end parameter
> (XID = 496), (SESSIONID = 55), (DATABASE =
> C:\hudson\workspace\dso_check_dso2_system_trunk_JDK_1.6_-server\trunk\community\code\base\build\testrun-0001\dso-system-tests\tests.system.temp\MapClearDeadLocksSleepycatTest\objectdb\datadb),
> (DRDAID = null), Executing prepared statement: UPDATE mapsdatabase SET
> derbyvalue = ?  WHERE derbykey = ? AND objectid = ?  :End prepared
> statement with 3 parameters begin parameter #1: BLOB:Length=17 :end
> parameter begin parameter #2: VARCHAR () FOR BIT DATA:Length=9 :end
> parameter begin parameter #3: 11002 :end parameter
> Thu May 12 04:50:39 PDT 2011 Thread[WorkerThread(commit_changes_stage,
> 2, 0),5,TC Thread Group] (XID = 496), (SESSIONID = 55), (DATABASE =
> C:\hudson\workspace\dso_check_dso2_system_trunk_JDK_1.6_-server\trunk\community\code\base\build\testrun-0001\dso-system-tests\tests.system.temp\MapClearDeadLocksSleepycatTest\objectdb\datadb),
> (DRDAID = null), Cleanup action starting
>
>
> Anyone has any clues?
>
> Thanks in advance,

Mime
View raw message