Job exception: UserDestroyer::PostsExistError


(Pad Pors) #1

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'


(Sam Saffron) #2

@LeoMcA any idea what this can be?


(Leo McArdle) #3

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


(Leo McArdle) #4

nvm, I’ve figured it out - fix incoming


(Leo McArdle) #5

(Alan Tan) #6

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.


(Pad Pors) #7

@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:


(Leo McArdle) #8

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


(Alan Tan) #9

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


(Leo McArdle) #10

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

(Alan Tan) #11

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


Still getting the error: Job exception: UserDestroyer::PostsExistError
(Jeff Atwood) #12

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