# Moving posts to a long topic fails

**URL:** https://meta.discourse.org/t/moving-posts-to-a-long-topic-fails/347984
**Category:** Bug
**Created:** [January 20, 2025, 9:31am UTC](https://meta.discourse.org/t/moving-posts-to-a-long-topic-fails/347984 "2025-01-20T09:31:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)
#### Post date: [January 20, 2025, 9:31am UTC](https://meta.discourse.org/t/moving-posts-to-a-long-topic-fails/347984/1 "2025-01-20T09:31:58Z")

</div>

I’m aware I’ve probably exceeded the _reasonable_ number of posts to move, and now it fails with the message:

`There was an error moving posts.`

I was trying to move 19 posts from a 1,500-post topic into a 4,500-post topic.

Still, it would be great if there was a solution.

Moving to a new topic works fine.

```plaintext
Unicorn worker received USR2 signal indicating it is about to timeout, dumping backtrace for main thread
config/unicorn.conf.rb:203:in `backtrace'
config/unicorn.conf.rb:203:in `block (2 levels) in reload'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rack-mini-profiler-3.3.1/lib/patches/db/pg.rb:110:in `exec'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rack-mini-profiler-3.3.1/lib/patches/db/pg.rb:110:in `async_exec'
(eval at /var/www/discourse/lib/method_profiler.rb:38):29:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_sql-1.6.0/lib/mini_sql/postgres/connection.rb:217:in `run'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_sql-1.6.0/lib/mini_sql/active_record_postgres/connection.rb:38:in `block in run'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_sql-1.6.0/lib/mini_sql/active_record_postgres/connection.rb:34:in `block in with_lock'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active_support/concurrency/null_lock.rb:9:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_sql-1.6.0/lib/mini_sql/active_record_postgres/connection.rb:34:in `with_lock'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_sql-1.6.0/lib/mini_sql/active_record_postgres/connection.rb:38:in `run'
/var/www/discourse/lib/mini_sql_multisite_connection.rb:109:in `run'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_sql-1.6.0/lib/mini_sql/postgres/connection.rb:196:in `exec'
(eval at /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/mini_sql-1.6.0/lib/mini_sql/builder.rb:62):2:in `exec'
/var/www/discourse/app/models/topic_user.rb:511:in `update_post_action_cache'
/var/www/discourse/app/models/post_mover.rb:634:in `update_statistics'
/var/www/discourse/app/models/post_mover.rb:116:in `move_posts_to'
/var/www/discourse/app/models/post_mover.rb:35:in `block in to_topic'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:6...

```

```plaintext

activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:130:in `block in warn' 
activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:231:in `block in dispatch' 
activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:231:in `each' 
activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:231:in `dispatch' 
activesupport-7.2.2.1/lib/active_support/broadcast_logger.rb:130:in `warn' 
/var/www/discourse/lib/signal_trap_logger.rb:40:in `public_send' 
/var/www/discourse/lib/signal_trap_logger.rb:40:in `block (2 levels) in ensure_logging_thread_running' 
<internal:kernel>:187:in `loop'
/var/www/discourse/lib/signal_trap_logger.rb:37:in `block in ensure_logging_thread_running'

```

I’m on latest core version [b6f62bcc05](https://github.com/discourse/discourse/commits/b6f62bcc05f82ca5b54894dfefef849675ceb77e)

Is there still a plan to move the logic to a sidekiq?

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [January 20, 2025, 11:08am UTC](https://meta.discourse.org/t/moving-posts-to-a-long-topic-fails/347984/2 "2025-01-20T11:08:44Z")

</div>

There is a recent post about a similar issue:

> [@Moving posts returns 502 bad gateway](https://meta.discourse.org/t/moving-posts-returns-502-bad-gateway/75654/79):
>
> Did you update in the past few days? There was a recent fix related to moving posts

Maybe try to update if you’re not on the last version.

---

<div class="post-metadata">

### Author: ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)
#### Post date: [January 20, 2025, 11:34am UTC](https://meta.discourse.org/t/moving-posts-to-a-long-topic-fails/347984/3 "2025-01-20T11:34:59Z")

</div>

I’ve noticed..

> [@Overgrow](#):
>
> I’m on latest core version [b6f62bcc05](https://github.com/discourse/discourse/commits/b6f62bcc05f82ca5b54894dfefef849675ceb77e)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 21, 2025, 2:49am UTC](https://meta.discourse.org/t/moving-posts-to-a-long-topic-fails/347984/4 "2025-01-21T02:49:07Z")

</div>

We could buy you a bit more time and kick this to the defer queue quite easily, that would give 90 seconds vs 30 seconds for the work.

I am a bit concerned that it takes so long here, updating stats does feel like something we should be able to do later after the posts moved.

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [January 28, 2025, 6:03am UTC](https://meta.discourse.org/t/moving-posts-to-a-long-topic-fails/347984/12 "2025-01-28T06:03:26Z")

</div>

I’ve done the hijack for now, but yes there is likely a bunch of other optimizations to make here:

[https://github.com/discourse/discourse/pull/31029](https://github.com/discourse/discourse/pull/31029)
