移动帖子返回502错误网关

10 posts were merged into an existing topic: 502 errors when splitting topic, moving or renaming categories

This most annoying bug is still with us.
Could you give me instructions to nail the problem?

1 个赞

Unfortunately we are still running into this issue from time to time. I managed to collect some data about a recent problem where moving 27 posts into an existing topic (2013 posts) failed:

Beginning move at 2021-05-25 20:54:57 +0000
create_temp_table
  0.000134   0.000027   0.000161 (  0.002810)

delete_invalid_post_timings
  0.000317   0.000065   0.000382 (  0.306869)

move_incoming_emails
  0.000056   0.000006   0.000062 (  0.000478)

move_notifications
  0.000074   0.000008   0.000082 (  0.005584)

update_reply_counts
  0.000088   0.000010   0.000098 (  0.001058)

update_quotes
  0.000079   0.000008   0.000087 (  0.002426)

move_first_post_replies
  0.000071   0.000008   0.000079 (  0.000695)

delete_post_replies
  0.000062   0.000006   0.000068 (  0.000834)

copy_first_post_timings
  0.000064   0.000007   0.000071 (  0.002660)

move_post_timings
  0.000082   0.000009   0.000091 (  0.008195)

copy_topic_users
  0.000398   0.000043   0.000441 (  0.043640)

move_each_post
  4.345220   0.132652   4.477872 (  3.447047)

create_moderator_post_in_original_topic
  0.163962   0.000253   0.164215 (  0.207101)

update_statistics
  0.217266   0.051660   0.268926 ( 45.258070)

update_user_actions
  0.000934   0.000101   0.001035 (  0.178894)

update_last_post_stats
  0.001589   0.000171   0.001760 (  0.003156)

update_upload_security_status
  0.000030   0.000003   0.000033 (  0.000034)

update_bookmarks
  0.000492   0.000054   0.000546 (  0.003832)

Finished move at 2021-05-25 20:55:47 +0000

Most methods finish real quick, but update_statistics took over 45 seconds in this case. All that time is spent on the following method call:

9 个赞

Maybe we defer the update_statistics work to sidekiq?

1 个赞

Yes, probably. But I’m going to take a hard look at how complicated it would be to move the whole process into a Sidekiq job and let the UI wait until it’s finished. We are kinda playing whac-a-mole here by always moving bits and pieces into jobs.

7 个赞

Thank you for your hard work!

2 个赞

I also get this 502 when trying to merge topics. Not every time, but a lot of the time.

I’m doing this when someone has started a topic on a subject that already exists, so typically I’m trying to move only a very small number of posts (no more than five).

I haven’t read this entire topic, but I’m understanding that this is a known issue that you’re working on and there isn’t anything I can do myself?

3 个赞

I’m also experiencing this issue on our forum. A number of us are unable to edit and/or create new posts. We’re getting the following error message:

1 个赞

我们还遇到了 502 错误,在移动帖子时发生。

以前只是偶尔发生,并且坚持尝试通常会成功。但现在我们遇到一个案例,在尝试将单个帖子移动到较长的帖子(2k 帖子)时,它会持续失败,并在大约 30 秒后超时。

发生这种情况时,服务器并不特别繁忙,并且可以很好地处理其他活动。在活动较低时尝试移动帖子会产生相同的结果。安全模式没有区别。

除了增强实例(假设这是其中一种解决方案?),还有什么我们可以尝试的吗?如果信息有用,我很乐意提供更多信息。值得一提的是,我使用的是最新的稳定版本——如果最近有针对此问题的更改,我会考虑切换到最新的测试版。

2 个赞

周末(我们最不忙碌的时候)我们暂时将存储最大 IOPS 增加了两倍,然后还将最大吞吐量增加了两倍,但仍然无法将一个帖子移动到包含 2k 个帖子的现有主题中。

在主题本身上发表新回复似乎没有问题,所以我猜想当帖子被移动而不是被重新创建时,会涉及更多额外的工作。如果无法在 30 秒内完成,也许应该通过后台作业来完成,而不是以“502 错误”消息失败?

6 个赞

是的,对于超过 3000 个帖子的旧且冗长的主题,我也会遇到同样的问题。
这仍然很痛苦。

3 个赞

你好

我遇到了类似的问题,无法将一个主题及其所有回复合并到另一个主题帖子中。我正在合并到的主题有 23 个帖子,而我正在移动的主题只有 4 个帖子。

|

错误日志
Message (4 copies reported)
Failed to process hijacked response correctly : PG::UniqueViolation : ERROR:  duplicate key value violates unique constraint "post_timings_unique"
DETAIL:  Key (topic_id, post_number, user_id)=(62975, 19, 538) already exists.
Backtrace
/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'
/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'
/var/www/discourse/app/models/post_mover.rb:517:in `move_post_timings'
/var/www/discourse/app/models/post_mover.rb:142:in `handle_moved_references'
/var/www/discourse/app/models/post_mover.rb:112: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:616:in `block in within_new_transaction'
/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/activerecord-7.2.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:613:in `within_new_transaction'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:361:in `transaction'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/transactions.rb:234:in `block in transaction'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:415:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/connection_handling.rb:296:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/transactions.rb:233:in `transaction'
/var/www/discourse/app/models/post_mover.rb:35:in `to_topic'
/var/www/discourse/app/models/topic.rb:1308:in `move_posts'
/var/www/discourse/app/controllers/topics_controller.rb:883:in `block in merge_topic'
/var/www/discourse/lib/hijack.rb:64:in `instance_eval'
/var/www/discourse/lib/hijack.rb:64:in `block in hijack'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promises.rb:911:in `callback_on_resolution'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promises.rb:797:in `call_callback'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promises.rb:803:in `call_callbacks'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promises.rb:692:in `resolve_with'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/promises.rb:1325:in `resolve'
/var/www/discourse/lib/scheduler/defer.rb:125:in `block in do_work'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rails_multisite-6.1.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rails_multisite-6.1.0/lib/rails_multisite/connection_management.rb:21:in `with_connection'
/var/www/discourse/lib/scheduler/defer.rb:119:in `do_work'
/var/www/discourse/lib/scheduler/defer.rb:105:in `block (2 levels) in start_thread'

**注意:**我注意到错误信息说“already exists”,但实际上它们是不同的主题。我不知道这是否相关,但在出现此错误之前,我将几个主题及其帖子移动到了我试图合并的这个有 23 个帖子的主题中(就像我对其他主题所做的那样)。

谢谢!

2 个赞

您最近几天更新了吗?最近有一个与移动帖子相关的修复程序

5 个赞