Remapping fails due to deadlock

I’ve got a large database (9.2 million posts) with a bunch of mega-topics (some > 150K posts!). When I try to do a restore to another server, I get something like this when it’s doing the remap to a new host name.

Restoring uploads, this may take a while...                                                   
Optimizing site icons...                                                                                      
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"  
EXCEPTION: ERROR:  deadlock detected                                              
DETAIL:  Process 960 waits for ShareLock on transaction 4765; blocked by process 2184.                   
Process 2184 waits for ShareLock on transaction 4915; blocked by process 960.                                    HINT:  See server log for query details.
CONTEXT:  while updating tuple (566294,13) in relation "posts"                                         

Is there something that I can do to resolve this deadlock?

This was on an 8GB standard droplet.

When trying to do a rebake I have had a similar issue with this site on a reasonably fast database server with 16GB of ram and a separate web server with 16GB of ram. Both were also serving some other fairly small and low-volume sites.

Does it seem likely that it’s the megatopics? Is there a solution other than splitting them into smaller ones?

1 Like

It’s a lot easier if you stop running the web and sidekiq processes during the remap, so there is nothing competing locks.

4 Likes

Thanks so much! This fixed it. And, so obvious once you suggested it.

3 Likes

sorry to bring this up we encounter the same problem.

how to stop the web and sidekiq proccesses?

Since you’re using a development environment, you just type control-c

in docker how should we stop it?

  sv stop unicorn
  sv stop sidekiq
1 Like

unicorn is the web right?

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.