Common symptoms
Transaction retry errors (SQLSTATE 40001)
Under SERIALIZABLE isolation, a transaction whose reads are invalidated by a concurrent committed write is aborted with a transaction retry error so that no lost update or write skew can occur. This is normal and expected under contention, not a defect. The application must wrap every transaction in a retry loop that re-runs the whole transaction with increasing backoff:
Hot-row contention on a popular SKU
When many writers converge on one SKU’s inventory row, they serialize on that row’s leaseholder and the losers take retries and back off, so throughput on that item flattens even while the rest of the cluster is idle. Reach for the tools in order: firstSELECT ... FOR UPDATE to queue contenders instead of letting them thrash, then counter sharding for genuine flash-sale SKUs.
See: https://www.cockroachlabs.com/docs/stable/select-for-update
Enabling changefeeds
Changefeeds read from rangefeeds, which must be enabled at the cluster level before a changefeed can be created:Guarded updates affecting zero rows
A reservation decrement or a state transition is written as anUPDATE whose WHERE clause encodes the precondition (enough stock, or the expected current state). When the precondition does not hold, the statement matches zero rows and makes no change. This is the designed rejection path. Return the appropriate business response (OUT_OF_STOCK, or reject the transition) and do not treat it as a database fault to retry.
CHECK constraint violations
Constraints such as CHECK (available >= 0) and CHECK (refunded_amount <= amount) are backstops: they make an invariant physically unbreakable even if application logic is wrong. A violation means a code path attempted an illegal write and the database refused it. Investigate the offending path; the constraint did its job.
Known limitations
These are properties of the system to design within, not bugs to fix.-
A single logical hot row has a throughput ceiling. Distribution does not remove it. A row has one leaseholder, and all writes to it serialize there.
SELECT ... FOR UPDATEand keeping transactions tiny raise the ceiling; only splitting the logical row into multiple physical sub-rows (counter sharding) raises aggregate write throughput past the single-row limit. -
Row-Level TTL deletion is background and batched, not real-time. Expired rows are removed by a periodic job, so a row can persist past its expiration until the next run. Never let correctness depend on TTL having already deleted a row: for example, compute live inventory availability by filtering
expires_at > now()at read time, and use TTL only to garbage-collect. See https://www.cockroachlabs.com/docs/stable/row-level-ttl -
Changefeed delivery is at-least-once with per-key ordering only. Messages for a single key arrive in order, but duplicates are possible and ordering across different keys is not guaranteed. Every consumer must be idempotent (dedupe by key plus
updated) and must not assume a global order. See https://www.cockroachlabs.com/docs/stable/change-data-capture-overview
[!NOTE] Verify version- and release-specific behavior Cluster setting names, default TTL scheduling, changefeed options, and feature availability can change between releases. Confirm anything version-sensitive against the documentation for your target CockroachDB version before relying on it, using the official links above.

