-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: always prefer unthreaded receipt when >1 exist (MSC4102) #16927
bugfix: always prefer unthreaded receipt when >1 exist (MSC4102) #16927
Conversation
As this PR references server behaviour specified by an MSC, my initial reaction was that "this needs an
In essence this change already fits within the current spec version, which was ambiguous. Today, this change in Synapse wouldn't require an MSC. However, I commend @kegsay for going and clarifying the spec as well by writing an MSC. |
Yeah @turt2live said much the same in that it doesn't really need to be an MSC, it's a clarification of previously undefined behaviour. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on! A couple small suggestions.
# This means we will drop some receipts, but MSC4102 is designed to drop semantically | ||
# meaningless receipts, so this is okay. Previously, we would drop meaningful data! | ||
receipt_data = db_to_json(data) | ||
if user_id in receipt_type_dict: # existing receipt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the first arm of this if
statement does not handle the following cases:
- there is an existing receipt, and it is unthreaded
- there is an existing receipt and it is threaded, but there is an incoming threaded receipt
In both of those cases, receipt_type_dict
is not modified. Is this on purpose? If not, perhaps it'd be best to pull line 490 up and out of this if
statement, so that it is run regardless (and then potentially overridden later).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is an existing receipt, and it is unthreaded then it should not be replaced so I would expect the conditional to fail.
It is impossible for there to be a threaded receipt and then another threaded receipt for the same (user, event, type) tuple. If that did happen, it's undefined behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. I was perplexed that the old code would always update receipt_type_dict
, whereas this new code does not in some cases. But I suppose that was the "last receipt always wins" behaviour you described that you seek to replace.
N.B. I find the (prior) code in this method a bit too magical. But your changes look sound.
Co-authored-by: Andrew Morgan <[email protected]>
# This means we will drop some receipts, but MSC4102 is designed to drop semantically | ||
# meaningless receipts, so this is okay. Previously, we would drop meaningful data! | ||
receipt_data = db_to_json(data) | ||
if user_id in receipt_type_dict: # existing receipt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. I was perplexed that the old code would always update receipt_type_dict
, whereas this new code does not in some cases. But I suppose that was the "last receipt always wins" behaviour you described that you seek to replace.
N.B. I find the (prior) code in this method a bit too magical. But your changes look sound.
# Synapse 1.102.0 (2024-03-05) ### Bugfixes - Revert element-hq/synapse#16756, which caused incorrect notification counts on mobile clients since v1.100.0. ([\#16979](element-hq/synapse#16979)) # Synapse 1.102.0rc1 (2024-02-20) ### Features - A metric was added for emails sent by Synapse, broken down by type: `synapse_emails_sent_total`. Contributed by Remi Rampin. ([\#16881](element-hq/synapse#16881)) ### Bugfixes - Do not send multiple concurrent requests for keys for the same server. ([\#16894](element-hq/synapse#16894)) - Fix performance issue when joining very large rooms that can cause the server to lock up. Introduced in v1.100.0. ([\#16903](element-hq/synapse#16903)) - Always prefer unthreaded receipt when >1 exist ([MSC4102](matrix-org/matrix-spec-proposals#4102)). ([\#16927](element-hq/synapse#16927)) ### Improved Documentation - Fix a small typo in the Rooms section of the Admin API documentation. Contributed by @RainerZufall187. ([\#16857](element-hq/synapse#16857)) ### Internal Changes - Don't invalidate the entire event cache when we purge history. ([\#16905](element-hq/synapse#16905)) - Add experimental config option to not send device list updates for specific users. ([\#16909](element-hq/synapse#16909)) - Fix incorrect docker hub link in release script. ([\#16910](element-hq/synapse#16910)) ### Updates to locked dependencies * Bump attrs from 23.1.0 to 23.2.0. ([\#16899](element-hq/synapse#16899)) * Bump bcrypt from 4.0.1 to 4.1.2. ([\#16900](element-hq/synapse#16900)) * Bump pygithub from 2.1.1 to 2.2.0. ([\#16902](element-hq/synapse#16902)) * Bump sentry-sdk from 1.40.0 to 1.40.3. ([\#16898](element-hq/synapse#16898))
Pull Request Checklist
MSC: matrix-org/matrix-spec-proposals#4102
Tests: matrix-org/complement#709
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)