Affects: 5.2.4
Postgres driver 42.2.11 introduces this change https://github.com/pgjdbc/pgjdbc/pull/1729. Basically it makes commit fail if a JDBC command in the transaction failed. It is possibly a breaking change since code like this will start to throw an exception on transaction commit.
@org.springframework.transaction.annotation.Transactional
public void insert() {
try {
jdbcTemplate.update("insert into my_table values('test')");
} catch(DataAccessException e) {
// ignored, expected behavior
logger.info("action=error_on_insert {}", e.getMessage());
}
}
It's reproduced here https://github.com/lukas-krecan/datasource-demo
See https://github.com/pgjdbc/pgjdbc/issues/1739 for details and discussion. I do not know if Spring can do something to prevent the issue, I just wanted to give you heads-up.
Comment From: jhoeller
From a transaction semantics perspective, we are expecting such a scenario already since such a late-failing commit attempt is quite common in JTA setups. I'm afraid there isn't much we can do from a cross-version compatibility perspective, and arguably we shouldn't even try since we generally aim for aligning with the underlying resource transaction semantics. If the underlying driver decides to reject transactions with failing statements, then we expose that by design.