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 bad interaction between methods and buffering #8088
Conversation
And do not ask how much debugging went into this one line code change. |
I am not sure what you are asking. |
My current workaround to fix this locally: saveOriginals = Meteor.connection.__proto__._saveOriginals
Meteor.connection.__proto__._saveOriginals = ->
@_flushBufferedWrites()
saveOriginals.apply this, arguments |
Hm, |
Changing the line to:
Seems to fix the test, but it is unclear if this is the right thing to do. |
You can try this small patch and see if it fixes for you. But I do not think it is related. Symptom here for me was that data on the client collection was old data because. So updates to the collection were overridden. I do not think this happens for methods because methods are not "updates". |
I added a test. |
Can we get some eyes on this? @glasser? |
Gosh, it's been a long long time since I've spent any time in this codebase. @benjamn do you think I'm still the best person to review this? |
18b5ad2
to
e7fe8ab
Compare
I'm not sure I'm the best person to review this either, although the original description and the recently added test (18b5ad2) makes it fairly clear to me. There might be a better fix, but I'd need to do quite a bit more digging to know. I'm curious if we should change the test to use I can confirm that the test fails without the "fix" code and I've gone ahead and rebased this off |
I think |
So it seems we introduced a bug with #5680.
The issue is the following scenario:
a
b
replace
message with the olda
value, without that published change being presentOr something like this. It is really tricky race condition when this happens. But the solution is simple. Methods should always run on the latest state of data, without any pending buffered state. So this pull requests applies pending buffered state. In retrospective this looks obvious.
I am unsure how to make a test for this to discover such cases in the future with tests.
cc @nathan-muir