BatchCompleter: batch all ops, not just completed #617
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a
JobSetStateIfRunningMany
query and corresponding driver API, with implementations for both pgxv5 anddatabase/sql
.The
BatchCompleter
was updated to use this new query and to batch all operations, not only those moving to acomplete
state. This means theAsyncCompleter
(as well as theInlineCompleter
) are both now unused and could be deleted, along with their underlying queries.The intention of this is not just to facilitate improved performance even on snoozes, retries, errors, cancellations, etc., but also to get down to a single path for completions (similar to now having a single path for insertions).
Benchmarks
These changes show a slight decrease in performance for the case of 100% completed jobs, but with the benefit of a significant improvement for a mix of jobs. With a normal workload including snoozes, cancellations, etc, we would expect this change to reduce overall contention due to fewer concurrent transactions and fewer conns active on a given database pool.
Before
After