-
Notifications
You must be signed in to change notification settings - Fork 368
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
LazySidekiq strategy #827
Merged
Merged
LazySidekiq strategy #827
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sl4vr
force-pushed
the
lazy_sidekiq_strategy
branch
from
December 10, 2021 15:58
6f149b1
to
6f58836
Compare
mrzasa
reviewed
Dec 13, 2021
sl4vr
force-pushed
the
lazy_sidekiq_strategy
branch
3 times, most recently
from
December 15, 2021 08:33
a77020e
to
54afc7b
Compare
sl4vr
commented
Dec 15, 2021
sl4vr
commented
Dec 15, 2021
sl4vr
force-pushed
the
lazy_sidekiq_strategy
branch
from
January 19, 2022 12:24
6f6849e
to
912eb47
Compare
Instead of spawning sidekiq jobs for every record, schedule one job in the end of strategy block and then query all records within this job and run all the callbacks using Sidekiq strategy.
sl4vr
force-pushed
the
lazy_sidekiq_strategy
branch
from
February 8, 2022 19:37
912eb47
to
561f037
Compare
sl4vr
force-pushed
the
lazy_sidekiq_strategy
branch
from
February 8, 2022 19:50
561f037
to
27193f7
Compare
Take into account different ruby versions.
sl4vr
force-pushed
the
lazy_sidekiq_strategy
branch
from
February 8, 2022 20:19
e5987c4
to
bdc9e6f
Compare
rabotyaga
approved these changes
Feb 10, 2022
mrzasa
approved these changes
Feb 18, 2022
riffraff
reviewed
Feb 18, 2022
barthez
reviewed
Feb 21, 2022
That will prevent scheduling Sidekiq strategy job from LazySidekiq job.
rabotyaga
approved these changes
Mar 4, 2022
Fix typo Co-authored-by: Ivan Rabotyaga <ivan.rabotyaga@toptal.com>
mrzasa
approved these changes
Mar 4, 2022
cyucelen
pushed a commit
to cyucelen/chewy
that referenced
this pull request
Jan 28, 2023
- Implement LazySidekiq strategy - Implement AtomicNoRefresh strategy - Add `no_refresh` chain call to `update_index` matcher Co-authored-by: Slava Mefodin <slava.mefodin@toptal.com> Co-authored-by: Bartek Bułat <bartek@toptal.com> Co-authored-by: Ivan Rabotyaga <ivan.rabotyaga@toptal.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PR implements proof of concept for new Chewy strategy. The strategy allows to avoid synchronous evaluation of index queries. Instead all the callbacks will be saved in class attribute and model type and id will be stashed into strategy instance. When strategy block ends it will enqueue
IndicesUpdateWorker
Sidekiq job with serialized stash as argument. The job will load records and run all the callbacks withinsidekiq
strategy block, which in turn will enqueue Sidekiq jobs updating indices.Since we cannot schedule
IndicesUpdateWorker
job for destroyed records, instead all the callbacks will be run synchronously and resulted index types and ids will be stashed into strategy instance and run on thelazy_sidekiq
strategy block end like if they would be run on the end ofsidekiq
strategy block.Some concerns to consider:
update_index
blocks because record will be reinstantiated on the time when callbacks will be run. We can however serializechanges
andprevious_changes
to Sidekiq jobs, or even specify what to serialize.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).