You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2011/12/02 12:53:04 UTC
svn commit: r1209427 - in
/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database:
DBInterfacePostgreSQL.java Database.java
Author: kwright
Date: Fri Dec 2 11:53:03 2011
New Revision: 1209427
URL: http://svn.apache.org/viewvc?rev=1209427&view=rev
Log:
Rejigger transaction logging, as part of CONNECTORS-299.
Modified:
incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java
incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java?rev=1209427&r1=1209426&r2=1209427&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java (original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java Fri Dec 2 11:53:03 2011
@@ -1131,7 +1131,14 @@ public class DBInterfacePostgreSQL exten
protected void startATransaction()
throws ManifoldCFException
{
- executeViaThread(connection,"START TRANSACTION",null,false,0,null,null);
+ try
+ {
+ executeViaThread(connection,"START TRANSACTION",null,false,0,null,null);
+ }
+ catch (ManifoldCFException e)
+ {
+ throw reinterpretException(e);
+ }
}
/** Abstract method to commit a transaction */
@@ -1153,7 +1160,14 @@ public class DBInterfacePostgreSQL exten
protected void rollbackCurrentTransaction()
throws ManifoldCFException
{
- executeViaThread(connection,"ROLLBACK",null,false,0,null,null);
+ try
+ {
+ executeViaThread(connection,"ROLLBACK",null,false,0,null,null);
+ }
+ catch (ManifoldCFException e)
+ {
+ throw reinterpretException(e);
+ }
}
/** Abstract method for explaining a query */
Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java?rev=1209427&r1=1209426&r2=1209427&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java (original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java Fri Dec 2 11:53:03 2011
@@ -290,9 +290,11 @@ public abstract class Database
public void performCommit()
throws ManifoldCFException
{
- Logging.db.debug("Committing transaction!");
+ if (doRollback)
+ return;
if (delayedTransactionDepth == 0)
{
+ Logging.db.debug("Committing transaction!");
commitCurrentTransaction();
commitDone = true;
}
@@ -302,7 +304,6 @@ public abstract class Database
*/
public void signalRollback()
{
- Logging.db.debug("Rolling transaction back!");
doRollback = true;
}
@@ -333,14 +334,26 @@ public abstract class Database
{
// Do a rollback in the database, and blow away cached queries (cached against the
// database transaction key).
- rollbackCurrentTransaction();
+ if (!commitDone)
+ {
+ Logging.db.debug("Rolling transaction back!");
+ rollbackCurrentTransaction();
+ }
+ else
+ {
+ doRollback = false;
+ throw new ManifoldCFException("Cannot roll back an already committed transaction");
+ }
}
else
{
// Do a commit into the database, and blow away cached queries (cached against the
// database transaction key).
if (!commitDone)
+ {
+ Logging.db.debug("Committing transaction!");
commitCurrentTransaction();
+ }
}
}
catch (ManifoldCFException e)
@@ -372,8 +385,11 @@ public abstract class Database
{
cacheManager.commitTransaction(th.getTransactionID());
}
+
+ // Clear the signaling variables. This keeps them local to the transaction.
commitDone = false;
doRollback = false;
+
th = parentTransaction;
if (th == null)
{