mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-13 04:51:00 +08:00
Add resource_version-based optimistic concurrency control to the persistence layer. Every write now requires an explicit WriteCondition (MustCreate or MatchResourceVersion), enforced at compile time by gating unconditional put/put_message behind #[cfg(test)]. - Add WriteCondition enum and put_if for conditional writes - Add update_message_cas for atomic read-modify-write operations - Add list_messages/list_messages_with_selector helpers that hydrate resource_version from authoritative DB rows - Convert all production write paths to CAS-aware methods - Gate put/put_message behind #[cfg(test)] to prevent non-CAS writes - Use structured PersistenceError::UniqueViolation matching instead of string matching for duplicate detection - Hydrate resource_version from WriteResult directly on creates, eliminating unnecessary read-after-write round trips Signed-off-by: Derek Carr <decarr@redhat.com>
6 lines
273 B
SQL
6 lines
273 B
SQL
-- Add resource_version column for optimistic concurrency control
|
|
ALTER TABLE objects ADD COLUMN resource_version BIGINT NOT NULL DEFAULT 1;
|
|
|
|
-- Backfill existing rows with resource_version = 1
|
|
-- (DEFAULT clause handles this automatically for existing rows in PostgreSQL)
|