Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,18 @@ protected boolean doAcquireLocks(Connection conn, List<LockDO> lockDOs) throws S
ps.setInt(8, lockDO.getStatus());
ps.addBatch();
}
return ps.executeBatch().length == lockDOs.size();
// Do not rely on executeBatch().length == size: per the JDBC spec the length is
// not guaranteed to equal the number of statements, and some drivers (e.g. Dameng/DM)
// aggregate the per-statement results, returning an array of a different length.
// Detect failure via EXECUTE_FAILED instead; real conflicts (duplicate row_key) still
// throw SQLIntegrityConstraintViolationException and are handled by the catch block below.
int[] result = ps.executeBatch();
for (int updated : result) {
if (updated == java.sql.Statement.EXECUTE_FAILED) {
return false;
}
}
Comment on lines +399 to +403
return true;
} catch (SQLIntegrityConstraintViolationException e) {
LOGGER.error("Global lock batch acquire error: {}", e.getMessage(), e);
// return false,let the caller go to conn.rollback()
Expand Down