-
Notifications
You must be signed in to change notification settings - Fork 74
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
THREESCALE-2989 - simplify background deletion #3958
base: master
Are you sure you want to change the base?
Conversation
ar_object.destroyed_by_association = DummyDestroyedByAssociationReflection.new(entry) if arguments.first != entry | ||
ar_object.background_deletion_method_call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one difference with previous logic. Previously #destroy
without !
was used when destroyed by association. But I don't see why should this be done and so far haven't observed any negative effects. I think it is correct that the job should fail/retry if the #destroy!
method failed.
payment_gateway_setting | ||
buyer_accounts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that these two are highlighted. Reading the original logic, all the reason for separate DeleteAccountHierarchyWorker
and DeletePaymentSettingHierarchyWorker
appears to be enforcing and order of executing the deletions. Since we do deleting serially here, the order is enforced by the order of entries put in background_deletion
so I removed all that and just arranged the entries like this.
I must say that I cannot definitively claim that I understood all implications of the original code. More like I vaguely understood it. I found it more important to understand the intentions of the original authors because the code was misbehaving anyways and is heavily been refactored.
Although further testing may lead to a realization of details that I missed. So don't blindly trust me!
What this PR does / why we need it:
Presently background deletion relies on Sidekiq batches which don't work well with ActiveJob. Specifically failing a job registers triggers callbacks for successful job if I remember correctly.
Moreover there was a bug that calling #delete was calling a state machine method instead of the activerecord method.
These two have the potential to cause indefinite rescheduling and multiplication of delete jobs eventually exhausting server performance and sidekiq redis memory.
With the new implementation, we only use a single ActiveRecord job, do not rely on Sidekiq batches and basically assuring order of operations, the logic can be much better understood. Runoffs are hopefully impossible but should be much easier to contain because now only the
:deletion
queue is used and stopping this queue should also freeze the problem until it can be properly debugged and fixed.Which issue(s) this PR fixes
https://issues.redhat.com/browse/THREESCALE-2989
Verification steps
DeleteObjectHierarchyWorker.delete_later(myprovider)
For upgrade
Special notes for your reviewer:
This is just an early preview to gather feedback. It is very much untested in most regards except for a simple new test.
As for review, I think you better initially ignore old code and just read the new implementation of the Worker as new code. Then see if there are areas in the old code that have not been addressed by the new code. I know it is a pain.
It remains to test compatibility, self-rescheduling, other existing users of the worker (except for the service deletion which is the only one tested atm) and who knows what else.