Skip to content

Conversation

@brandur
Copy link
Contributor

@brandur brandur commented Aug 28, 2024

Updates the Ruby client to be compatible with the fast unique insertion
added to the main River in [1] which uses a unique index instead of
advisory lock + fetch as long as uniqueness is constrained to the
default set of unique job states.

We also reorganize the driver tests such that the majority of the tests
are put in a single set of shared examples, largely so that ActiveRecord
and Sequel aren't so duplicative of each other, and so we can easily add
new tests for all drivers in one place.

Lastly, I killed the mock driver in use at the top level. Adding
anything new required all kinds of engineering around it, and I found
lots of test bugs that were the result of imperfect mocking that wasn't
fully checking the client end to end.

[1] riverqueue/river#451

Copy link
Contributor

@bgentry bgentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! While you're working on this, would you mind taking a look at bumping rexml to clear up all these dependabot & security scan alerts? https://github.com/riverqueue/riverqueue-ruby/security/dependabot

CHANGELOG.md Outdated

### Changed

- Now compatible with "fast path" unique job insertion that uses a unique index instead of advisory lock and fetch [as introduced in River #451](https://github.com/riverqueue/river/pull/451). [PR #XXX](https://github.com/riverqueue/riverqueue-ruby/pull/XXX).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Now compatible with "fast path" unique job insertion that uses a unique index instead of advisory lock and fetch [as introduced in River #451](https://github.com/riverqueue/river/pull/451). [PR #XXX](https://github.com/riverqueue/riverqueue-ruby/pull/XXX).
- Now compatible with "fast path" unique job insertion that uses a unique index instead of advisory lock and fetch [as introduced in River #451](https://github.com/riverqueue/river/pull/451). [PR #28](https://github.com/riverqueue/riverqueue-ruby/pull/28).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx! Fixed.

Comment on lines 67 to 72
# It'd be nice to specify this as `(kind, unique_key) WHERE unique_key
# IS NOT NULL` like we do elsewhere, but in its pure ingenuity, fucking
# ActiveRecord tries to look up a unique index instead of letting
# Postgres handle that, and of course it doesn't support a `WHERE`
# clause.
unique_by: "river_job_kind_unique_key_idx"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 🤦‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, felt a little hard done by the time I finally found something that worked.

@brandur brandur force-pushed the brandur-fast-unique-path branch from 5e0e9a2 to eda0e4e Compare August 31, 2024 04:25
@brandur
Copy link
Contributor Author

brandur commented Aug 31, 2024

Nice! While you're working on this, would you mind taking a look at bumping rexml to clear up all these dependabot & security scan alerts? https://github.com/riverqueue/riverqueue-ruby/security/dependabot

Yep! It's been a while since I bumped the gems in this project. Let me tackle that right after.

@brandur brandur force-pushed the brandur-fast-unique-path branch from eda0e4e to 6e75e81 Compare August 31, 2024 04:30
Updates the Ruby client to be compatible with the fast unique insertion
added to the main River in [1] which uses a unique index instead of
advisory lock + fetch as long as uniqueness is constrained to the
default set of unique job states.

We also reorganize the driver tests such that the majority of the tests
are put in a single set of shared examples, largely so that ActiveRecord
and Sequel aren't so duplicative of each other, and so we can easily add
new tests for all drivers in one place.

Lastly, I killed the mock driver in use at the top level. Adding
anything new required all kinds of engineering around it, and I found
lots of test bugs that were the result of imperfect mocking that wasn't
fully checking the client end to end.

[1] riverqueue/river#451
@brandur brandur force-pushed the brandur-fast-unique-path branch from 6e75e81 to cab6dd4 Compare August 31, 2024 04:32
@brandur brandur merged commit 621831b into master Aug 31, 2024
@brandur brandur deleted the brandur-fast-unique-path branch August 31, 2024 04:33
brandur added a commit that referenced this pull request Aug 31, 2024
Prepare v0.7.0, containing largely the changes in #28 that add support
for past path unique job insertion.
@brandur brandur mentioned this pull request Aug 31, 2024
brandur added a commit that referenced this pull request Aug 31, 2024
Prepare v0.7.0, containing largely the changes in #28 that add support
for past path unique job insertion.
brandur added a commit that referenced this pull request Feb 27, 2025
Remove a few straggler references saying that advisory locks provide
uniqueness. As of #28, this is no longer true and a unique index is used
instead.
brandur added a commit that referenced this pull request Feb 28, 2025
Remove a few straggler references saying that advisory locks provide
uniqueness. As of #28, this is no longer true and a unique index is used
instead.
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.

3 participants