We have an Informix DB table used by multiple tech stacks like ESQL/C, Java (JPA), db batch updates. The below is the production issue that keeps bugging us (not often, though).
Caused by: org.hibernate.exception.GenericJDBCException: could not update:
Caused by: java.sql.SQLException: Could not do a physical-order read to fetch next row.
Caused by: java.sql.SQLException: ISAM error: record is locked.
I have removed some stacktrace for brevity.
After initial analysis, we found out ESQL/C and Java were trying to update the record at the same time. ESQL/C had locked the record JPA was trying to flush. Our JPA entity have @Version and is designed for optimistic locking.
Now, my question is, how does JPA behave when its entity is designed for optimistic locking, but the record it's trying to update is locked by an entirely different application at DB level.
- DB specifications: Page locked, NO WAIT - both default.
- JPA specification: READ_UNCOMMITTED, wait timeout - 60 sec.
My Thoughts:
- Will setting table's lock mode to WAIT solve it?
- How will this concur with the Optimistic locking set at JPA level, which are designed to never involve lock at all.