If given a consul KV key a/key, where there are multiple agent server instances running, what happens if:
Two requests A (set value to val-a) and B (set value to val-b) are made to the create key endpoint without making use of the parameters cas or acquire in order to update the same key a/key:
- If A and B are made in parallel can the key's value become corrupted?
- Or if A comes slightly before B can the final value still become
val-a?
The data will not be corrupted if Consul receives two write requests at the same time. The write requests would be processed serially by the leader, so the value of
a/keywould become eitherval-aorval-b, whichever is processed last.You can find details on how Consul writes data in Consul's Consensus Protocol documentation.