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

Fleet UI: Fix flaky race condition bug, clean code #18872

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

RachelElysia
Copy link
Member

@RachelElysia RachelElysia commented May 9, 2024

Issue

Addresses #18740

Description

  • Use useEffect to update formData to avoid race condition
  • Clean code and other consistency nits, examples include:
    • Rename onSubmit, instead of handleSubmit
    • Rename isUpdatingXYZ, instead of updatingXYZ
    • Re-order `useState``s for readability
    • Rename variables to clearly match 2 similar but different modals

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Manual QA for all new/changed functionality

@RachelElysia
Copy link
Member Author

Status: @getvictor is testing this branch. If the await doesn't fix it, will need to table to next Wednesday and consider looking into useMutation hook.

@getvictor
Copy link
Member

It looks to be working most of the time. I was able to reproduce it once, but I can't reproduce it again: https://www.loom.com/share/df5b97abcd204ce3846fed799e348799 So, I'm OK with this fix.

Looks like after saving the policies in parallel, you refetch the policies. Do you wait some time before refetching? I'm wondering whether it makes sense to wait a small amount of time to avoid read-after-write consistency issues in production (where we have separate master/replica databases).

This question is not just for this issue. This applies to any time we read something after writing a new value for it, like updating a user, etc. In production, I see a replication time of 30ms, so that's probably a good enough wait time. Note: I'm not running master/replica in my dev environment, but this is just a thought I had.

@RachelElysia
Copy link
Member Author

ation time of 30m

Thanks for all this @getvictor - I just added a 100ms wait to be on the safe side.

@RachelElysia RachelElysia marked this pull request as ready for review May 29, 2024 16:02
@RachelElysia RachelElysia requested a review from a team as a code owner May 29, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants