Skip to content
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

[HOLD for payment 2024-08-07] [$500] Onyx updates are not being queued in the correct order #37560

Closed
blimpich opened this issue Feb 29, 2024 · 61 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@blimpich
Copy link
Contributor

blimpich commented Feb 29, 2024

Problem

When batching update operations (e.g. when coming online), Onyx executes the merge and mergeCollection operations in an incorrect order which leads to data inconsistency. See this comment for context.

Why do we care?

This has caused multiple issues: this, this, and is currently holding this.

What's expected?

The updates should happen in the same exact order as they've been enqueued to guarantee the eventual consistency of the data.

Note: this will probably involve working with the react-native-onyx repository

Issue reported by: @paultsimura
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1709229991663269?thread_ts=1705484273.717249&cid=C01GTK53T8Q

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01fec4289917eb6d71
  • Upwork Job ID: 1763289951731056640
  • Last Price Increase: 2024-02-29
  • Automatic offers:
    • jjcoffee | Reviewer | 0
    • paultsimura | Contributor | 0
Issue OwnerCurrent Issue Owner: @Christinadobrzyn
@blimpich blimpich added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Feb 29, 2024
Copy link

melvin-bot bot commented Feb 29, 2024

Triggered auto assignment to @Christinadobrzyn (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@blimpich blimpich added the External Added to denote the issue can be worked on by a contributor label Feb 29, 2024
@melvin-bot melvin-bot bot changed the title Onyx updates are not being queued in the correct order [$500] Onyx updates are not being queued in the correct order Feb 29, 2024
Copy link

melvin-bot bot commented Feb 29, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01fec4289917eb6d71

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 29, 2024
Copy link

melvin-bot bot commented Feb 29, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee (External)

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 29, 2024
Copy link

melvin-bot bot commented Feb 29, 2024

📣 @jjcoffee 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Feb 29, 2024

📣 @paultsimura 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@blimpich
Copy link
Contributor Author

blimpich commented Feb 29, 2024

@jjcoffee I assigned @paultsimura without proposal based off this conversation. @paultsimura is going to work on this with help from @tgolen.

@paultsimura
Copy link
Contributor

Hey @tgolen, I'd like to discuss potential ways of fixing this (actually, only one of them worked for me).

This simple change fixes the issue:

- return clearPromise.then(() => Promise.all(_.map(promises, (p) => p())));
+ return clearPromise.then(() => _.reduce(promises, (p, fn) => p.then(fn), Promise.resolve()));

https://github.com/Expensify/react-native-onyx/blob/8cca556b08bf858c17a7d4f5ddd2879ac3f456d4/lib/Onyx.js#L1518

However, it makes all the batched changes execute in sequence, not in parallel, and I guess it's not something we would like, right?

Screen.Recording.2024-03-01.at.00.08.10-compressed.mp4

@paultsimura

This comment was marked as outdated.

@melvin-bot melvin-bot bot added the Overdue label Mar 4, 2024
Copy link

melvin-bot bot commented Mar 4, 2024

@tgolen, @paultsimura, @jjcoffee, @Christinadobrzyn Whoops! This issue is 2 days overdue. Let's get this updated quick!

@paultsimura
Copy link
Contributor

Melvin, I'm doing my best with the PR 🙂

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Mar 5, 2024
@Christinadobrzyn

This comment was marked as duplicate.

@melvin-bot melvin-bot bot removed the Overdue label Mar 8, 2024
@Christinadobrzyn

This comment was marked as duplicate.

@Christinadobrzyn
Copy link
Contributor

PR in the works!

@paultsimura
Copy link
Contributor

@tgolen should I open the PR, or are there some kind of regular centralized Onyx bumps?

@tgolen
Copy link
Contributor

tgolen commented Jul 24, 2024

I think you need to open a PR. There are no regular bumps for that. @mountiny might know if there are any currently open PRs that bump the version, but I am not aware of any.

@mountiny
Copy link
Contributor

We have just merged a PR from @hannojg but I dont think he started a bump PR yet. So we should make sure we will test for all the merged PRs in onyx compared to the one used in App now

@paultsimura
Copy link
Contributor

Ok @tgolen @mountiny - I will open a bump PR today. Will we look for C+ volunteer like usual for bump PRs, or should @jjcoffee review since he's the C+ for this issue?

@tgolen
Copy link
Contributor

tgolen commented Jul 26, 2024

I don't think we need to have a C+ if it's just a version bump.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 31, 2024
@melvin-bot melvin-bot bot changed the title [$500] Onyx updates are not being queued in the correct order [HOLD for payment 2024-08-07] [$500] Onyx updates are not being queued in the correct order Jul 31, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 31, 2024
Copy link

melvin-bot bot commented Jul 31, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Jul 31, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.14-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-08-07. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jul 31, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@paultsimura] The PR that introduced the bug has been identified. Link to the PR:
  • [@paultsimura] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@paultsimura] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@paultsimura] Determine if we should create a regression test for this bug.
  • [@paultsimura] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@Christinadobrzyn] Link the GH issue for creating/updating the regression test once above steps have been agreed upon: https://github.com/Expensify/Expensify/issues/418518

@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Aug 6, 2024

Payouts due:

Do we need a regression test @paultsimura?

@Christinadobrzyn Christinadobrzyn added Daily KSv2 and removed Weekly KSv2 labels Aug 6, 2024
@paultsimura
Copy link
Contributor

Sorry @Christinadobrzyn, this one is $500, not $250 as mentioned in the payment summary.

@paultsimura
Copy link
Contributor

I was not a C+ here, but would suggest the regression test:

  1. Submit a distance request with 3 waypoints
  2. Navigate to the distance request details (transaction thread)
  3. Disable the internet connection
  4. Click on the distance field to edit
  5. Click on a waypoint
  6. Click on the 3 dot menu > Delete waypoint
  7. Hit Save
  8. Switch chat
  9. Go back online
  10. Go back to the transaction thread
  11. Click "distance" again
  12. Verify the deleted waypoint is not present (i.e. it's "indeed" deleted)

@jjcoffee
Copy link
Contributor

jjcoffee commented Aug 7, 2024

@Christinadobrzyn No payment due to me as I never reviewed anything in the end 🙏

@jjcoffee jjcoffee removed their assignment Aug 7, 2024
@Christinadobrzyn
Copy link
Contributor

Thanks @paultsimura and @jjcoffee - are we paying someone else? @sobitneupane I see you on the PR, were you the C+ for this?

@paultsimura
Copy link
Contributor

Technically, there was no C+ here, only me and @tgolen mostly.

@Christinadobrzyn
Copy link
Contributor

Ah okay! Thanks @paultsimura!

I paid this out based on this payment summary. The regression test is created so I think this is good to close. Let me know if I'm missing anything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Archived in project
Development

No branches or pull requests

9 participants