Rebake all posts?


I’ve installed spoiler alert plugin. It works correctly. But old post doesn’t work spoiler tag.

“If you change this, you must rebake all posts with: “rake posts:rebake”.”

How can do that?

When i ./launcher enter app

rake is not installed!

I’ve 300k post. Even if I did, the process may take a long time. Is there a way to do it in a short way?

(Régis Hanol) #2

Either one of these should work

./launcher enter app
rake posts:rebake


./launcher enter app
cd /var/discourse
bundle exec rake posts:rebake

I don't understand image sizing

I applied that commands and after close terminal but it seems working now on the terminal with htop command.

bin/rake posts:rebake

But the server is high load because of that. There 300.000 post. I think it will take a long time. When this is done, spoiler tag for old post work correctly, right?

How can i cancel that rake process. Server is high cpu load because of that.

(Gerhard Schlager) #4

So, the rake task finished and put lots of rebake jobs into Sidekiq and now your server is on :fire:?

Hmm, I guess, you could stop all tasks by flushing redis. :bomb:
:warning: You may loose some other background jobs in the process!

cd /var/discourse
./launcher enter app
redis-cli flushall

After that, take a look at the following topic. It should allow you to rebake only posts that contain the spoiler tag.


I applied actions.



Anyway, bin/rake posts:rebake process still looks terminal and high cpu load continues.

(Gerhard Schlager) #6

Well, then kill the rake process.


I killed process. Server load down 5+ to 1.6 but CPU running still %70+.

How should it be rebake posts matching pattern for containing tags?

(Gerhard Schlager) #8

Try flushing redis again.

Something like rake posts:rebake_match["\[spoiler]"] should work. You’ll have to try it out yourself…
Read the post about rebaking I linked above. The documentation is really good!


This process has high cpu usage. %50,%90

postgres 9.5/main: discourse discourse [local] SELECT

What does it do?

(Ivan Rapekas) #10

Hi, I got no lightbox working on my discourse, and I resolved it by the following post. New pictures work fine. Then I’d like to apply lightbox to existent pictures and run command:

rake posts:rebake

but get an error

    # rake posts:rebake
    Rebaking post markdown for 'default'
    rake aborted!
    ArgumentError: wrong number of arguments (given 2, expected 3)
    /var/www/discourse/lib/tasks/topics.rake:1:in `print_status'
    /var/www/discourse/lib/tasks/posts.rake:95:in `block in rebake_posts'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.3/lib/active_record/relation/batches.rb:63:in `block (2 levels) in find_each'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.3/lib/active_record/relation/batches.rb:63:in `each'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.3/lib/active_record/relation/batches.rb:63:in `block in find_each'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.3/lib/active_record/relation/batches.rb:129:in `block in find_in_batches'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.3/lib/active_record/relation/batches.rb:230:in `block in in_batches'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.3/lib/active_record/relation/batches.rb:214:in `loop'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.3/lib/active_record/relation/batches.rb:214:in `in_batches'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.3/lib/active_record/relation/batches.rb:128:in `find_in_batches'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.3/lib/active_record/relation/batches.rb:62:in `find_each'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.3/lib/active_record/querying.rb:9:in `find_each'
    /var/www/discourse/lib/tasks/posts.rake:93:in `rebake_posts'
    /var/www/discourse/lib/tasks/posts.rake:80:in `block in rebake_posts_all_sites'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rails_multisite-1.1.0.rc4/lib/rails_multisite/connection_management.rb:126:in `block in each_connection'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rails_multisite-1.1.0.rc4/lib/rails_multisite/connection_management.rb:124:in `each'
    /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rails_multisite-1.1.0.rc4/lib/rails_multisite/connection_management.rb:124:in `each_connection'
    /var/www/discourse/lib/tasks/posts.rake:79:in `rebake_posts_all_sites'
    /var/www/discourse/lib/tasks/posts.rake:3:in `block in <top (required)>'
    /usr/local/bin/bundle:22:in `load'
    /usr/local/bin/bundle:22:in `<main>'
    Tasks: TOP => posts:rebake
    (See full trace by running task with --trace)

No luck with rebake_match as well… How can I fix that on 1.9.0.beta11? Does anybody have the same problem? I tried on two instances including just deployed clean discourse :confused:

(Gerhard Schlager) #11

This issue has been fixed a few days ago. Unfortunately it’s not on the beta channel yet. You can either update to latest or apply the fix to topics.rake yourself.