Reposted by Vlad Mihalcea
SELECT ... FOR UPDATE statements lock the rows you're querying
If another process has these locked it must wait
To get an instant error instead, use:
SELECT ... FOR UPDATE NOWAIT
@vladmihalcea.bsky.social shows how do this with JPA and Hibernate
buff.ly
The best way to use SQL NOWAIT - Vlad Mihalcea
Learn what is the best way to use the amazing SQL NOWAIT feature that allows us to avoid blocking when acquiring a row-level lock.