Company
Date Published
Author
Charlie Custer
Word count
873
Language
English
Hacker News points
None

Summary

The article, written by Charlie Custer, discusses handling transaction failures in CockroachDB, emphasizing its ACID transactional guarantees which ensure consistency through serializable isolation. However, these guarantees can lead to transaction failures, such as deadlocks, where two transactions compete for the same resource, resulting in one being canceled and returning a 40001 error code. CockroachDB can automatically retry some transactions, particularly single SQL statements or batched statements, but others require application-level logic to handle retries, especially when additional application-side processing is involved. The article advises using ORM or database driver documentation for retry methods, or writing custom retry logic if none exist. An example of implementing transaction retries using node.js and node-postgres is provided, illustrating the practical application of these concepts, and further resources for learning are available through Cockroach University.