This commit fixes an undesirable geometric query memory usage introduced in b908abe35a (#29539)

I have been unable to figure out a way of testing this usefully (as I fear it would require creating several thousands of objects), but existing tests pass and a manual test with ~400k topics succeeds after the fix, while it would hang indefinitely and/or consume all disk space before the fix.

I have reported the initial problem and my findings in https://meta.discourse.org/t/topic-reset-all-highest-exhausts-all-available-disk-space/333837
This commit is contained in:
pgcd 2024-11-03 23:00:03 +01:00 committed by GitHub
parent f4865a4288
commit 725d2411e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -881,7 +881,8 @@ class Topic < ActiveRecord::Base
WHERE
topics.archetype <> 'private_message' AND
X.topic_id = topics.id AND
Y.topic_id = topics.id AND (
Y.topic_id = topics.id AND
Z.topic_id = topics.id AND (
topics.highest_staff_post_number <> X.highest_post_number OR
topics.highest_post_number <> Y.highest_post_number OR
topics.last_posted_at <> Y.last_posted_at OR
@ -926,7 +927,8 @@ class Topic < ActiveRecord::Base
WHERE
topics.archetype = 'private_message' AND
X.topic_id = topics.id AND
Y.topic_id = topics.id AND (
Y.topic_id = topics.id AND
Z.topic_id = topics.id AND (
topics.highest_staff_post_number <> X.highest_post_number OR
topics.highest_post_number <> Y.highest_post_number OR
topics.last_posted_at <> Y.last_posted_at OR