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

AccountDeletionWorker locking up sidekiq #15379

Closed
thatcosmonaut opened this issue Dec 20, 2020 · 3 comments · Fixed by #15380
Closed

AccountDeletionWorker locking up sidekiq #15379

thatcosmonaut opened this issue Dec 20, 2020 · 3 comments · Fixed by #15380
Labels
bug Something isn't working

Comments

@thatcosmonaut
Copy link

Expected behaviour

Sidekiq should not have all workers locked up by AccountDeletionWorker running forever

Actual behaviour

Sidekiq has all workers locked up by AccountDeletionWorker running forever. There are hundreds of jobs queued all with the same parameters: 43875, {"reserve_username"=>false, "skip_activitypub"=>true}

When a worker starts this job, it gets stuck forever.

Steps to reproduce the problem

Just running the server normally.

Specifications

Note: we are running glitch-soc
Commit: ec9ec81

@thatcosmonaut thatcosmonaut added the bug Something isn't working label Dec 20, 2020
@thatcosmonaut
Copy link
Author

I dug into the rails console and got this info, maybe it will help?

irb(main):029:0> Sidekiq::Queue.new('pull').find { |j| j.item['class'] == 'AccountDeletionWorker' && j.item['args'][0] == 43875 }
=> #<Sidekiq::Job:0x000055762f1f17d8 @args=nil, @value="{\"retry\":true,\"queue\":\"pull\",\"class\":\"AccountDeletionWorker\",\"args\":[43875,{\"reserve_username\":false,\"skip_activitypub\":true}],\"jid\":\"503fe0a39624d84b475e6d5a\",\"created_at\":1608438017.8601284,\"enqueued_at\":1608443329.3542883,\"error_message\":\"Attempted to destroy a stale object: Poll.\",\"error_class\":\"ActiveRecord::StaleObjectError\",\"failed_at\":1608443282.46411,\"retry_count\":0}", @item={"retry"=>true, "queue"=>"pull", "class"=>"AccountDeletionWorker", "args"=>[43875, {"reserve_username"=>false, "skip_activitypub"=>true}], "jid"=>"503fe0a39624d84b475e6d5a", "created_at"=>1608438017.8601284, "enqueued_at"=>1608443329.3542883, "error_message"=>"Attempted to destroy a stale object: Poll.", "error_class"=>"ActiveRecord::StaleObjectError", "failed_at"=>1608443282.46411, "retry_count"=>0}, @queue="pull">

@ClearlyClaire
Copy link
Contributor

ClearlyClaire commented Dec 20, 2020

I cannot find commit ec9ec81, but this issue doesn't ring a bell, so I don't think that's something we solved recently anyway.

The DeleteAccountService seems to fail because of ActiveRecord::StaleObjectError: “Attempted to destroy a stale object: Poll.”. I will investigate how it's possible and how it could be fixed.

@ClearlyClaire
Copy link
Contributor

I couldn't find any way to reproduce it, and I can't see how anything but a very specific race condition could cause this, but does the following help?

diff --git a/app/models/poll.rb b/app/models/poll.rb
index b5deafcc2..e1ca55252 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -25,7 +25,7 @@ class Poll < ApplicationRecord
   belongs_to :account
   belongs_to :status
 
-  has_many :votes, class_name: 'PollVote', inverse_of: :poll, dependent: :destroy
+  has_many :votes, class_name: 'PollVote', inverse_of: :poll, dependent: :delete_all
 
   has_many :notifications, as: :activity, dependent: :destroy
 

More generally, I think there's a lot of stuff we can delete instead of destroying in the DeleteAccountService, this may also make account deletion faster. On the other hand, while this may be true right now, it might not be in the future…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants