GH-8748: JDBC locks: use READ_COMMITTED isolation (#8749)
Fixes https://github.com/spring-projects/spring-integration/issues/8748 The Oracle DB throws `ORA-08177: can't serialize access for this transaction` when other transaction on the row has begun * Change the isolation for `DefaultLockRepository.acquire()` transaction to the `READ_COMMITTED` for what database automatically and silently restarts the entire SQL statement, and no error occurs. * Add `oracle` dependencies to JDBC module * Introduce `OracleContainerTest` and implement it for `OracleLockRegistryTests` **Cherry-pick to `6.1.x` & `6.0.x`**
This commit is contained in:
@@ -142,7 +142,7 @@ public class DefaultLockRepository
|
||||
|
||||
private TransactionTemplate readOnlyTransactionTemplate;
|
||||
|
||||
private TransactionTemplate serializableTransactionTemplate;
|
||||
private TransactionTemplate readCommittedTransactionTemplate;
|
||||
|
||||
private boolean checkDatabaseOnStart = true;
|
||||
|
||||
@@ -341,9 +341,9 @@ public class DefaultLockRepository
|
||||
this.readOnlyTransactionTemplate = new TransactionTemplate(this.transactionManager, transactionDefinition);
|
||||
|
||||
transactionDefinition.setReadOnly(false);
|
||||
transactionDefinition.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
|
||||
transactionDefinition.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
|
||||
|
||||
this.serializableTransactionTemplate = new TransactionTemplate(this.transactionManager, transactionDefinition);
|
||||
this.readCommittedTransactionTemplate = new TransactionTemplate(this.transactionManager, transactionDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -396,7 +396,7 @@ public class DefaultLockRepository
|
||||
@Override
|
||||
public boolean acquire(String lock) {
|
||||
Boolean result =
|
||||
this.serializableTransactionTemplate.execute(
|
||||
this.readCommittedTransactionTemplate.execute(
|
||||
transactionStatus -> {
|
||||
if (this.template.update(this.updateQuery, this.id, epochMillis(),
|
||||
this.region, lock, this.id, ttlEpochMillis()) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user