Permalink
Browse files

fix: execute autosave/rollback savepoint via simple queries always to…

… prevent "statement S_xx not exists" when autosaving

Fixes AutoRollbackTestSuite in extendedCacheEverything mode

fixes #955
  • Loading branch information...
vlsi committed Jan 8, 2018
1 parent bb8a315 commit 684a69920e08017c74ab4194d1a77067f544a28b
@@ -67,11 +67,6 @@ cache:

matrix:
fast_finish: true
allow_failures:
- env: # REMOVE FAILURE extendedCacheEverything
- PG_VERSION=9.4
- QUERY_MODE=extendedCacheEverything
- COVERAGE=N
include:
- jdk: oraclejdk8
env: RUN_CHECKSTYLE=true
@@ -353,10 +353,10 @@ private boolean sendAutomaticSavepoint(Query query, int flags) throws IOExceptio
|| !(query instanceof SimpleQuery)
|| ((SimpleQuery) query).getFields() != null)) {
sendOneQuery(autoSaveQuery, SimpleQuery.NO_PARAMETERS, 1, 0,
updateQueryMode(QUERY_NO_RESULTS | QUERY_NO_METADATA)
QUERY_NO_RESULTS | QUERY_NO_METADATA
// PostgreSQL does not support bind, exec, simple, sync message flow,
// so we force autosavepoint to use simple if the main query is using simple
| (flags & QueryExecutor.QUERY_EXECUTE_AS_SIMPLE));
| QUERY_EXECUTE_AS_SIMPLE);
return true;
}
return false;
@@ -367,8 +367,9 @@ private void rollbackIfRequired(boolean autosave, SQLException e) throws SQLExce
&& getTransactionState() == TransactionState.FAILED
&& (getAutoSave() == AutoSave.ALWAYS || willHealOnRetry(e))) {
try {
// ROLLBACK and AUTOSAVE are executed as simple always to overcome "statement no longer exists S_xx"
execute(restoreToAutoSave, SimpleQuery.NO_PARAMETERS, new ResultHandlerDelegate(null),
1, 0, updateQueryMode(QUERY_NO_RESULTS | QUERY_NO_METADATA));
1, 0, QUERY_NO_RESULTS | QUERY_NO_METADATA | QUERY_EXECUTE_AS_SIMPLE);
} catch (SQLException e2) {
// That's O(N), sorry
e.setNextException(e2);
@@ -31,9 +31,11 @@
import java.util.Collection;
import java.util.EnumSet;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;

@RunWith(Parameterized.class)
public class AutoRollbackTestSuite extends BaseTest4 {
private static final AtomicInteger counter = new AtomicInteger();

private enum FailMode {
/**
@@ -343,7 +345,7 @@ private void doCommit() throws SQLException {
con.setAutoCommit(false);
Statement st = con.createStatement();
st.executeUpdate(
"insert into rollbacktest(a, str) values (42, '" + System.currentTimeMillis() + "')");
"insert into rollbacktest(a, str) values (42, '" + System.currentTimeMillis() + "," + counter.getAndIncrement() + "')");
st.close();
}
con.commit();

0 comments on commit 684a699

Please sign in to comment.