Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a non-locking repository that makes use of SKIP LOCKED clause in MySQL & PostgreSQL #1853

Merged
merged 4 commits into from
Mar 28, 2025

Conversation

jakubkosinski
Copy link
Contributor

Allow to use faster non-locking repository in Outbox that is using SELECT ... FOR UPDATE SKIP LOCKED query. Such query will skip all locked rows while still returning non-locked ones if present.
This allows to stop obtaining any locks prior to fetching the next batch as we could just lock the whole batch of rows while reading them.

@jakubkosinski jakubkosinski force-pushed the outbox-non-locking-repository branch 2 times, most recently from b314e7d to 7094bda Compare March 27, 2025 08:56
Allow to process next batch of records in the repository using locking or non-locking method.
Repository should expose only 3 public methods:

- with_next_batch
- mark_as_enqueued
- delete_enqueued_older_than

Other implementation details are private. Consumer handler processing records by passing the block
to `Repository#with_next_batch` method.

Add `-l, --[no-]locking` switch to CLI to allow changing the locking method in the repository (locking is default)
@jakubkosinski jakubkosinski force-pushed the outbox-non-locking-repository branch from 7094bda to ce9a58f Compare March 27, 2025 08:57
@jakubkosinski jakubkosinski merged commit 7f49b4e into master Mar 28, 2025
23 checks passed
@jakubkosinski jakubkosinski deleted the outbox-non-locking-repository branch March 28, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant