conductor icon indicating copy to clipboard operation
conductor copied to clipboard

Optimise the postgres queries for popping messages

Open bjpirt opened this issue 1 year ago • 0 comments

Pull Request type

  • [x] Refactoring (no functional changes, no api changes)

NOTE: Please remember to run ./gradlew spotlessApply to fix any format violations.

Changes in this PR

The previous behaviour for popping messages off a queue when using Postgres was:

  • SELECT potential messages using peekMessages while locking them for update
  • Loop through those messages in Conductor and update them to pop them

This means that Postgres is holding open a transaction and lock over the course of multiple queries

The new behaviour is to do the exact same thing but in a single statement so that at worst it will half the number of queries made when popping a message and reduce the amount of time a lock is held on records.

It doesn't change the behaviour at all.

bjpirt avatar Feb 12 '24 13:02 bjpirt