mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 00:13:41 +08:00
9c39053d6f
What is the problem? Previously, this was the query used to move change messages into another channel. ``` INSERT INTO chat_messages( chat_channel_id, user_id, last_editor_id, message, cooked, cooked_version, created_at, updated_at ) SELECT :destination_channel_id, user_id, last_editor_id, message, cooked, cooked_version, CLOCK_TIMESTAMP(), CLOCK_TIMESTAMP() FROM chat_messages WHERE id IN (:message_ids) RETURNING id ``` The problem is that this incorrectly assumes that the insertion will be based on the order of `message_ids`. However, that is not the case as PostgreSQL provides no such guarantee. Instead we need to explicitly order the messages to ensure the right order of insertion. This problem was discovered by a flaky test which exposed the non-guarantee order of insertion. |
||
---|---|---|
.. | ||
bookmark_extension.rb | ||
category_extension.rb | ||
channel_archive_service.rb | ||
channel_fetcher.rb | ||
channel_hashtag_data_source.rb | ||
channel_membership_manager.rb | ||
direct_message_channel_creator.rb | ||
duplicate_message_validator.rb | ||
engine.rb | ||
guardian_extensions.rb | ||
mailer.rb | ||
message_bookmarkable.rb | ||
message_creator.rb | ||
message_mover.rb | ||
message_processor.rb | ||
message_rate_limiter.rb | ||
message_reactor.rb | ||
message_updater.rb | ||
notifier.rb | ||
parsed_mentions.rb | ||
plugin_instance_extension.rb | ||
post_notification_handler.rb | ||
review_queue.rb | ||
reviewable_extension.rb | ||
secure_uploads_compatibility.rb | ||
seeder.rb | ||
slack_compatibility.rb | ||
statistics.rb | ||
steps_inspector.rb | ||
transcript_service.rb | ||
user_email_extension.rb | ||
user_extension.rb | ||
user_notifications_extension.rb | ||
user_option_extension.rb |