Skip to content

Add optimistic locking based on versions #568

Description

@solenuk

As a developer I want to add optimistic versioning to TaskBody so that two concurrent updates to the same task can't silently overwrite each other.

Assumptions & Constraints

  • Uses the standard JPA version field, a long column that increments on every update.
  • This is purely a concurrency safeguard, it doesn't change any business rule or existing field.
  • A concurrent update conflict should surface as a clear error to the caller.

Preconditions

  1. TaskBody entity and its migration already exist.

Business rules

  1. Every update to a TaskBody row increments its version.
  2. An update based on a stale version is rejected, not silently applied.
  3. Creating a new TaskBody starts at the initial version, no special handling needed there.

Acceptance Criteria

  • task_bodies has a version column, not null, defaulting to 0.
  • The entity has a version field mapped to that column.
  • Updating a TaskBody with a stale version results in a clear, mapped error response.
  • A normal, non concurrent update still works exactly as before.

Out of scope

  • Any UI handling for a version conflict, that's a separate concern once this exists.
  • Adding versioning to any entity other than TaskBody.

Epic link
Epic #6 - EPIC: Tasks

Tasks

  • Add the version column migration for task_bodies.
  • Add the version field to TaskBody.
  • Confirm a normal update still works and a stale update is rejected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions