This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bind the event TXN ID to the device ID instead of the access token ID #13064
Copy link
Copy link
Closed
Labels
T-TaskRefactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Description
When sending an event, the client sets a locally unique txnID on it, which serves two purposes:
- deduplicating events in case of network failures/retries
- when the client receives an event from /sync that they created, map it correctly to the locally-created event (for proper local echo)
The problem is, this txnID is currently bound to the user ID and the access token ID. Since MSC2918 (refresh tokens), a single client might deal with multiple access tokens, meaning that the current scenario is possible:
- client starts a /sync with its current access token
- this token is about to expire, so it refreshes it and gets a new access token
- the client sends a new event, with a random txnID, using the new access token
- /sync gets back, with the new event but not the txnID, since this /sync was done with another access token than when the event was created
I think the proper way to deal with this would be to have the txnIDs bound to devices instead of access tokens.
This is also relevant for the OIDC patches, since we don't really have access token IDs, but we do have the device ID.
What I would like to do is:
- add a column to the
event_txn_idto store the device ID - add the
device_idfield in the_EventInternalMetadata(and ensure we're persisting it when saving the txn IDs) - when looking up existing events, consider both the
token_idand thedevice_id - release Synapse like that, so current transactions don't break
- remove the
token_idfrom event transactions (event_txn_idtable,_EventInternalMetadata) everywhere, and do another release
Metadata
Metadata
Assignees
Labels
T-TaskRefactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.