Timeline inconsistent over deleted cache
#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 theroom_timelineis 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.
I would go with the behavior the MemoryStore has. Does this also cause https://github.com/matrix-org/matrix-rust-sdk/issues/572 ?
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.