-
Notifications
You must be signed in to change notification settings - Fork 268
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
crypto: events can be sent without an up-to-date member list causing UTDs #3529
Comments
I don't think so, due to this check happening at the start of the send:
Which does this check: matrix-rust-sdk/crates/matrix-sdk/src/room/mod.rs Lines 2524 to 2529 in abda959
Later on, the same piece of data is used to skip the matrix-rust-sdk/crates/matrix-sdk/src/room/mod.rs Lines 517 to 522 in abda959
In conclusion, if the SDK doesn't think you are joined, it doesn't let you send a message.
I think this is an unrelated issue, failing to upload OTKs would produce UTDs on the EX side, not on the EW side. |
I think this might be the problem, though the cancellation shouldn't set the To further expand, we have a request deduplication handler: matrix-rust-sdk/crates/matrix-sdk/src/deduplicating_handler.rs Lines 29 to 38 in abda959
The handler allows the first caller to acquire a lock and the lock is held for the duration of the call. The second caller then tries to acquire the same lock, though it will do so only after the first caller is done. The first caller gets the result of the operation and shares it through the lock with the rest of them. So a failure would be propagated correctly to the rest of the callers, but a cancellation, like EX does here, might not be a failure due to this critical line: matrix-rust-sdk/crates/matrix-sdk/src/deduplicating_handler.rs Lines 65 to 67 in abda959
|
We also have a deduplicating mechanism for some queries, including Now, I didn't think about cancellability when I implemented that deduplication (one extra proof that making it possible to cancel any future makes reasoning really hard). So what could happen:
Ideally, the SDK would "transmit" ownership of the deduplicated query to one of the waiters on the result, but I'm not sure that's what's happening here... |
I think we assume a successful result, look at my previous reply. |
Indeed, I hadn't seen your answer yet while typing mine. Good catch! |
So the failure scenario would be:
|
Not sure how it's done in this case, as I haven't checked what EXA is doing, but we provide a general cancellation primitive: matrix-rust-sdk/bindings/matrix-sdk-ffi/src/task_handle.rs Lines 4 to 39 in abda959
Yes, correct. The previous steps are correct as well. |
Fwiw, I'm working on adding a test showing the deduplicating handler failure (in this case), and making it more robust against this particular cancelling race. This doesn't mean it will solve this particular issue entirely (since it's unclear whether that was the root cause or not), but at least it'll make the whole deduplication handling more robust. |
Ah nice, thanks. |
Manually confirmed that #3533 fixes the issue. Whilst EXA still produces |
I've seen two bug reports from the same user on EXA which shows the following:
The SDK is supposed to hit
/members
prior to sending encrypted events to ensure they have an up-to-date member list. This is done inmatrix-rust-sdk/crates/matrix-sdk/src/room/futures.rs
Lines 166 to 168 in 0c97c85
I see no evidence of a
/members
hit when sending the event.However, this is complicated by the several confounding factors:
/members
and then immediately cancels the job, causingkotlinx.coroutines.JobCancellationException: Job was cancelled; job=SupervisorJobImpl{Cancelling}@6f96c4a
- this is normal behaviour when you back out of a room quickly before it can fully load.sync_members
will not actually sync the members if the user is invited and history visibility isHistoryVisibility::WorldReadable | HistoryVisibility::Invited
required_state: [[m.room.member, *]]
./keys/upload
to HTTP 400.These factors mean there's several things which could be going wrong here:
sync_members
doesn't actually sync members?/messages
? That doesn't make sense as it's historical state.There's a lot of moving parts here but I've done due diligence:
/members
is only hit one time, just after the/join
(this was triggered by EXA)The text was updated successfully, but these errors were encountered: