Postgres 18 fixes silent audit log corruption with new RETURNING old/new syntax
A long-standing race condition in database applications allows concurrent transactions to read the same value simultaneously, causing lost updates while the audit log falsely appears consistent. In tests simulating ten workers each withdrawing from a shared account, between four and six transactions were silently lost per run, yet the audit table showed no anomalies. PostgreSQL 18 introduces old and new row references directly within a RETURNING clause, allowing the read, write, and audit insert to occur as a single atomic statement. This eliminates the gap between reading and writing a value that competing transactions could previously exploit. The change means audit logs now reflect what a query actually overwrote, not what the application last read, making silent data corruption detectable by design.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in