Skip to content

Commit

Permalink
rfe11310: AGConnPool should rollback when borrowing
Browse files Browse the repository at this point in the history
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
Mike Hinchey authored and dklayer committed Feb 9, 2012
1 parent de16c2d commit 279b54e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/com/franz/agraph/pool/AGConnFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/com/franz/agraph/pool/AGConnPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 5 additions & 2 deletions src/com/franz/agraph/pool/AGPoolProp.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ public enum AGPoolProp {
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)
*/
Expand Down

0 comments on commit 279b54e

Please sign in to comment.