-
Notifications
You must be signed in to change notification settings - Fork 170
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
Fix race in send_upload_message #7088
Conversation
Pull Request Test Coverage Report for Build daniel.tabacaru_600
💛 - Coveralls |
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 tested this against BAAS version 27f42f55a7944ed7d8ba9fad1854a4b22714cb8d where I had been able to repro the hang in the test "app: flx-sync basic tests" and it looks like it is fixed. Great job tracking down the issue here.
I'd suggest adding a changelog note as it may be affecting customers or SDK tests.
I'll definitely add changelog entries for both bugs. |
Could the failure above be related to these changes?
|
Everything looks fine. I looked at the logs and we do send the query, but it seems we don't wait for it to be complete:
My theory is that there is a race and wait_for_download fires before the query is bootstrapped. If my theory is correct, one way to fix it is:
There will be no wait in most cases. |
What, How & Why?
A race in
send_upload_message()
causes subscriptions not being sent to the server (and as a side effect a notification on that subscription may never be fulfilled). This can happen when send_upload_message() is called as a result of a commit previous to the one for subscriptions. send_upload_message() then forwards the upload cursor past the version associated with the subscription and so the subscription is never uploaded to the server.A second bug was uncovered while investigating this issue.
SessionWrapper reads the state of the SubscriptionStore when it is created, but this state can change after a client reset (when then state of existing subscription may change, in addition to new subscriptions being created and old subscriptions being removed). This can cause a crash with realm::KeyNotFound when trying to update a subscription which does not exist anymore.
Fixes #7076, #7090.
☑️ ToDos
[ ] 🚦 Tests (or not relevant)[ ] C-API, if public C++ API changed.