Job exception: UserDestroyer::PostsExistError

I’m getting this error repeatedly after a recent update:

var/www/discourse/app/services/user_destroyer.rb:18:in `destroy'
/var/www/discourse/app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:17:in `block (2 levels) in execute_onceoff'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/relation/delegation.rb:46:in `each'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/relation/delegation.rb:46:in `each'
/var/www/discourse/app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:15:in `block in execute_onceoff'
/var/www/discourse/app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:10:in `each_key'
/var/www/discourse/app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:10:in `execute_onceoff'
/var/www/discourse/app/jobs/onceoff.rb:21:in `execute'
/var/www/discourse/app/jobs/base.rb:153:in `block (2 levels) in perform'

@LeoMcA any idea what this can be?

1 Like

@Pad_Pors do you have the full traceback - including the error being raised?

nvm, I’ve figured it out - fix incoming

https://github.com/discourse/discourse/pull/5071

4 Likes

Did you manage to have a look at the state of @Pad_Pors’s DB? Otherwise, we’ll need the exact error message to be sure of what is going on.

@LeoMcA I didn’t get what I’m supposed to do. here is what I get in admin panel (but they are already there in the OP):

info:
Job exception: UserDestroyer::PostsExistError

backtrace:

/var/www/discourse/app/services/user_destroyer.rb:18:in `destroy'
/var/www/discourse/app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:17:in `block (2 levels) in execute_onceoff'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/relation/delegation.rb:46:in `each'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/relation/delegation.rb:46:in `each'
/var/www/discourse/app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:15:in `block in execute_onceoff'
/var/www/discourse/app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:10:in `each_key'
/var/www/discourse/app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:10:in `execute_onceoff'
/var/www/discourse/app/jobs/onceoff.rb:21:in `execute'
/var/www/discourse/app/jobs/base.rb:153:in `block (2 levels) in perform'

env:

application_version	[8f795b35bb18cebb01e1853ce642d78262a3af64, 42c1b7e6e0ba4f0d5c38aaa939f3a63f9751f720]
current_db	default
current_hostname	padpors.com
job	Jobs::FixPrimaryEmailsForStagedUsers
problem_db	default
	
opts	
current_site_id	default

and the image:

2 Likes

No, but I did manage to reproduce the backtrace exactly, and the exception also matches:

3 Likes

Can you provide me with the repro steps? Thank you :slight_smile:

Uuuh, sort-of. I did it using an rspec test - so repro steps would be:

git remote add LeoMcA https://github.com/LeoMcA/discourse.git
git fetch LeoMcA remove_duplicated_without_posts
git checkout LeoMcA/remove_duplicated_without_posts -- spec/jobs/fix_primary_emails_for_staged_users_spec.rb
RAILS_ENV=test bundle exec rspec spec/jobs/fix_primary_emails_for_staged_users_spec.rb

Which should produce the output:

F.

Failures:

  1) Jobs::FixPrimaryEmailsForStagedUsers should keep the duplicated staged user with posts
     Failure/Error: raise PostsExistError if !opts[:delete_posts] && user.posts.count != 0
     
     UserDestroyer::PostsExistError:
       UserDestroyer::PostsExistError
     # ./app/services/user_destroyer.rb:18:in `destroy'
     # ./app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:17:in `block (2 levels) in execute_onceoff'
     # ./app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:15:in `block in execute_onceoff'
     # ./app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:10:in `each_key'
     # ./app/jobs/onceoff/fix_primary_emails_for_staged_users.rb:10:in `execute_onceoff'
     # ./spec/jobs/fix_primary_emails_for_staged_users_spec.rb:29:in `block (3 levels) in <top (required)>'
     # ./spec/jobs/fix_primary_emails_for_staged_users_spec.rb:29:in `block (2 levels) in <top (required)>'

Finished in 2.26 seconds (files took 1.98 seconds to load)
2 examples, 1 failure

Failed examples:

rspec ./spec/jobs/fix_primary_emails_for_staged_users_spec.rb:26 # Jobs::FixPrimaryEmailsForStagedUsers should keep the duplicated staged user with posts

OK in that case, we need to transfer all existing posts on the duplicated user to the only user that we’re keeping.

1 Like

This topic was automatically closed after 31 hours. New replies are no longer allowed.