Skip to content

Transactions should be committed before restoring the transaction isolation level in restoreOriginalAtributes #1364

@YHaoNan

Description

@YHaoNan

Quartz Version: 2.3.2
Database Version: KingbaseES V009R001C001B0030 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit (Based PGSql)

java.sql.Connection.setTransactionIsolation documentation says:

Note: If this method is called during a transaction, the result is implementation-defined.

In AttributeRestoringConnectionInvocationHandler, you call setTransactionIsolation before you commit / rollback the transaction. So the result is non-determined.

/**
 * Attempts to restore the auto commit and transaction isolation connection
 * attributes of the wrapped connection to their original values (if they
 * were overwritten).
 */
public void restoreOriginalAtributes() {
    try {
        if (overwroteOriginalAutoCommitValue) {
            conn.setAutoCommit(originalAutoCommitValue);
        }
    } catch (Throwable t) {
        getLog().warn("Failed restore connection's original auto commit setting.", t);
    }
    
    try {    
        if (overwroteOriginalTxIsolationValue) {
            conn.setTransactionIsolation(originalTxIsolationValue);
        }
    } catch (Throwable t) {
        getLog().warn("Failed restore connection's original transaction isolation setting.", t);
    }
}

In Kingbase, following exception will raised:

com.kingbase8.util.KSQLException: Cannot change transaction isolation lev in the middle of a transaction.

RISK:

  1. Polluting connections in the shared connection pool(because failed of restore).

    But i think one (who share the same connection pool with you) can not assume anything about the connections in pool.

  2. I don't know if can cause starvation of other lock competitors(because not commit the transaction)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions