ozeigermann 2004/02/19 09:05:39
Modified: src/stores/org/apache/slide/store/txfile/rm/impl
FileResourceManager.java
Log:
- Fixed problem with failed commits as read locks were unnecessarily upgraded to
commit locks
Revision Changes Path
1.8 +27 -21
jakarta-slide/src/stores/org/apache/slide/store/txfile/rm/impl/FileResourceManager.java
Index: FileResourceManager.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/txfile/rm/impl/FileResourceManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FileResourceManager.java 11 Feb 2004 11:30:22 -0000 1.7
+++ FileResourceManager.java 19 Feb 2004 17:05:39 -0000 1.8
@@ -652,7 +652,9 @@
logger.logFiner("Creating temporary light weight tx " + txId + " to
check for exists");
context = new TransactionContext(txId);
context.isLightWeight = true;
+ // XXX higher isolation might be needed to make sure upgrade to commit
lock always works
context.isolationLevel = ISOLATION_LEVEL_READ_COMMITTED;
+// context.isolationLevel = ISOLATION_LEVEL_REPEATABLE_READ;
globalTransactions.put(txId, context);
}
@@ -758,7 +760,9 @@
logger.logFiner("Creating temporary light weight tx " + txId + " for
reading");
TransactionContext context = new TransactionContext(txId);
context.isLightWeight = true;
+ // XXX higher isolation might be needed to make sure upgrade to commit
lock always works
context.isolationLevel = ISOLATION_LEVEL_READ_COMMITTED;
+// context.isolationLevel = ISOLATION_LEVEL_REPEATABLE_READ;
globalTransactions.put(txId, context);
}
@@ -1416,24 +1420,27 @@
public synchronized void upgradeLockToCommit() throws
ResourceManagerException {
for (Iterator it = locks.iterator(); it.hasNext();) {
GenericLock lock = (GenericLock) it.next();
- try {
- // in case of deadlocks, make failure of non-committing tx more
likely
- if (!lock
- .acquire(
- txId,
- LOCK_COMMIT,
- true,
- true,
- getDefaultTransactionTimeout() *
DEFAULT_COMMIT_TIMEOUT_FACTOR)) {
- throw new ResourceManagerException(
- "Could not upgrade to commit lock for resource at '"
- + lock.getResourceId().toString()
- + "'",
- ERR_NO_LOCK,
- txId);
+ // only upgrade if we had write access
+ if (lock.getLockLevel(txId) == LOCK_EXCLUSIVE) {
+ try {
+ // in case of deadlocks, make failure of non-committing tx
more likely
+ if (!lock
+ .acquire(
+ txId,
+ LOCK_COMMIT,
+ true,
+ true,
+ getDefaultTransactionTimeout() *
DEFAULT_COMMIT_TIMEOUT_FACTOR)) {
+ throw new ResourceManagerException(
+ "Could not upgrade to commit lock for resource at '"
+ + lock.getResourceId().toString()
+ + "'",
+ ERR_NO_LOCK,
+ txId);
+ }
+ } catch (InterruptedException e) {
+ throw new ResourceManagerSystemException(ERR_SYSTEM, txId,
e);
}
- } catch (InterruptedException e) {
- throw new ResourceManagerSystemException(ERR_SYSTEM, txId, e);
}
}
@@ -1565,7 +1572,6 @@
return is.available();
}
- // FIXED: increased concurrency and guarantee unlocking
public void close() throws IOException {
try {
is.close();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]