Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a0cffe-206f-7323-89d3-b20ca4cf4bf9
3.6 KiB
P01 Optimistic Concurrency Rejection
Definition
A client attempts to update a resource by providing a version identifier. The server rejects the update with a conflict error if the provided version identifier does not match the server's current version of the resource.
Candidate Identity
P01, family: Concurrency Control, scale: Interaction, status: draft, maturity: hypothesis, evidence_kind: primary
Context
A client holds a local representation of a resource, including a version identifier obtained from a previous read operation. The client then attempts to modify this resource and send the updated state to the server.
Problem
Without a mechanism to detect concurrent modifications, a client's update based on an outdated view could inadvertently overwrite changes made by another client, leading to data loss or inconsistent states.
Forces
- Preventing data loss: The system needs to ensure that changes made by one client are not silently overwritten by another client's update based on an older state.
- Client autonomy: Clients should be able to propose updates without constant server synchronization, allowing for disconnected work or reduced network traffic.
Solution
When a client sends an update request for a resource, it includes a resourceVersion (C01). The server compares this resourceVersion with its current version of the resource. If they do not match, indicating that the resource has been modified since the client last read it, the server rejects the update with a 409 Conflict error (C01, C02).
Dynamics
- Client fetches resource R, receiving
resourceVersionV1. - Client modifies R locally.
- Another client (or process) updates R on the server, changing its
resourceVersionto V2. - Client attempts to update R, sending its modified R along with
resourceVersionV1. - Server compares V1 with its current
resourceVersionV2. - Since V1 != V2, the server returns a
409 Conflicterror.
Resulting Context
The client receives a 409 Conflict error, indicating that its proposed update could not be applied due to a concurrent modification. The server's state remains unchanged.
Consequences
- Data integrity: Prevents accidental overwrites of concurrent changes.
- Client responsibility: The client is informed of the conflict and must decide how to resolve it (e.g., fetch the latest version, reapply changes, or notify the user).
- Increased complexity for clients: Clients must implement logic to handle
409 Conflictresponses, which often involves re-fetching the resource and re-attempting the update.
Failure Modes
- Client ignores conflict: If the client does not handle the
409 Conflicterror, the update will simply fail without resolution. - Incorrect versioning: If the
resourceVersionmechanism is flawed or not consistently applied, conflicts might not be detected.
Source Evidence
- C01: "If a client submits an update to a resource using a
resourceVersionthat is no longer current, the Kubernetes API server responds with a409 Conflicterror." (SRC-0008, Updates to existing resources, second paragraph) - C02: "The Kubernetes API server uses a
409 ConflictHTTP status code to indicate that a client's proposed update is based on an outdatedresourceVersion." (SRC-0008, Updates to existing resources, second paragraph)
Counterevidence
None.
Review Notes
The evidence clearly describes a server-side mechanism for optimistic concurrency control using a version identifier and a specific HTTP status code for rejection.
Known uses
Known uses: unknown Recurrence: unknown
{"candidates": [{"id": "P01", "known_uses": [], "recurrence": "unknown"}]}