dcapwell commented on code in PR #4572: URL: https://github.com/apache/cassandra/pull/4572#discussion_r2744474591
########## doc/modules/cassandra/pages/developing/cql/dml.adoc: ########## @@ -474,3 +474,96 @@ partly applied. Use the `COUNTER` option for batched counter updates. Unlike other updates in Cassandra, counter updates are not idempotent. + +=== BATCH vs Transactions + +While BATCH statements provide atomicity for multiple operations, they have limitations compared to Accord transactions. Understanding the differences helps you choose the right approach for your use case. Review Comment: Updated ########## doc/modules/cassandra/pages/developing/cql/transactions-examples.adoc: ########## @@ -0,0 +1,418 @@ += Accord Transaction Design Patterns +:page-nav-title: Transaction Patterns + +This page provides advanced design patterns for Accord transactions. These patterns solve common distributed system challenges that were difficult or impossible to address with eventual consistency. + +For basic syntax, getting started, and migration guides, see xref:developing/cql/transactions.adoc[Accord Transactions]. + +== Pattern: Synchronous Unique Constraints + +Cassandra's primary key enforces uniqueness, but what if you need uniqueness on a non-primary-key column like `email` or `username`? This pattern uses sidecar index tables to enforce multiple unique constraints atomically. Review Comment: Updated ########## doc/modules/cassandra/pages/developing/cql/transactions.adoc: ########## @@ -0,0 +1,985 @@ += Accord Transactions +:page-nav-title: Transactions + +Accord provides strong consistency and ACID guarantees for Cassandra operations. +When enabled on a table, **all CQL operations automatically execute through Accord** - no code changes required. +For complex multi-step operations, explicit transaction syntax (`BEGIN TRANSACTION ... COMMIT TRANSACTION`) allows you to read, apply conditions, and write atomically across multiple partitions and tables. + +== Overview + +=== Key Benefits + +* **Automatic Strong Consistency**: Normal CQL reads and writes become linearizable when `transactional_mode='full'` +* **ACID Guarantees**: Atomicity, Consistency, Isolation, and Durability across multiple operations +* **Multi-Partition Consistency**: Coordinate updates across different partition keys +* **Multi-Table Support**: Update multiple tables atomically within a single transaction +* **Complex Business Logic**: Support for conditional operations with multiple steps + +=== When to Use Explicit Transactions + +While normal CQL operations are automatically transactional with `transactional_mode='full'`, use explicit `BEGIN TRANSACTION ... COMMIT TRANSACTION` syntax when you need: + +* **Read-Modify-Write Patterns**: Check a condition before making changes +* **Complex Business Logic**: Multi-step operations that must be atomic +* **Cross-Partition Operations**: Updates that span multiple partition keys +* **Multi-Table Atomicity**: Ensure related changes across tables succeed or fail together + +=== Safety & Consistency + +Accord ensures data integrity through: + +* **Snapshot Isolation**: Each transaction sees a consistent snapshot of data Review Comment: Updated -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

