flagsmith icon indicating copy to clipboard operation
flagsmith copied to clipboard

Add concurrency check when updating flags config value

Open rfriend-zilo opened this issue 11 months ago • 4 comments

How are you running Flagsmith

  • [ ] Self Hosted with Docker
  • [ ] Self Hosted with Kubernetes
  • [X] SaaS at flagsmith.com
  • [ ] Some other way (add details in description below)

Describe the bug

When two people have the config drawer open for any given feature flag which includes config, if one user makes a change to the config value and then the second user makes a change (without refreshing the screen), the config value is updated with the second users change and the first change is lost.

Steps To Reproduce

  1. User 1 open right drawer with a feature flag and config
  2. Another user open same config value
  3. User 1 makes a change
  4. User 2 makes a different change
  5. User 1 change is lost

Expected behavior

Add an optomistic concurrency check (timestamp or concurrency key), and reject the 2nd change until the screen is reloaded and the user has the changes made between them loading the screen and wanting to save - they can then make the changes again to the latest data.

Screenshots

No response

rfriend-zilo avatar Feb 26 '24 13:02 rfriend-zilo

This should be pretty easy to do in the FE by just checking the flag state id before saving the flag?

dabeeeenster avatar Feb 26 '24 16:02 dabeeeenster

I'm not too clear on what you mean here @dabeeeenster, the ids would be the same? I guess what could happen is it could get the feature before saving and compare a last updated timestamp, though the correct behaviour for this scenario is not clear.

I wonder if this would naturally solved by feature flag versioning, with this we'd have a saved reference of each version. In the above scenario the user can compare versions, rollback or just combine the values.

kyle-ssg avatar Mar 13 '24 17:03 kyle-ssg

User A updates a flag whilst user B is looking at the flag. We are versioning all this stuff, so we now have the original value v1 and new value v2 provided by User A.

When User B attempts to persist their change, we could have the FE check the latest version of the flag they are looking at. If they receive v1, they know they are not going to clobber any changes by other users. If they get v2, they know that someone else modified the value while they were looking at it. We can then surface an error/warning.

dabeeeenster avatar Mar 13 '24 17:03 dabeeeenster

One possible UX to implement this is similar to VS Code does when a file has been externally modified:

image

rolodato avatar Jun 04 '24 13:06 rolodato