You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by oz...@apache.org on 2004/01/06 15:56:02 UTC
cvs commit: jakarta-slide/src/stores/org/apache/slide/store/txfile XMLResourceDescriptor.java AbstractTxFileStoreService.java TxFileContentStore.java
ozeigermann 2004/01/06 06:56:02
Modified: src/stores/org/apache/slide/store/txfile
XMLResourceDescriptor.java
AbstractTxFileStoreService.java
TxFileContentStore.java
Log:
Refactored tx file store to throw nested ConflictException upon deadlock.
This way deadlocks can be resolved with response code "Conflict" passing
multi user tests copyDisjoint and copySame.
Revision Changes Path
1.5 +7 -7 jakarta-slide/src/stores/org/apache/slide/store/txfile/XMLResourceDescriptor.java
Index: XMLResourceDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/txfile/XMLResourceDescriptor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XMLResourceDescriptor.java 14 Nov 2003 16:25:06 -0000 1.4
+++ XMLResourceDescriptor.java 6 Jan 2004 14:56:02 -0000 1.5
@@ -174,7 +174,7 @@
if (e.getStatus() == ResourceManagerException.ERR_NO_SUCH_RESOURCE) {
throw new ObjectNotFoundException(uri);
} else {
- store.throwInternalError(e);
+ store.throwInternalError(e, uri);
}
} finally {
try {
@@ -204,7 +204,7 @@
if (e.getStatus() == ResourceManagerException.ERR_RESOURCE_EXISTS) {
throw new ObjectAlreadyExistsException(uri.toString());
} else {
- store.throwInternalError(e);
+ store.throwInternalError(e, uri);
}
}
}
@@ -227,7 +227,7 @@
if (e.getStatus() == ResourceManagerException.ERR_NO_SUCH_RESOURCE) {
throw new ObjectNotFoundException(uri.toString());
} else {
- store.throwInternalError(e);
+ store.throwInternalError(e, uri);
}
}
}
@@ -263,7 +263,7 @@
if (e.getStatus() == ResourceManagerException.ERR_NO_SUCH_RESOURCE) {
throw new ObjectNotFoundException(uri);
} else {
- store.throwInternalError(e);
+ store.throwInternalError(e, uri);
}
} finally {
try {
1.7 +29 -5 jakarta-slide/src/stores/org/apache/slide/store/txfile/AbstractTxFileStoreService.java
Index: AbstractTxFileStoreService.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/txfile/AbstractTxFileStoreService.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractTxFileStoreService.java 26 Nov 2003 11:13:59 -0000 1.6
+++ AbstractTxFileStoreService.java 6 Jan 2004 14:56:02 -0000 1.7
@@ -64,6 +64,7 @@
package org.apache.slide.store.txfile;
import org.apache.slide.common.*;
+import org.apache.slide.macro.ConflictException;
import org.apache.slide.store.txfile.rm.ResourceManager;
import org.apache.slide.store.txfile.rm.ResourceManagerException;
@@ -378,10 +379,33 @@
}
+ public synchronized void throwInternalError(Throwable cause) throws ServiceAccessException {
+ Object txId = getActiveTxId();
+
+ getLogger().log(
+ "Thread "
+ + Thread.currentThread()
+ + " marked transaction branch "
+ + txId
+ + " for rollback. Cause: "
+ + cause,
+ LOG_CHANNEL,
+ Logger.WARNING);
+
+ try {
+ rm.markTransactionForRollback(txId);
+ } catch (ResourceManagerException re) {
+ throw new ServiceAccessException(this, re);
+ }
+
+ throw new ServiceAccessException(this, cause);
+
+ }
+
// TODO if error is caused by lock that could not be acquired
// we should try deadlock detection instead of simply rolling back
// if no deadlock is detected, retrying for lock would be preferred method
- public synchronized void throwInternalError(Throwable cause) throws ServiceAccessException {
+ public synchronized void throwInternalError(Throwable cause, String uri) throws ServiceAccessException {
Object txId = getActiveTxId();
if ((cause instanceof ResourceManagerException)
@@ -404,7 +428,7 @@
LOG_CHANNEL,
Logger.INFO);
- throw new ServiceAccessException(this, "deadlock victim");
+ throw new ServiceAccessException(this, new ConflictException(uri));
} else {
1.4 +9 -9 jakarta-slide/src/stores/org/apache/slide/store/txfile/TxFileContentStore.java
Index: TxFileContentStore.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/txfile/TxFileContentStore.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TxFileContentStore.java 14 Nov 2003 13:11:25 -0000 1.3
+++ TxFileContentStore.java 6 Jan 2004 14:56:02 -0000 1.4
@@ -105,7 +105,7 @@
if (e.getStatus() == ResourceManagerException.ERR_NO_SUCH_RESOURCE) {
throw new RevisionNotFoundException(uri.toString(), revisionDescriptor.getRevisionNumber());
} else {
- throwInternalError(e);
+ throwInternalError(e, uri.toString());
return null; // XXX fake (is never called)
}
}
@@ -123,12 +123,12 @@
storeRevisionContent(uri, revisionDescriptor, revisionContent);
} catch (RevisionNotFoundException e) {
// Can not be, as we just created it. If it unexpectedly is, this is fatal
- throwInternalError(e);
+ throwInternalError(e, uri.toString());
} catch (ResourceManagerException e) {
if (e.getStatus() == ResourceManagerException.ERR_RESOURCE_EXISTS) {
throw new RevisionAlreadyExistException(uri.toString(), revisionDescriptor.getRevisionNumber());
} else {
- throwInternalError(e);
+ throwInternalError(e, uri.toString());
}
}
}
@@ -157,12 +157,12 @@
}
}
} catch (IOException e) {
- throwInternalError(e);
+ throwInternalError(e, uri.toString());
} catch (ResourceManagerException e) {
if (e.getStatus() == ResourceManagerException.ERR_NO_SUCH_RESOURCE) {
throw new RevisionNotFoundException(uri.toString(), revisionDescriptor.getRevisionNumber());
} else {
- throwInternalError(e);
+ throwInternalError(e, uri.toString());
}
} finally {
try {
@@ -186,7 +186,7 @@
try {
rm.deleteResource(getActiveTxId(), revisionUri);
} catch (ResourceManagerException e) {
- throwInternalError(e);
+ throwInternalError(e, uri.toString());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org