Error in post_creator.rb when using bench.rb


(Gerhard Schlager) #1

I’m trying to run bench.rb and I’m getting the following error during the benchmark while it’s creating 2000 replies.

/var/www/discourse/lib/post_creator.rb:206:in `setup_post': undefined method `posts' for nil:NilClass (NoMethodError)
from /var/www/discourse/lib/post_creator.rb:70:in `block in create'
from /var/www/discourse/lib/distributed_mutex.rb:21:in `synchronize'
from /var/www/discourse/lib/distributed_mutex.rb:5:in `synchronize'
from /var/www/discourse/lib/post_creator.rb:135:in `block in transaction'
from /var/www/discourse/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
from /var/www/discourse/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
from /var/www/discourse/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
from /var/www/discourse/bundle/ruby/2.1.0/gems/activerecord-4.1.4/lib/active_record/transactions.rb:208:in `transaction'
from /var/www/discourse/lib/post_creator.rb:129:in `transaction'
from /var/www/discourse/lib/post_creator.rb:68:in `create'
from /var/www/discourse/lib/post_creator.rb:102:in `create'
from script/profile_db_generator.rb:107:in `block in <main>'
from script/profile_db_generator.rb:105:in `times'
from script/profile_db_generator.rb:105:in `<main>'

(Sam Saffron) #2

Is this reproducible, does it fail on the first post ?


(Gerhard Schlager) #3

Yes, the error is reproducible. It always happens after 10%.

creating 2000 replies
........../var/www/discourse/lib/post_creator.rb:206:in `setup_post': undefined method `posts' for nil:NilClass (NoMethodError)

I’m new to Ruby, so I’m not sure how to debug that yet. However, you can try it out in the Docker container I’ve created. I sent you a pull request for it.

https://github.com/discourse/discourse_docker/pull/81


(Sam Saffron) #4

This is now fixed, SORRY it took so long


(Sam Saffron) #5