Select FOR UPDATE considered harmful in PostgreSQL(cybertec-postgresql.com)
cybertec-postgresql.com
Select FOR UPDATE considered harmful in PostgreSQL
https://www.cybertec-postgresql.com/en/select-for-update-considered-harmful-postgresql/
https://www.cybertec-postgresql.com/en/select-for-update-considered-harmful-postgresql/
This also happens when you UPDATE the same row twice within the same transaction.
https://goncalo.mendescabrita.com/blog/cross-table-lock/