Skip to content

Prevent lost updates with optimistic locking - #108

Merged
Pan14ek merged 1 commit into
mainfrom
bug/aggregate-lost-updates
Jul 19, 2026
Merged

Prevent lost updates with optimistic locking#108
Pan14ek merged 1 commit into
mainfrom
bug/aggregate-lost-updates

Conversation

@Pan14ek

@Pan14ek Pan14ek commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Purpose

Prevent silent lost updates across mutable backend aggregates by requiring an ETag-based version precondition on mutations.

Type

  • Bug fix

Changes

  • Add JPA version columns and API-visible versions for Event, Task, Lobby, User, Plan, and notification preferences.
  • Require quoted If-Match headers for PATCH, Plan PUT, deletes, and lobby member removal; map missing, malformed, and stale conditions to 428, 400, and 409.
  • Persist default notification preferences on first GET so clients receive an initial ETag.
  • Add unit coverage for stale Event and Task mutations and precondition parsing.

Expected result

Concurrent stale writes no longer silently overwrite a newer mutation; the stale request receives an RFC 7807 409 response.

How to use and test

  1. Read a resource representation and retain its version or ETag.
  2. Send the quoted version in the If-Match request header when mutating it.
  3. Retry after a fresh read when a stale request returns 409.
  4. Run ./gradlew test.

Verification

  • ./gradlew test passed before the final focused test additions.
  • Checkstyle was run after resolving parameter-count issues, but the final combined quality gate was not completed.
  • PostgreSQL/Testcontainers race coverage for CONC-T01-T04 remains required.

Metrics

All fitness and Sonar metrics: not measured.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
64.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@Pan14ek
Pan14ek marked this pull request as ready for review July 19, 2026 10:38
@Pan14ek
Pan14ek merged commit 277a922 into main Jul 19, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant