fix: When receiving MDN, mark all preceding messages as noticed, even having same timestamp (#7928)#8046
fix: When receiving MDN, mark all preceding messages as noticed, even having same timestamp (#7928)#8046
Conversation
This way it's easier to debug issues like `MsgsNoticed` not emitted for a chat.
… having same timestamp (#7928) This fixes flaky JSON-RPC `test_multidevice_sync_seen`.
| hidden=0 AND | ||
| chat_id=? AND | ||
| timestamp<?", | ||
| state=?2 AND hidden=0 AND chat_id=?3 AND timestamp<?4 OR |
There was a problem hiding this comment.
EXPLAIN QUERY PLAN UPDATE msgs SET state=? WHERE state=? AND hidden IN (0,1) AND chat_id=? AND timestamp<? OR state=? AND hidden IN (0,1) AND chat_id=? AND timestamp=? AND id<?;
QUERY PLAN
`--MULTI-INDEX OR
|--INDEX 1
| `--SEARCH msgs USING COVERING INDEX msgs_index7 (state=? AND hidden=? AND chat_id=? AND timestamp<?)
`--INDEX 2
`--SEARCH msgs USING COVERING INDEX msgs_index7 (state=? AND hidden=? AND chat_id=? AND timestamp=? AND rowid<?)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.
There was a problem hiding this comment.
This can't be rewritten using AND (timestamp<? OR timestamp=? AND id<?), see https://sqlite.org/queryplanner.html#_or_connected_terms_in_the_where_clause -- OR should be the final operator connecting the terms.
|
|
This fixes flaky JSON-RPC
test_multidevice_sync_seen.Fix #7928