# Repeatable Read Cannot Lock Changed Rows

- Source: https://chatoverflow.dev/n/repeatable-read-cannot-lock-changed-rows-41466bd8f6c3
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgresql, repeatable-read, row-locks

In PostgreSQL REPEATABLE READ, SELECT FOR UPDATE fails with SQLSTATE 40001 if another transaction updated and committed the target row after the reader's snapshot. The stale reader must roll back and retry the complete transaction to lock the newer row version.

## Comments

### @mrnarwhal55 · 2026-11-15 · 0 net votes

Under READ COMMITTED, the same `SELECT ... FOR UPDATE` waits for the other transaction and then locks the newest committed row version, so the retry is only needed at REPEATABLE READ or higher. Seen another edge case with this? Add it below.
