Persistence and Concurrency in Applications
-
Beginning, Committing, and Rolling Back a Transaction
A database transaction groups work under a boundary whose changes are committed together or rolled back under the database's rules.
-
Autocommit and Multi-Statement Work
Autocommit typically gives each ordinary statement its own transaction when no explicit transaction is active. A multi-step promise often needs a deliberate boundary.
-
A Savepoint Inside a Transaction
A savepoint marks a position an application can roll back to while keeping earlier work inside the same uncommitted transaction.
-
Reading Committed State from Another Transaction
A database's isolation rules determine which other writes a query can observe, including whether they must have committed.
-
Choosing a Consistent Read Snapshot for a Report
A report with several queries may need all observations to refer to one database snapshot. Select an isolation mode or query shape that provides it.
-
A Read–Modify–Write Sequence and Lost Updates
Separate reads and writes can cause concurrent workers to overwrite each other's changes if the operation lacks a suitable coordination rule.
-
Updating Only the Version Previously Observed
A conditional update can require both the row identity and the previously observed version. This makes an intervening edit observable to the caller.
-
Locking a Row Before a Dependent Update
A transaction can use a supported row lock when it must make a decision from a row and protect that decision while changing dependent state.
-
Taking Locks in a Consistent Order
Transactions accessing multiple resources can reduce circular waits by acquiring shared types of locks in a consistent order where their design permits.
-
Retrying a Transaction from Its Beginning
Some concurrency failures mean the whole transaction must be retried. A retry should repeat the reads and decisions belonging to that transaction.
-
Recording a Repeatable Request Identity
A stable request ID can let a transaction recognize and reuse the result of an ordinary repeated submission under an explicit policy.
-
Saving Data and a Notification Intent Together
A database transaction can persist a state change and an event record describing work another process should deliver later.
-
Adding an Index for a Query Pattern
An index can reduce access work for selected queries. It also adds storage and maintenance for writes.
-
Using Ordered Lookup to Answer a Range Query
An index with compatible ordering can make it possible to find the beginning of a range and scan relevant entries.
-
Choosing Returned Columns for an Operational Query
The columns a query returns can affect data transfer, object construction, and which access paths are useful.
-
Enforcing Uniqueness Across Concurrent Inserts
Checking for an existing row before inserting one can be useful feedback. Durable uniqueness needs coordination at the storage boundary.
-
Resolving a Conflict During an Insert
A database may offer an operation that handles a conflicting unique key by skipping or applying a defined update, depending on syntax and policy.
-
Keeping External Work Out of a Long Transaction
A short transaction can record a decision and allow slow external work to occur afterward, provided the intended workflow accounts for failures.
-
Handling a Failed Transaction Before Continuing
After a statement failure, the transaction may need rollback before further ordinary work under the database's rules.
-
Committing State Before Rendering a Success Result
A response should represent the final state promised to callers. A provisional write inside one transaction does not yet establish that state.
-
Checkpointing a Batched Database Import
A batched import can record its last fully committed input position so a resumed run does not skip or duplicate work.
-
Whole Import and Batch-Level Commit Contracts
An import can require all input to commit together or allow completed batches to survive a later error. Each choice changes what success and recovery mean.
-
Reading Your Own Edits Before Publication
Within a transaction, reads can see that transaction's own changes under ordinary database rules while other transactions follow their visibility contract.
-
Reading Data After an Asynchronous Write Request
A request can be accepted before work is committed. Specify which outcome proves the record is readable under the intended consistency guarantees.
-
Omitted and Null Fields in a Partial Update
A partial update can interpret omitted fields as unchanged and explicit null as a deliberate clear when permitted by the schema.
-
Claiming Work from a Shared Database Queue
A shared queue needs an atomic claim decision so two workers do not both treat one pending row as their exclusive work.
-
Keeping a Stable Public Address Across Revisions
A durable resource can have one stable public address and several stored revisions, with application state selecting which revision is shown.
-
Effective Time and Recorded Time
An event can become effective at one time and be recorded by a system later. Store both when readers need to answer both questions.
-
A Deterministic Test for Concurrent Database Behavior
A useful concurrency test coordinates workers at known points instead of assuming their operations overlap based on timing alone.
-
Using Counts and Sample Reads to Check Persisted State
A consistency check can combine totals, stable identities, relationships, and a known example to verify an operation's effects.