[
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-af-askToRaiseSelfDeadlock.diff
None of us are getting Apache email right now, so I missed your latest
comments, too. I am attaching a new rev of the patch. You can evaluate whether
you think this version is better or worse than the previous rev.
The new rev adds an extra argument to lockObject() so that callers can request
how they want SelfDeadlock to be handled:
1) Callers can ask that a SelfDeadlock exception be thrown. This option is
useful when callers need to distinguish the SelfDeadlock situation from other
situations in which a nested subtransaction can't get a lock immediately.
2) Callers can ask for the existing behavior prior to the work on this issue.
That is, lockObject() returns null if a lock can't be grabbed immediately and
does not distinguish between SelfDeadlock and being blocked by another
Connection's work.
Attaching derby-6554-02-af-askToRaiseSelfDeadlock.diff. I am running tests.
It became clear from the previous revs of this patch that there are many places
where Derby attempts to do work in a nested sub-transa tion, hoping to get a
lock immediately. The new code affected too many old code paths. And by the
time we got to lockObject(), there was not enough context in the call arguments
to let us isolate the SequenceUpdater case.
So I am experimenting with a solution in which the caller has to explicitly
request a SelfDeadlock exception when a nested subtransaction is blocked by its
parent and it can't grab a lock immediately.
This new patch adds a new argument to LockFactory.lockObject():
raiseSelfDeadlock. When this argument is set to true, lockObject() raises a
SelfDeadlock exception. Otherwise, lockObject() behaves the way it did before
this patch. The only code path which sets raiseSelfDeadlock is the code path
starting with SequenceUpdater.
There are 3 parts to this patch:
1) Adding more state to transactions so that we can detect the self-deadlock
between a nested subtransaction and its parent. This logic was in the previous
revs of the patch.
2) Adding the new raiseSelfDeadlock argument to LockFactory.lockObject(). These
changes are new to this patch.
3) Adjusting SequenceUpdater so that it escalates locks into the parent
transaction when it detects a SelfDeadlock.
Touches the following files:
---------------------
M java/engine/org/apache/derby/iapi/services/locks/LockOwner.java
M java/engine/org/apache/derby/iapi/error/StandardException.java
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/impl/services/reflect/UpdateLoader.java
M java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
M java/engine/org/apache/derby/impl/services/locks/LockControl.java
M java/engine/org/apache/derby/impl/store/access/RAMTransaction.java
M java/engine/org/apache/derby/impl/store/raw/xact/Xact.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
M java/engine/org/apache/derby/loc/messages.xml
M java/shared/org/apache/derby/shared/common/reference/SQLState.java
Changes for 1). Machinery to detect a self-deadlock between a subtransaction
and its parent transaction. These changes were in the previous rev of the patch.
---------------------
M java/engine/org/apache/derby/iapi/services/locks/LockFactory.java
M java/engine/org/apache/derby/impl/services/locks/LockTable.java
M java/engine/org/apache/derby/impl/services/locks/AbstractPool.java
M java/engine/org/apache/derby/impl/store/access/PropertyConglomerate.java
M java/engine/org/apache/derby/iapi/store/raw/LockingPolicy.java
M java/engine/org/apache/derby/impl/store/raw/xact/RowLocking2.java
M java/engine/org/apache/derby/impl/store/raw/xact/RowLocking3.java
M java/engine/org/apache/derby/impl/store/raw/xact/ContainerLocking2.java
M java/engine/org/apache/derby/impl/store/raw/xact/ContainerLocking3.java
M java/engine/org/apache/derby/impl/store/raw/xact/NoLocking.java
M
java/engine/org/apache/derby/iapi/store/access/ConglomerateController.java
M
java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerateController.java
M
java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerate.java
M
java/engine/org/apache/derby/impl/store/access/conglomerate/GenericScanController.java
M
java/engine/org/apache/derby/impl/store/access/btree/BTreeController.java
M java/engine/org/apache/derby/impl/store/access/heap/HeapController.java
M java/engine/org/apache/derby/impl/store/raw/data/BasePage.java
M java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java
M java/engine/org/apache/derby/impl/store/raw/data/ReclaimSpaceHelper.java
M
java/engine/org/apache/derby/impl/store/raw/data/LogicalPageOperation.java
M java/testing/org/apache/derbyTesting/unitTests/services/T_User.java
M
java/testing/org/apache/derbyTesting/unitTests/services/T_LockFactory.java
M
java/testing/org/apache/derbyTesting/unitTests/store/T_AccessFactory.java
M
java/testing/org/apache/derbyTesting/unitTests/store/T_RawStoreFactory.java
Changes for 2). New raiseSelfDeadlock argument for lockObject(). This includes
changes to the conglomerate interfaces so that raiseSelfDeadlock behavior can
be requested when opening conglomerates and fetching rows. These changes are
new to this patch.
---------------------
M java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
M java/engine/org/apache/derby/impl/sql/catalog/SequenceUpdater.java
Request raiseSelfDeadlock behavior when updating rows in SYS.SYSSEQUENCES. The
DataDictionaryImpl change is what's new to this patch.
---------------------
M
java/testing/org/apache/derbyTesting/functionTests/tests/lang/SequenceTest.java
Test the fix to this bug. This test case was in the previous rev of the patch.
> 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, D6554_2.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, derby-6554-02-ab-selfDeadlock.diff,
> derby-6554-02-ac-selfDeadlock.diff,
> derby-6554-02-ae-selfDeadlock_sps_compress.diff,
> derby-6554-02-af-askToRaiseSelfDeadlock.diff,
> derby-6554-02-ag-raiseSelfDeadlockAlways.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)