[keyserver] Use message ID as tiebreaker in message-fetchers code
Summary:
In D4675, @tomek pointed out that our results may be inconsistent in the case where two messages have the same timestamp. While this scenario is unlikely, it is technically possible.
To make the results consistent we can add a "tiebreaker" as a second ORDER BY parameter. This diff adds id as the tiebreaker for all message-fetchers.js functions that return ordered lists.
Tracked in ENG-1488.
Test Plan:
- I compared the web inbox in my local environment between master and with this diff to make sure the same chats appeared in the same order with the same set of messages inside them.
- First, I ran the query with the PREDICATE manually in MariaDB to make sure it worked, since that was a special case.
- Then I patched this diff onto prod and deployed it to make sure that the queries still worked without issue (including without performance issues).
Reviewers: tomek, atul
Reviewed By: atul
Subscribers: adrian, abosh, tomek
Differential Revision: https://phab.comm.dev/D4722