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

remove deprecated advisory lock uniqueness, consolidate insert logic #614

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

bgentry
Copy link
Contributor

@bgentry bgentry commented Sep 24, 2024

This removes the original unique jobs implementation in its entirety. It was already deprecated in the previous release.

🗒️ I'm not quite ready to merge this yet (I'd like to get the Ruby + Python clients to ship the new unique jobs changes first) but I still wanted to prepare it while the context is fresh. It's also needed to simplify some upcoming Pro changes.

All known use cases are better supported with the new unique jobs implementation which is also dramatically faster and supports batch insertion.

As part of this change, single insertions now inherit the behavior of batch insertions as far as always setting a scheduled_at time in the job args prior to hitting the database. This is due to the difficulty of trying to pass an array of nullable timestamps for scheduled_at to the database using sqlc. One side effect of this is that some tests needed to be updated because they run in a transaction, which locks in a particular now() time used in JobGetAvailble by default. Jobs inserted after the start of that transaction would pick up a scheduled timestamp from Go code that is later than the database transaction's timestamp, and so those jobs would never run. This was fixed in some cases by allowing now to be overridden by lower level callers of that query, whereas other tests were updated to simply insert jobs with a past scheduled_at to ensure their visibility.

TODO

  • Changelog entry

Currently based on #613.

Base automatically changed from bg-mod-tidy to master September 24, 2024 21:02
@bgentry bgentry force-pushed the bg-remove-advisory-lock-unique-jobs branch 2 times, most recently from 9184e75 to 2b5eff2 Compare September 26, 2024 21:49
@bgentry bgentry force-pushed the bg-remove-advisory-lock-unique-jobs branch 2 times, most recently from 95d5825 to 6264e3f Compare September 30, 2024 22:58
@bgentry bgentry marked this pull request as ready for review October 1, 2024 01:16
This removes the original unique jobs implementation in its entirety. It
was already deprecated in the previous release.

All known use cases are better supported with the new unique jobs
implementation which is also dramatically faster and supports batch
insertion.

As part of this change, single insertions now inherit the behavior of
batch insertions as far as always setting a `scheduled_at` time in the
job args prior to hitting the database. This is due to the difficulty of
trying to pass an array of nullable timestamps for `scheduled_at` to the
database using sqlc. One side effect of this is that some tests needed
to be updated because they run in a transaction, which locks in a
particular `now()` time used in `JobGetAvailble` by default. Jobs
inserted _after_ the start of that transaction would pick up a scheduled
timestamp from Go code that is _later_ than the database transaction's
timestamp, and so those jobs would never run. This was fixed in some
cases by allowing `now` to be overridden by lower level callers of that
query, whereas other tests were updated to simply insert jobs with a
past `scheduled_at` to ensure their visibility.
@bgentry bgentry force-pushed the bg-remove-advisory-lock-unique-jobs branch from 6264e3f to 182dfb4 Compare October 4, 2024 00:53
@bgentry
Copy link
Contributor Author

bgentry commented Oct 4, 2024

I haven't yet found the time to get the Ruby and Python clients upgraded to support this newer unique jobs path and remove the advisory lock path. However with all the stuff in flight and the much smaller user base of those libraries, I don't think I can justify holding up these other improvements any longer.

I'm going to go ahead and ship this and #627 in order to move forward on #584 and the other stuff that's blocked on them.

@bgentry bgentry merged commit 0aa276d into master Oct 4, 2024
14 checks passed
@bgentry bgentry deleted the bg-remove-advisory-lock-unique-jobs branch October 4, 2024 01:03
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