-
Couldn't load subscription status.
- Fork 38.8k
Description
In the AbstractPlatformTransactionManager.java, the logic to start new transaction is written inside the startTransaction() as below
private TransactionStatus startTransaction(TransactionDefinition definition, Object transaction,
boolean debugEnabled, @nullable SuspendedResourcesHolder suspendedResources) {
boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER);
DefaultTransactionStatus status = newTransactionStatus(
definition, transaction, true, newSynchronization, debugEnabled, suspendedResources);
doBegin(transaction, definition); //Transaction is getting built here and connection is getting acquired here based on RoutingDataSource.determineCurrentLookupKey()
prepareSynchronization(status, definition); //Transaction is getting synchronized after the connection is built
return status;
}
As you can see in the above code transaction is getting synchronized after connection is acquired. So RoutingDataSource.determineCurrentLookupKey() will not be called after prepareSynchronization(status, definition).
Will there be a fix to synchronize the transaction before the connection is getting acquired ? Or is this the default functionality?
I could not track the issue(https://jira.spring.io/browse/SPR-16876?redirect=false) in the github as it might have been lost or to be not found.
Even 6.2.x still has this behaviour.