matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

Timeline inconsistent over deleted cache

Open gnunicorn opened this issue 3 years ago • 1 comments

#509 surfaced a problem in the room_timeline API: What to do with a stream handed out, when the underlying cache changes?

This could happen because the server has reshuffled and we are now seeing an event again in the sync, that we have already seen before - or because we are given a limited result set to save. Both cases trigger a complete purging of the existing timeline for a room right now. But there is no mention as two what that means for the stream handed out via room_timeline at this point, and MemoryStore and SledStore have different behaviors around this at the moment:

  • MemoryStore holds a Vec<Events> at the time they were requested and will continue to hand them out until they are gone, even if the entire timeline has been purged or reset since the room_timeline is requested
  • SledStore remembers the index of the item it is handing out next within the stream, which means that if the underlying timeline changes, the item it hands out might be different from the one at the time the stream was requested, including handing out the same event twice, or it could even be out of bounds (which leads it to terminate the Stream gracefully)

Neither is inherently right or wrong, as the API doesn't say what is the expected behavior. #509 contains an deactivated tests, that show cases that problem and the inconsistency between the two implementations.

gnunicorn avatar Mar 02 '22 11:03 gnunicorn

I would go with the behavior the MemoryStore has. Does this also cause https://github.com/matrix-org/matrix-rust-sdk/issues/572 ?

jsparber avatar Apr 08 '22 10:04 jsparber

I think that the method in question was removed, we now have a higher level Timeline API so please use that one instead.

Feel free to correct me if I'm wrong.

poljar avatar Feb 02 '24 12:02 poljar