Simon Willison’s Weblog

Subscribe

Saturday, 18th December 2021

Transactionally Staged Job Drains in Postgres. Any time I see people argue that relational databases shouldn’t be used to implement job queues I think of this post by Brandur from 2017. If you write to a queue before committing a transaction you run the risk of a queue consumer trying to read from the database before the new row becomes visible. If you write to the queue after the transaction there’s a risk an error might result in your message never being written. So: write to a relational staging table as part of the transaction, then have a separate process read from that table and write to the queue. # 1:34 am

2021 » December

MTWTFSS
  12345
6789101112
13141516171819
20212223242526
2728293031