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?

1 Like

Either one of these should work

./launcher enter app
rake posts:rebake

or

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

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.

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.

3 Likes

I applied actions.

Output:

OK

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

Well, then kill the rake process.

1 Like

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?

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!

2 Likes

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

postgres 9.5/main: discourse discourse [local] SELECT

What does it do?

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:

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.

5 Likes

After restoring Discourse on a new host, I found some old topic images are not showing

But it appears in two case

  • When I click on it to see full size
  • When I rebuild HTML of that topic

If I do below command

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

Is it same as rebuilding? :thinking:
Yesterday, I tried it was taking so long time, so I stopped it in half-way.

Thanks & Regards,
Gulshan

1 Like

If the URL to your site changed, yes, it’s a good idea to rebake.

4 Likes

Site URL is same as before. The original goal was to moving Discourse existing forum to another hosting.

The include thumbnails in backups site setting lets you configure if backups should include thumbnails or not. The setting defaults to off and leads to smaller backups. When you restore such a backup you will see the following message in the log:

Posts will be rebaked by a background job in sidekiq. You will see missing images until that has completed.
You can expedite the process by manually running rake posts:rebake_uncooked_posts

4 Likes

Thanks for the head up. Actually, I was surprised my original disk usage was near 34GB out of 40GB. but I was getting backup file of only 2GB. I have enabled this settings now, and I will take backup again and then I will proceed to restore.

  1. I enabled include thumbnails in backups
  2. Created backup at S3
  3. Installed Discourse
  4. Download backup at default folder location using wget command
  5. Restored site. Every posts are showing even many images also, but few of them are broken.

Rebuild HTML is not fixing the problem, just make that area little larger than before. Ref: screenshot


(Clicking on image doesn’t show me full size image)

8tAkwFf30m

Not sure, if this will fix. :frowning:

On 8 vCPUs, 52 GB memory, the rebake process is quite slow. Is there any alternative fix?