Move from non-locking to locking reads while processing a batch in background thread. #674
Closed
ironhide0396
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
I'm unclear on this bit. The update to Could you clarify? It sounds like something the code is specifically designed to avoid but that it's not working as intended. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, when processing backlogged or stale items, what we do is
Now in this duration between
[T1, T2)
, if there is any other node having the same Outbox configured ( quite an everyday use-case, thanks to HA), the exact same set of rows will be picked up, lastProcessedTime updated with respect to this new transaction.However, because during the actual processing we take a explicit lock (leveraging
FOR UPDATE SKIP LOCKED
), the work started by T2 will always be wasted.My proposal is to move the entire thing in a single locked transaction, something like
FOR UPDATE SKIP LOCKED
The only possible drawback I see in this is the waiting time for DB locks is increased and depends on the time it takes for the slowest consumer to process a message.
Alternative : Add a randomness to the select query so that chances of the same batch or overlapping rows picked up are greatly reduced by two nodes.
Beta Was this translation helpful? Give feedback.
All reactions