Skip to content

fix: When receiving MDN, mark all preceding messages as noticed, even having same timestamp (#7928)#8046

Merged
iequidoo merged 2 commits intomainfrom
iequidoo/7928
Mar 29, 2026
Merged

fix: When receiving MDN, mark all preceding messages as noticed, even having same timestamp (#7928)#8046
iequidoo merged 2 commits intomainfrom
iequidoo/7928

Conversation

@iequidoo
Copy link
Copy Markdown
Collaborator

This fixes flaky JSON-RPC test_multidevice_sync_seen.
Fix #7928

This way it's easier to debug issues like `MsgsNoticed` not emitted for a chat.
hidden=0 AND
chat_id=? AND
timestamp<?",
state=?2 AND hidden=0 AND chat_id=?3 AND timestamp<?4 OR
Copy link
Copy Markdown
Collaborator Author

@iequidoo iequidoo Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXPLAIN QUERY PLAN UPDATE msgs SET state=? WHERE state=? AND hidden IN (0,1) AND chat_id=? AND (timestamp,id)<(?,?);
QUERY PLAN
`--SEARCH msgs USING INDEX msgs_index7 (state=? AND hidden=? AND chat_id=? AND timestamp<?)

Let's prepare for adding timestamp to msgs_index7, it's not the only place where timestamp speeds up a query, e.g. building chatlists is also sped up. See also #7904 for why hidden IN (0,1) (instead of hidden=0) is used in EXPLAIN QUERY PLAN.

Copy link
Copy Markdown
Collaborator Author

@iequidoo iequidoo Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: SQLite supports tuple comparison, so i updated the query in the PR

@iequidoo
Copy link
Copy Markdown
Collaborator Author

iequidoo commented Mar 26, 2026

test_iroh_webxdc.py::test_no_duplicate_messages hung for unknown reason (https://github.com/chatmail/core/actions/runs/23614345419/job/68778915544?pr=8046), but i don't think that's related to the fix here. test_multidevice_sync_seen passed for all configurations

@iequidoo iequidoo marked this pull request as ready for review March 26, 2026 19:57
@iequidoo iequidoo requested review from Hocuri and link2xt March 26, 2026 19:57
… having same timestamp (#7928)

This fixes flaky JSON-RPC `test_multidevice_sync_seen`.
@iequidoo iequidoo merged commit ef718bb into main Mar 29, 2026
30 checks passed
@iequidoo iequidoo deleted the iequidoo/7928 branch March 29, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests/test_multidevice.py::test_multidevice_sync_seen is flaky

2 participants