Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Bind the event TXN ID to the device ID instead of the access token ID  #13064

Closed
@sandhose

Description

@sandhose

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_id to store the device ID
  • add the device_id field in the _EventInternalMetadata (and ensure we're persisting it when saving the txn IDs)
  • when looking up existing events, consider both the token_id and the device_id
  • release Synapse like that, so current transactions don't break
  • remove the token_id from event transactions (event_txn_id table, _EventInternalMetadata) everywhere, and do another release

Metadata

Metadata

Assignees

Labels

T-TaskRefactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions