-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
It's not explicitly clear that Devices and (Live) Sync Tokens are meant to exist on a 1-to-1 basis #1416
Comments
I added a helper method to Complement to help managing multiple devices for a single user easier: matrix-org/complement#576 |
I'm afraid I'm struggling to parse this four-line sentence. Please can you update the description with a clearer summary of what the issue is. Including context of where it was discussed is fine, but don't make me read through it all before even explaining what the problem is. Devices and Sync tokens are not meant to exist on a 1:1 basis. A single device will see many sync tokens over the course of its lifetime. |
@richvdh i've reworded that paragraph, and my reasoning.
Alive sync tokens, maybe I should punctate that in some points. |
Thanks, the issue is much clearer now. However:
I don't think this is correct.
|
Argh, that is indeed not as simple as I saw it first, but this gives me a distinct impression that the platonic ideal (for sync tokens) feels in conflict with itself, if its used for both KOTH (King-of-the-hill) style one-token-lives functionality (e.g. to-device), but also as a more-universal pagination or resumption token (e.g. I feel like this is good feedback for sliding sync, or at least its E2EE extension, as right now I don't see an easy way out of this kind-of messiness, and instead this should inform future API design to not cause these kinds of complications.
I tried to clarify, but my definition of a "live" token in this case is "whatever token the client will be using for its next sync request, only replaced by the An additional caveat would be - in my opinion - that a device cant "backtrack" (to prevent something like to-device messages getting dropped server-side) several "generations" of tokens, and that it can only use the current or next generation of the sync token, progressing those in lock-step with the server. |
<shrug> It works fine, even if it's not a platonic ideal. (And yes, I believe sliding sync is changing this.) I'm now unclear if this issue is complaining that the spec is not clear about how the endpoint works (in which case, contributions welcome), or that you'd have designed the API differently (in which case, maybe wait for sliding sync)? |
I think it's a bit of both, but I'll wait for sliding sync, as my problem with the spec is mostly together with worry that its continued mis-interpretation would result in new implementations making these mistakes. |
Context
This came up while discussing MSC3391 in
#synapse-dev
, context here.Synapse stores a table of user devices that have seen a particular delete of account data, to keep track which devices have yet outstanding notices, and to delete the account-data table entry when the last one had received it.
I mused about a possible edge-case of multiple sync-tokens per device not receiving this information, and proposed tracking the account-data stream id in the sync token itself. (Which had other problems, but is irrelevant to contextualising this).
I got told that this wasn't necessary, as devices were expected to only hold one sync-token live, which got underscored with a pointer to to-device message handling, where old to-devices are removed from the database once a device calls sync on the
next_batch
sync-token.In my eyes, this above would make it unworkable (or at the very least, very undesirable) to use multiple sync tokens per device, or that a sync token is used more than once, as it effectively causes undefined or undesirable behaviour.
Issue
Currently, it seems, that matrix expects devices to only regard a single sync token usable at any time, replaced by the
next_batch
sync token when it is received in a sync response.This is only weakly suggested in the spec, and is not really enforced by homeservers. I myself have made the mistake of sometimes (ab)using multiple sync tokens (per device) in complement (which means I probably need to give it a once-over and abstract these multi-synctoken usecases with devices), and I suspect some libraries or other are using this as well.
Especially to-device, and maybe soon the behaviour from MSC3391 (deleting account data, and getting notified of it), rely on a client never re-using a sync token (after already continuing to use its
next_batch
successor), and calling sync on two sync tokens linked to the same device, at the same time.This could be a potential source for bugs and confusion. If the spec would be extra strict, and encourage homeserver implementations to add more-strict checks on sync tokens (i.e. "one sync token is alive at a time, per device"), it could remove a class of desynchronisation bugs (where things such as to-device, presence, or other "falls between the cracks"), and could possibly help make syncing easier to manage.
The text was updated successfully, but these errors were encountered: