Permalink
Browse files

rfe11310: AGConnPool should rollback when borrowing

tests-added: none
tests-run:   java-bigger-test
performance: pool will always rollback on borrow

<release-notes>
rfe11310: AGConnPool should rollback when borrowing

Pool will now always rollback when borrowing a connection.
This makes the transaction catch up to the most recent.

The 'testOnBorrow' property for the pool is now
redundant, so generally not recommended.
</release-notes>

Change-Id: I7f74a59669a1d3915ff2e02cd9b15fb7f6686995
Reviewed-on: https://gerrit.franz.com:9080/1944
Reviewed-by: Ahmon Dancy <dancy@franz.com>
Reviewed-by: John O'Rourke <jor@franz.com>
Tested-by: Kevin Layer <layer@franz.com>
  • Loading branch information...
1 parent de16c2d commit 279b54eee9d3c94501a683f2252f0a4ea47c044e Mike Hinchey committed with dklayer Feb 7, 2012
@@ -98,6 +98,9 @@ private synchronized AGRepository createRepo(AGCatalog cat) throws Exception {
}
protected void activateConnection(AGRepositoryConnection conn) throws RepositoryException {
+ // rollback to transaction will catch up to the most recent
+ conn.rollback();
+
switch (props.session) {
case SHARED:
if (!conn.isAutoCommit()) {
@@ -125,6 +128,11 @@ protected void activateConnection(AGRepositoryConnection conn) throws Repository
}
}
+ /**
+ * Calls {@link AGRepositoryConnection#rollback()} and
+ * resets {@link AGRepositoryConnection#setAutoCommit(boolean)}
+ * if it has changed.
+ */
@Override
public void activateObject(Object obj) throws Exception {
activateConnection( (AGRepositoryConnection) obj);
@@ -139,9 +147,8 @@ public void destroyObject(Object obj) throws Exception {
public void passivateObject(Object obj) throws Exception {
AGRepositoryConnection conn = (AGRepositoryConnection) obj;
if (!conn.isAutoCommit() && conn.getRepository().isWritable()) {
+ // rollback to free resources on server
conn.rollback();
- // TODO MH: any reason to do this?
- //conn.setAutoCommit(true);
}
}
@@ -44,7 +44,6 @@
* AGConnProp.session, AGConnProp.Session.DEDICATED,
* AGPoolProp.shutdownHook, true,
* AGPoolProp.maxActive, 10,
- * AGPoolProp.testOnBorrow, true,
* AGPoolProp.initialSize, 2);
* AGRepositoryConnection conn = pool.borrowConnection();
* try {
@@ -77,8 +77,11 @@
maxWait,
/**
- * Calls {@link AGRepositoryConnection#size(org.openrdf.model.Resource...)}
- * - Important, because sessions may timeout while idle in the pool.
+ * Calls {@link AGRepositoryConnection#size(org.openrdf.model.Resource...)}.
+ *
+ * Redundant because {@link AGConnFactory#activateObject(Object)}
+ * always calls {@link AGRepositoryConnection#rollback()}.
+ *
* @see GenericObjectPool#setTestOnBorrow(boolean)
* @see AGConnFactory#validateObject(Object)
*/

0 comments on commit 279b54e

Please sign in to comment.