The SAVEPOINT cockroach_restart statement defines the intent to retry transactions using the CockroachDB-provided function for client-side transaction retries. For more information, see Transaction Retries.

CockroachDB’s SAVEPOINT implementation only supports the cockroach_restart savepoint and does not support all savepoint functionality, such as nested transactions.



Required Privileges

No privileges are required to create a savepoint. However, privileges are required for each statement within a transaction.


Create Savepoint

After you BEGIN the transaction, you must create the savepoint to identify that if the transaction contends with another transaction for resources and “loses”, you intend to use the function for client-side transaction retries.


> SAVEPOINT cockroach_restart;

> UPDATE products SET inventory = 0 WHERE sku = '8675309';

> INSERT INTO orders (customer, sku, status) VALUES (1001, '8675309', 'new');

> RELEASE SAVEPOINT cockroach_restart;


When using SAVEPOINT, your application must also include functions to execute retries with ROLLBACK TO SAVEPOINT cockroach_restart.

See Also

Yes No