feat(flags): finer grained concurrency control #29328
Open
+345
−32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
fine-grained-concurrency-demo.mp4
Follow up to: #29268
#29268 introduces concurrency controls to feature flag editing. If another user saves a change, any change, while you're editing, we block your save from stomping over their changes.
However, the implementation to do that was very broad. For example, if two people change different fields, it would block. It would block even if a user made no changes, but clicked the save button as we'd save it and increment the version (perhaps we should fix that too, but I leave it as an exercise for the reader).
Changes
Now, when we detect a possible conflict, we look deeper and compare what fields have changed. If the current save attempts to overwrite any fields that have changed while they were editing, we block the save. If there are no conflicts, for example, the current user changes the description while another user changed the filters, then we allow the save to go through.
CAVEAT: This PR doesn't do anything fancy in regards to filters. So if one user edits the variants, while another edits the conditions, we will block because they get saved to the same filters JSON blob. I think this is satisfactory for now.
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
Manual testing and also unit tests. See the demo video.