I wonder if the locks held in postgres are optimistic locks or what is the logic for database lock contention at the application level