r/programming • • 10d ago

PostgreSQL 19 Released!

https://www.postgresql.org/about/news/postgresql-19-released-3449/
838 Upvotes

33 comments sorted by

View all comments

Show parent comment

85

u/jmickeyd 10d ago

Unfortunately the new concurrent repack comes with a heck of a caveat:

Warning REPACK with the CONCURRENTLY option is not MVCC-safe. After the repacking transaction commits, the table will appear empty to concurrent transactions, if they are using a snapshot taken before repacking started. See Section 13.6 for more details.

48

u/IamPic 10d ago

Does it even make sense to use it then? It's hard to imagine what sort of weird bugs you can run into with such behavior.

16

u/Mognakor 10d ago

If i understand correctly the sequencing needs to be: TransactionStart -> RepackStart -> RepackEnd (-> TransactionRead) -> TransactionEnd

Sounds like it only becomes an issue when the transaction runs longer than the repack in which case either the transaction takes too long or your REPACK is very fast (which i assume implies small tables or little need for work to be done).

From the top of my head the only scenario where this becomes a concern is if you have something long running like a nightly report and someone decides to schedule a REPACK during the night.

Otherwise i'd say optimize your transactions and make sure you only run REPACK when necessary.

4

u/Freeky 10d ago

That's my reading too - it's up to you to make sure no long-running transactions might use a stale snapshot. Most transactions are probably both short, and use the default read committed isolation level which takes a fresh snapshot for each statement, so the set of scenarios where it's likely to be a problem seems fairly limited.

If you want to be completely certain, enforce a bit of downtime prior to running the REPACK - once the server is quiesced, you can kick it off, and then allow traffic again. Still a win over needing downtime for the entire duration of the operation.