You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by mi...@apache.org on 2014/10/31 17:14:02 UTC
svn commit: r1635803 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/store/raw/data/UpdateOperation.java
testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Derby5165Test.java
Author: mikem
Date: Fri Oct 31 16:14:02 2014
New Revision: 1635803
URL: http://svn.apache.org/r1635803
Log:
DERBY-5165
Update code to reclaim locks on prepared but not committed XA transaction
update locks on recovery reboot following crash. Enable checked in test
that demonstrated the bug, which was verified to fail before the change
and pass after the change.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/UpdateOperation.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Derby5165Test.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/UpdateOperation.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/UpdateOperation.java?rev=1635803&r1=1635802&r2=1635803&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/UpdateOperation.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/UpdateOperation.java Fri Oct 31 16:14:02 2014
@@ -29,6 +29,8 @@ import org.apache.derby.iapi.services.io
import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.store.raw.ContainerHandle;
+import org.apache.derby.iapi.store.raw.LockingPolicy;
import org.apache.derby.iapi.store.raw.Page;
import org.apache.derby.iapi.store.raw.RecordHandle;
import org.apache.derby.iapi.store.raw.Transaction;
@@ -320,6 +322,76 @@ public final class UpdateOperation exten
undoMe(xact, undoPage, CLRInstant, in);
}
+ /**
+ * return RecordHandle of the update row.
+ * <p>
+ * Return the RecordHandle that should be locked when updating the
+ * row in this UpdateOperation.
+ * <p>
+ **/
+ private RecordHandle getRecordHandle()
+ {
+ return new RecordId(getPageId(), recordId);
+ }
+
+ /**************************************************************************
+ * Public Methods of RePreparable Interface:
+ **************************************************************************
+ */
+
+ /**
+ * reclaim locks associated with the changes in this log record.
+ * <p>
+ * @param locking_policy The locking policy to use to claim the locks.
+ *
+ *
+ * @exception StandardException Standard exception policy.
+ **/
+ public void reclaimPrepareLocks(
+ Transaction t,
+ LockingPolicy locking_policy)
+ throws StandardException
+ {
+ if (SanityManager.DEBUG)
+ {
+ SanityManager.DEBUG_PRINT(
+ "", "UpdateOperation.reclaimPrepareLocks().");
+
+ SanityManager.ASSERT(getRecordHandle() != null);
+ }
+
+ ContainerHandle ch = t.openContainer(
+ getPageId().getContainerId(), locking_policy,
+ (ContainerHandle.MODE_FORUPDATE |
+ ContainerHandle.MODE_OPEN_FOR_LOCK_ONLY |
+ ContainerHandle.MODE_LOCK_NOWAIT));
+
+ if (SanityManager.DEBUG)
+ {
+ SanityManager.ASSERT(ch != null);
+ }
+
+ if (ch != null)
+ ch.close();
+
+ // get the row lock on the updated row.
+ boolean lock_granted =
+ locking_policy.lockRecordForWrite(
+ t,
+ getRecordHandle(),
+ false, // default is not for insert.
+ false); // don't wait for the lock, it is bug if a
+ // lock has to wait while reclaiming locks
+ // during recovery.
+
+ releaseResource(t);
+
+ if (SanityManager.DEBUG)
+ {
+ SanityManager.ASSERT(lock_granted);
+ }
+ }
+
public String toString()
{
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Derby5165Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Derby5165Test.java?rev=1635803&r1=1635802&r2=1635803&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Derby5165Test.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Derby5165Test.java Fri Oct 31 16:14:02 2014
@@ -72,7 +72,7 @@ public class Derby5165Test extends BaseJ
"Derby5165Test cannot run without XA support");
}
- public void xtestXAUpdateLockKeptPastDBRestart()
+ public void testXAUpdateLockKeptPastDBRestart()
throws InterruptedException, SQLException, XAException {
if (usingDerbyNetClient())
return;
@@ -214,7 +214,7 @@ public class Derby5165Test extends BaseJ
xac.close();
}
- public void xtestXAUpdateLockKeptPastCrashedDBRestart() throws Exception
+ public void testXAUpdateLockKeptPastCrashedDBRestart() throws Exception
{
// call a forked process - this one will do something,
// then *not* shutdown, but not doing anything else either,