The transactions should start by locking the table rather than by locking it after they have done a select.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных