-
Notifications
You must be signed in to change notification settings - Fork 37
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
Ensure clients see their transaction_id
s
#146
Conversation
18b5483
to
b67ea78
Compare
1210663
to
7a5335f
Compare
4bd7531
to
142290f
Compare
I assume everything is broken because I'm now delaying certain messages for up to a second. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sensible. Needs more testing and removal of visiblity checks.
This was the best way for me to make sense of the test log.
transaction_id
stransaction_id
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see some e2e tests to try to repro this bug (it'll flakey fail but that's better than not having any e2e tests here). This ensures that we are using the right API (e.g checking the right fields, etc.
Specifically:
- The alice/bob use case described in a comment.
- Multiple devices for alice, where other devices see the event without a txn id.
@@ -233,17 +233,18 @@ func TestInviteRejection(t *testing.T) { | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We neeed e2e tests for this. We cannot force the race to happen, but we can greatly encourage it by spamming events. I would do something like:
- Make alice and bob, join to same room.
- goroutine to repeatedly sliding sync as alice and accumulate the events without making assertions.
- goroutine to repeatedly sliding sync as bob and accumulate the events without making assertions.
- for i in N:
- Alice sends message with txnid i, remember event_id -> txnid mapping.
- Terminate goroutines when final event id is seen on both alice and bob.
- Assert that alice has the correct txn IDs for all N events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went for something simpler, see baa3596.
Running on that commit:
$ SYNCV3_SERVER=http://localhost:8888 SYNCV3_ADDR=http://localhost:8844 go test ./tests-e2e -v -count=10 -v -run TestTransactionIDsAppearWithMultiplePollers | egrep 'PASS|FAIL'
egrep: warning: egrep is obsolescent; using grep -E
--- PASS: TestTransactionIDsAppearWithMultiplePollers (2.53s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (2.67s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (2.67s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (2.49s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (2.71s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (2.63s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (2.80s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (2.70s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (2.66s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (2.65s)
PASS
Running on 595e1b3 (an older main):
$ SYNCV3_SERVER=http://localhost:8888 SYNCV3_ADDR=http://localhost:8844 go test ./tests-e2e -v -count=10 -v -run TestTransactionIDsAppearWithMultiplePollers | egrep 'PASS|FAIL'
egrep: warning: egrep is obsolescent; using grep -E
--- FAIL: TestTransactionIDsAppearWithMultiplePollers (1.65s)
--- FAIL: TestTransactionIDsAppearWithMultiplePollers (1.57s)
--- FAIL: TestTransactionIDsAppearWithMultiplePollers (1.80s)
--- FAIL: TestTransactionIDsAppearWithMultiplePollers (1.63s)
--- FAIL: TestTransactionIDsAppearWithMultiplePollers (1.69s)
--- FAIL: TestTransactionIDsAppearWithMultiplePollers (1.61s)
--- FAIL: TestTransactionIDsAppearWithMultiplePollers (1.69s)
--- FAIL: TestTransactionIDsAppearWithMultiplePollers (1.78s)
--- FAIL: TestTransactionIDsAppearWithMultiplePollers (1.56s)
--- FAIL: TestTransactionIDsAppearWithMultiplePollers (1.70s)
FAIL
FAIL github.com/matrix-org/sliding-sync/tests-e2e 16.677s
FAIL
In another test of 100 runs, I saw this fail 95 times and pass 5 times.
The 1 second difference in timing makes me wonder if something has gone wrong with the all clear mechanism. I will investigate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, we would not emit the V2TransactionID payloads if there were no new events.
28b11f8 contains the fix. With it:
$ SYNCV3_SERVER=http://localhost:8888 SYNCV3_ADDR=http://localhost:8844 go test ./tests-e2e -v -count=10 -v -run TestTransactionIDsAppearWithMultiplePollers | egrep 'PASS|FAIL'
egrep: warning: egrep is obsolescent; using grep -E
--- PASS: TestTransactionIDsAppearWithMultiplePollers (1.65s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (1.61s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (1.84s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (1.53s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (1.96s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (1.69s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (1.64s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (1.68s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (1.65s)
--- PASS: TestTransactionIDsAppearWithMultiplePollers (1.63s)
PASS
More sense conceptually---pollermap doesn't track any cross-poller state---and removes some indirection. Followup to #146. No functional changes.
Suppose
pos
) sliding sync./send
s a message into a room using atransaction_id
.The bold bullet is bad because it means that the client doesn't realise it has just received the event it sent, meaning that the "local echo" flickers.
We want to fix this by never notifiying a waiting sync handler about Things until its dedicated poller has seen that Thing. Do this by: