[ 
https://issues.apache.org/jira/browse/DERBY-6554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rick Hillegas updated DERBY-6554:
---------------------------------

    Attachment: derby-6554-02-aa-selfDeadlock.diff

Attaching derby-6554-02-aa-selfDeadlock.diff. This is a first pass at fixing 
this bug by adding a new SelfDeadlock condition which is raised by the lock 
manager.

The lock manager code has been changed as follows:

1) Xact now has a field holding the TransactionId of its parent transaction. 
Usually, this field is null. However, it is non-null if the transaction was 
created by TransactionController.startNestedUserTransaction().

2) LockControl uses this new information to determine if a parent transaction 
has been granted a lock which conflicts with a nested transaction's lock 
request.

3) ConcurrentLockSet.lockObject() raises a SelfDeadlock exception if this is 
the case.

This is my first attempt to touch this part of Derby so it is likely that I 
have misunderstood something important and put this code in the wrong place. I 
would appreciate review by the experts.

I don't know if I've allocated the SelfDeadlock exception out of the correct 
block of SQLStates. Technically, it is an internal error which should never 
escape to the user and is only used to communicate this edge-case condition to 
higher levels of the engine.


Touches the following files:

----------------

M       java/engine/org/apache/derby/loc/messages.xml
M       java/shared/org/apache/derby/shared/common/reference/SQLState.java

The new SelfDeadlock exception state.

----------------

M       java/engine/org/apache/derby/iapi/store/raw/xact/TransactionFactory.java
M       java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java
M       java/engine/org/apache/derby/iapi/services/locks/LockOwner.java
M       java/engine/org/apache/derby/impl/store/raw/xact/Xact.java
M       java/engine/org/apache/derby/impl/store/access/RAMTransaction.java
M       java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java
M       java/engine/org/apache/derby/impl/store/raw/xact/InternalXact.java
M       java/engine/org/apache/derby/impl/store/raw/RawStore.java

Added a parent transaction id to transactions.

----------------

M       java/engine/org/apache/derby/impl/services/locks/LockControl.java
M       java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java

Added a method to check whether any of the conflicting locks is owned by the 
parent transaction of the transaction which wants a lock.

----------------

M       java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java

The lockObject() now raises a SelfDeadlock error if the parent of the 
requesting transaction has been granted a conflicting lock on the object.

----------------

M       java/engine/org/apache/derby/impl/sql/catalog/SequenceUpdater.java

Escalates to the parent (execution) transaction if a SelfDeadlock error is 
caught while trying to update SYS.SYSSEQUENCES in the nested transaction.

----------------

M       
java/testing/org/apache/derbyTesting/functionTests/tests/lang/SequenceTest.java

Test to verify that this bug is fixed.


> Too much contention followed by assert failure when accessing sequence in 
> transaction that created it
> -----------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-6554
>                 URL: https://issues.apache.org/jira/browse/DERBY-6554
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.9.1.0, 10.11.0.0, 10.10.2.0
>            Reporter: Knut Anders Hatlen
>         Attachments: D6554.java, 
> derby-6554-01-aa-useCreationTransaction.diff, 
> derby-6554-01-ab-useCreationTransaction.diff, 
> derby-6554-01-ac-useCreationTransaction.diff, derby-6554-01-ad-bugfixes.diff, 
> derby-6554-02-aa-selfDeadlock.diff
>
>
> {noformat}
> ij version 10.11
> ij> connect 'jdbc:derby:memory:db;create=true' as c1;
> ij> autocommit off;
> ij> create sequence seq;
> 0 rows inserted/updated/deleted
> ij> values next value for seq;
> 1          
> -----------
> ERROR X0Y84: Too much contention on sequence SEQ. This is probably caused by 
> an uncommitted scan of the SYS.SYSSEQUENCES catalog. Do not query this 
> catalog directly. Instead, use the SYSCS_UTIL.SYSCS_PEEK_AT_SEQUENCE function 
> to view the current value of a query generator.
> ij> rollback;
> ERROR 08003: No current connection.
> ij> connect 'jdbc:derby:memory:db' as c2;
> ij(C2)> autocommit off;
> ij(C2)> create sequence seq;
> 0 rows inserted/updated/deleted
> ij(C2)> values next value for seq;
> 1          
> -----------
> ERROR 38000: The exception 
> 'org.apache.derby.shared.common.sanity.AssertFailure: ASSERT FAILED Identity 
> being changed on a live cacheable. Old uuidString = 
> 0ddd00a9-0145-98ba-79df-000007d88b08' was thrown while evaluating an 
> expression.
> ERROR XJ001: Java exception: 'ASSERT FAILED Identity being changed on a live 
> cacheable. Old uuidString = 0ddd00a9-0145-98ba-79df-000007d88b08: 
> org.apache.derby.shared.common.sanity.AssertFailure'.
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to