-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[$1000] Web - Onyx: out-of-order updates #28737
Comments
Triggered auto assignment to @CortneyOfstad ( |
Bug0 Triage Checklist (Main S/O)
|
I believe I found the cause. When the Just for documentation purposes: I suggested we need to make the update operations sequentially await. @marcaaron @tgolen are however worried about the app taking a big performance hit. I will try another solution and report back if I manage to get the app to do reliable updates. |
for note: that is what I already told in my proposal. #26592 (comment) |
Another problem in the App side:ProposalPlease re-state the problem that we are trying to solve in this issue.Onyx updating on race condition What is the root cause of that problem?https://github.com/Expensify/App/assets/16595846/736946e5-183f-4b16-969a-c0ef118ad228 @marcaaron I saw recently it changed to onyx to memory here
What changes do you think we should make in order to solve the problem?App/src/libs/Network/SequentialQueue.js Line 126 in 41ddd74
we need to flush out each api success or failure. |
Job added to Upwork: https://www.upwork.com/jobs/~013373cff08a2575e9 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee ( |
Upwork job price has been updated to $1000 |
@CortneyOfstad bumping the price as this one is pretty critical |
@jjcoffee any thoughts on the comments/proposals above? |
Unsure if this is still reproducible based on this, but also looks like @ospfranco has a PR in the works. |
@jjcoffee #26592 (comment), is fixed . but still have some issues can you check my #28737 (comment) |
Bump @jjcoffee ^^^ Thanks! |
Sorry @pradeepmdk could you flesh out your proposal or try to explain it a bit better? I'm finding it hard to follow what new issue you've found. |
From what I understand API requests responses are placed in a networkRequestQueue, which was before persisted to disk but now it is only kept in memory. If one refreshes the tab, then this queue will be lost (also due to its size it will probably take some time to process). Which could potentially lead to an inconsistent state. IMO this is another issue, not even sure if it is an issue if it doesn't cause incosistent data in the app, and should be in a separate ticket. my PR is merged and should have already fixed the out-of-order database writes. Let me know if there is anything else. |
Hi @ospfranco, the PR link you shared just links back to this issue. |
Oops, sorry, this is the PR |
Ah, fantastic. So I think we can consider this issue finished once the Onyx lib is bumped. |
@CortneyOfstad yeah 👍 |
Sounds good @Julesssss! @paultsimura I've adjusted the offer in Upwork, so please let me know once you accept! @ospfranco I still need you to link me your Upwork profile so I can send you an offer. Thanks! |
Thank you @CortneyOfstad, accepted the offer |
Thanks! Both @paultsimura and @Julesssss have been paid 👍 Will also ping @ospfranco in Slack 👍 |
Actually, can't find them in Slack 🤔 |
@Julesssss Can you tell me if this issue is fixed or not? Cause I saw the linked PR and I am not able to understand how changes to |
@shubham1206agra there are a couple of linked PRs, can you clarify the question please? |
I am talking about this PR #29169. My question is how did this PR fix the out-of-order updates? |
@Julesssss Bump on the question ^ |
There are explanations in the original and follow up onyx repo PR |
I found them on Twitter, but I got blocked for typing a message that sounded like a scam 😆 lets see if they get my second message |
Ah, so actually my PR was reverted, I don't know which steps the team took to fix the issue if any at all. As it had entailed doing a large refactoring of the Onyx internals. I cannot in good conscience accept any payment since I'm no longer helping Margelo with the project. You can forgo any payment you are planning for me, it's fine :) |
@ospfranco thanks, I see. It's hard to tell but it looks like we would have reverted, then resubmitted with a small fix which would still be eligible for payment. But I'll leave it up to you |
@ospfranco bump on the comment above ^^^ Thanks! |
Sounds like he's happy not to. We can always reopen if that changes though! |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
This bug comes from discussion in #26592
TL;DR: Onyx processes the
successData
and API response in the wrong order on iOS and Android.Dive deeper:
App/src/libs/actions/Policy.js
Line 408 in 3352cc8
When adding a member to workspace here, we send the following data:
And the API call returns the following onyx
merge_collection
action:It should replace the temporary
accountID
of thereport.ownerAccountID
with the real one, which comes from the server.On the web, the onyx actions are executed in the following order:
The issue is that on iOS, the onyx actions are executed in the following order:
The
successData
holds merge operation of only several certain fields, which shouldn't affect the report much.However, here's the tricky part:
This piece of code, which creates a promise for future merge operation, is executed before Onyx persists the API response:
https://github.com/Expensify/react-native-onyx/blob/616c4c5286b7a7fadac18d477cd75edd60865b12/lib/Onyx.js#L1136-L1147
Meaning the following execution chain:
persistSuccessData
promise;persistSuccessData
promise;This means, at the moment
persistSuccessData
is created, the existingValue is still not updated, so even though it should update only a couple of fields, themodifiedData
here is saved in a state of pre-API-response.Then the report is updated by the "persist API response" operation, but gets overwritten by the
persistSuccessData
operation with the outdated data.If we debug step-by-step, you'll notice that the chat name is displayed correctly between the steps 3 and 4 from above.
As an outcome of this complete operation, the state of Onyx is the following:
Expected Result:
Onyx updates are executed in correct order without data being overwritten
Actual Result:
Onyx updates face a race condition and some data is overwritten
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.3.76.0
Reproducible in staging?: n/a
Reproducible in production?: n/a
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
n/a
Expensify/Expensify Issue URL:
Issue reported by: @@paultsimura
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1696287156456449
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: