Getting Started
Tutorial: Building with CleaveDB
ROLLBACK
When an unrecoverable validation error occurs, or business logic requires canceling an in-flight operation, ROLLBACK discards all uncommitted modifications from the Software Transactional Memory buffer.
Manual rollback
Issuing ROLLBACK cancels all buffered writes in the current transaction block:
CleaveQLExample · Aborted write transaction
BEGIN POUR INTO users "t3" {"name": "T3"} ROLLBACKVerifying the state with a subsequent lookup confirms that the document was never written:
CleaveQLExample · Verify aborted write
FIND users "t3"
-- Returns: 0 documents (empty result)Because the transaction was aborted prior to COMMIT, the Write-Ahead Log remains completely clean of the discarded operations.
Automatic rollback on errors
You do not always need to trigger ROLLBACK manually. CleaveDB automatically initiates an internal rollback if any statement in a transaction triggers an error:
- Guard Rule Violations: If a document fails a bucket's
GUARDschema (such as a missing required key or out-of-range value), the entire transaction aborts. - Security Policy Rejections: If a write fails an active
ENFORCE SECURITYpolicy rule, all prior writes in that block roll back. - Syntax or Type Errors: Malformed commands immediately cancel the pending transaction.
