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

Deprecate definition of job priority, change to "smaller number is higher priority" to align with Active Job definition #883

Merged
merged 1 commit into from
Mar 9, 2023

Conversation

bensheldon
Copy link
Owner

Reported in #524 (comment).

Active Job describes priority as "lower is more priority".

@bensheldon bensheldon temporarily deployed to goodjob-deprecate-rever-zpaio2 March 8, 2023 16:33 Inactive
Copy link
Contributor

@segiddins segiddins left a comment

Choose a reason for hiding this comment

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

Thank you so much for the swift follow up!!

app/models/good_job/execution.rb Show resolved Hide resolved
@bensheldon bensheldon temporarily deployed to goodjob-deprecate-rever-zpaio2 March 8, 2023 18:49 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-deprecate-rever-zpaio2 March 8, 2023 18:50 Inactive
…gher priority" to align with Active Job definition.
@bensheldon bensheldon temporarily deployed to goodjob-deprecate-rever-zpaio2 March 8, 2023 22:03 Inactive
@bensheldon bensheldon marked this pull request as ready for review March 9, 2023 01:53
@bensheldon bensheldon added bug Something isn't working enhancement New feature or request labels Mar 9, 2023
@bensheldon bensheldon merged commit a81c5ff into main Mar 9, 2023
@bensheldon bensheldon deleted the deprecate_reverse_priority branch March 9, 2023 01:53
@bensheldon
Copy link
Owner Author

@zarqman
Copy link
Contributor

zarqman commented Apr 4, 2023

@bensheldon, does this also affect the index on :priority?

In an existing app (with migrations from prior to this change), I have this index:

add_index :good_jobs, [:priority, :created_at], order: { priority: "DESC NULLS LAST", created_at: :asc },

Does that need to become priority: :asc (which I believe is equivalent to ASC NULLS LAST)? Even if so, no idea how that should be handled with regard to the deprecation cycle. 😬

Apologies if this is a dupe and this was already on your radar.

coreyaus added a commit to coreyaus/good_job that referenced this pull request Jul 10, 2023
bensheldon added a commit that referenced this pull request Sep 23, 2023
* Explain how `priority` works in GoodJob (#883)

Resolves #991

* Remove section on named queues

---------

Co-authored-by: Ben Sheldon [he/him] <bensheldon@gmail.com>
mkrfowler added a commit to mkrfowler/good_job that referenced this pull request Jan 14, 2024
The preexisting index (introduced in bensheldon#726) gave a direct answer to the
materialized subquery used to find candidate jobs, subject to the ordering rules
that were in place at that time.  In bensheldon#883, `GoodJob` deprecated that ordering in
favour of a lower-is-more-important scheme, aligning with Active Job.

When there are a substantial number of completed jobs, the `priority desc` index
does not allow for a straight index scan, and may not actually be used by the
planner.  Aligning the sort orders here allows for the subquery to be satisfied
directly.
mkrfowler added a commit to mkrfowler/good_job that referenced this pull request Jan 14, 2024
The preexisting index (introduced in bensheldon#726) gave a direct answer to the
materialized subquery used to find candidate jobs, subject to the ordering rules
that were in place at that time.  In bensheldon#883, `GoodJob` deprecated that ordering in
favour of a lower-is-more-important scheme, aligning with Active Job.

When there are a substantial number of completed jobs, the `priority desc` index
does not allow for a straight index scan, and may not actually be used by the
planner.  Aligning the sort orders here allows for the subquery to be satisfied
directly.

Although `ASC NULLS LAST` is the default (as observable in the generated schema)
it seems appropriate to be explicit in the actual index declaration, although
mostly for consistency with the previous version.
mkrfowler added a commit to mkrfowler/good_job that referenced this pull request Jan 14, 2024
The preexisting index (introduced in bensheldon#726) gave a direct answer to the
materialized subquery used to find candidate jobs, subject to the ordering rules
that were in place at that time.  In bensheldon#883, `GoodJob` deprecated that ordering in
favour of a lower-is-more-important scheme, aligning with Active Job.

When there are a substantial number of completed jobs, the `priority desc` index
does not allow for a straight index scan, and may not actually be used by the
planner.  Aligning the sort orders here allows for the subquery to be satisfied
directly.

Although `ASC NULLS LAST` is the default (as observable in the generated schema)
it seems appropriate to be explicit in the actual index declaration, although
mostly for consistency with the previous version.
mkrfowler added a commit to mkrfowler/good_job that referenced this pull request Jan 14, 2024
The preexisting index (introduced in bensheldon#726) gave a direct answer to the
materialized subquery used to find candidate jobs, subject to the ordering rules
that were in place at that time.  In bensheldon#883, `GoodJob` deprecated that ordering in
favour of a lower-is-more-important scheme, aligning with Active Job.

When there are a substantial number of completed jobs, the `priority desc` index
does not allow for a straight index scan, and may not actually be used by the
planner.  Aligning the sort orders here allows for the subquery to be satisfied
directly.

Although `ASC NULLS LAST` is the default (as observable in the generated schema)
it seems appropriate to be explicit in the actual index declaration, although
mostly for consistency with the previous version.
mkrfowler added a commit to mkrfowler/good_job that referenced this pull request Jan 14, 2024
The preexisting index (introduced in bensheldon#726) gave a direct answer to the
materialized subquery used to find candidate jobs, subject to the ordering rules
that were in place at that time.  In bensheldon#883, `GoodJob` deprecated that ordering in
favour of a lower-is-more-important scheme, aligning with Active Job.

When there are a substantial number of completed jobs, the `priority desc` index
does not allow for a straight index scan, and may not actually be used by the
planner.  Aligning the sort orders here allows for the subquery to be satisfied
directly.

Although `ASC NULLS LAST` is the default (as observable in the generated schema)
it seems appropriate to be explicit in the actual index declaration, although
mostly for consistency with the previous version.
mkrfowler added a commit to mkrfowler/good_job that referenced this pull request Jan 14, 2024
The preexisting index (introduced in bensheldon#726) gave a direct answer to the
materialized subquery used to find candidate jobs, subject to the ordering rules
that were in place at that time.  In bensheldon#883, `GoodJob` deprecated that ordering in
favour of a lower-is-more-important scheme, aligning with Active Job.

When there are a substantial number of completed jobs, the `priority desc` index
does not allow for a straight index scan, and may not actually be used by the
planner.  Aligning the sort orders here allows for the subquery to be satisfied
directly.

Although `ASC NULLS LAST` is the default (as observable in the generated schema)
it seems appropriate to be explicit in the actual index declaration, although
mostly for consistency with the previous version.
bensheldon pushed a commit that referenced this pull request Jan 19, 2024
…1213)

The preexisting index (introduced in #726) gave a direct answer to the
materialized subquery used to find candidate jobs, subject to the ordering rules
that were in place at that time.  In #883, `GoodJob` deprecated that ordering in
favour of a lower-is-more-important scheme, aligning with Active Job.

When there are a substantial number of completed jobs, the `priority desc` index
does not allow for a straight index scan, and may not actually be used by the
planner.  Aligning the sort orders here allows for the subquery to be satisfied
directly.

Although `ASC NULLS LAST` is the default (as observable in the generated schema)
it seems appropriate to be explicit in the actual index declaration, although
mostly for consistency with the previous version.
francois-ferrandis added a commit to betagouv/rdv-service-public that referenced this pull request Mar 4, 2024
francois-ferrandis added a commit to betagouv/rdv-service-public that referenced this pull request Mar 4, 2024
* Update gem

* Generate and run GoodJob migrations

* Switch to Active Job's priority convention

See bensheldon/good_job#883

* FIx spec on priority

* Ignore GoodJob migrations in Rubocop

* Re-add safety_assured that was wiped when regenerating migrations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

3 participants