Two staff members can open the same customer record and each make a reasonable edit. If the application blindly saves the whole form, the later request may overwrite changes the second person never saw.
Define the conflict policy before choosing a database mechanism. Some fields can merge independently; others represent a business decision that requires the user to review the newer state.
Distinguish stale forms from simultaneous transactions
A form can become stale over minutes even when each database write is individually transactional. A transaction alone does not tell the server whether the user edited the current record or an older version.
One common design is optimistic concurrency: the update includes the version it was based on, and the server applies it only if that version remains current. Other workflows may use locking or append-only changes. Review the actual consistency requirement and the PostgreSQL transaction-isolation documentation before selecting a mechanism.
Test a fictional service-customer edit
Suppose Priya and Omar open customer version 7. Priya changes the callback number. Omar changes the preferred contact time from a form still showing the old number.
Under whole-record last-write-wins, Omar's save may restore the old number. Under a version-check policy, Omar receives a conflict and can compare the latest record with his draft. Under a carefully defined field-level update, both independent changes may survive, but the application must still handle two edits to the same field.
Test independent fields, the same field, a deleted record, an access change, and a retry after an interrupted response. Inspect the final stored record and audit events. The desired result should follow the chosen policy rather than whichever request arrived last by chance.
Make conflicts actionable in the interface
Preserve the user's draft when a conflict occurs. Show the relevant changed fields and offer a clear retry or review path. A generic save failure forces users to retype work and can encourage repeated submissions.
For consequential state changes, such as approving a refund or closing a request, require the current state expected by the action. A valid edit permission does not mean every transition remains valid after another user acts.
The tradeoff is friction versus silent loss. Version checks create occasional conflict handling work but make stale edits visible. Last-write-wins can be acceptable for explicitly low-consequence preferences, provided the product accepts that behaviour rather than applying it accidentally to every record.
The StackFlight product account supplies related SaaS context. Priya and Omar's record is a fictional concurrency exercise, not a production incident.
Questions about concurrent edits
Does wrapping the update in a transaction solve stale forms?
Not necessarily. The server needs a way to detect that the submitted edit was based on an older state or a policy that safely handles it.
Should every conflict be merged automatically?
No. Independent fields may be mergeable, but competing decisions or same-field edits often need explicit review.
What should a regression case capture?
Record the starting version, both edits, request order, expected policy, final record, and audit history. Bring it to a data-consistency review.