Skip to content
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

Incremental /sync and /transactions query events differently #11394

Open
matrixbot opened this issue Dec 19, 2023 · 0 comments
Open

Incremental /sync and /transactions query events differently #11394

matrixbot opened this issue Dec 19, 2023 · 0 comments

Comments

@matrixbot
Copy link
Collaborator

matrixbot commented Dec 19, 2023

This issue has been migrated from #11394.


As discovered in matrix-org/synapse#11265 (comment)


/sync looks for stream_ordering but excludes all outliers.

https://github.com/matrix-org/synapse/blob/b09d90cac9179f84024d4cb3ab4574480c1fd1df/synapse/storage/databases/main/stream.py#L519-L527

Whereas /transactions(Application service API) only cares about stream_ordering.

https://github.com/matrix-org/synapse/blob/b09d90cac9179f84024d4cb3ab4574480c1fd1df/synapse/storage/databases/main/appservice.py#L358-L368

The behavior of these two endpoints should probably return and push the same events.

Here is the history behind why we added AND not outlier to the incremental sync endpoint, "Don't return outliers when we get recent events for rooms.", matrix-org/synapse@1505055 but it doesn't explain the why or which interaction creates outlier events that aren't backfilled.

What does the spec say?

For /transactions, the spec doesn't distinguish which events a homeserver should and shouldn't push, https://spec.matrix.org/v1.1/application-service-api/#put_matrixappv1transactionstxnid

For /sync, there is also nothing so clear cut but it's obvious using the since pagination query parameter that it should return anything after which equates to stream_ordering in Synapse land.

Potential solutions

Exclude outliers in both

Perhaps we should exclude outliers in /transactions so they both just match?

@richvdh had some critique about this approach though:

the outlier flag seems like a poor way to decide whether we should push this data. (Yes, outliers shouldn't be sent over /transactions, but there are probably many other events which shouldn't be sent).

FederationEventHandler._process_received_pdu has a backfilled parameter (see synapse/handlers/federation_event.py#L945), whose purpose is slightly unclear, but I think one of its jobs is this sort of thing. Maybe we should use similar logic to that, somehow?

-- @richvdh, https://github.com/matrix-org/synapse/pull/11265#discussion_r746523400

But for /transactions, we can't tell whether the event was backfilled. The only indication is that the stream_ordering would be negative which is what the /transactions code already takes into account.

Only exclude backfilled events

This means only relying on stream_ordering.

Then any interaction creating outliers that we don't want to appear down /sync//transactions, should be updated to be also marked as backfilled.

Dev notes

/sync stack trace

/transactions stack trace

submit_event_for_as ->

@matrixbot matrixbot changed the title Dummy issue Incremental /sync and /transactions query events differently Dec 21, 2023
@matrixbot matrixbot reopened this Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant