You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rollback-transaction.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ toc: false
6
6
7
7
The `ROLLBACK`[statement](sql-statements.html) aborts the current [transaction](transactions.html), discarding all updates made by statements included in the transaction.
8
8
9
-
When using [client-side transaction retries](transactions.html#client-side-transaction-retries), use `ROLLBACK TO SAVEPOINT cockroach_restart` to handle transaction that need to be retried (identified via the `40001` error code or `retry transaction` string in the error message), and then re-execute the statements in the transaction.
9
+
When using [client-side transaction retries](transactions.html#client-side-transaction-retries), use `ROLLBACK TO SAVEPOINT cockroach_restart` to handle a transaction that needs to be retried (identified via the `40001` error code or `retry transaction` string in the error message), and then re-execute the statements you want the transaction to contain.
10
10
11
11
<divid="toc"></div>
12
12
@@ -22,13 +22,13 @@ No [privileges](privileges.html) are required to rollback a transaction. However
22
22
23
23
| Parameter | Description |
24
24
|-----------|-------------|
25
-
|`TO cockroach_restart`| If using [client-side transaction retries](transactions.html#client-side-transaction-retries), retry the transaction. You should execute this statement when a transaction returns a `40001` / `retry transaction` error. |
25
+
|`TO SAVEPOINT cockroach_restart`| If using [client-side transaction retries](transactions.html#client-side-transaction-retries), retry the transaction. You should execute this statement when a transaction returns a `40001` / `retry transaction` error. |
26
26
27
27
## Example
28
28
29
29
### Rollback a Transaction
30
30
31
-
Typically, your application conditionally executes rollbacks but you can see their behavior by using `ROLLBACK` instead of `COMMIT` directly through SQL.
31
+
Typically, your application conditionally executes rollbacks, but you can see their behavior by using `ROLLBACK` instead of `COMMIT` directly through SQL.
32
32
33
33
~~~sql
34
34
>SELECT*FROM accounts;
@@ -59,10 +59,10 @@ Typically, your application conditionally executes rollbacks but you can see the
59
59
60
60
### Retry a Transaction
61
61
62
-
To use [client-side transaction retries](transactions.html#client-side-transaction-retries), your application must execute `ROLLBACK TO cockroach_restart` after detecting a `40001` / `retry transaction` error.
62
+
To use [client-side transaction retries](transactions.html#client-side-transaction-retries), your application must execute `ROLLBACK TO SAVEPOINT cockroach_restart` after detecting a `40001` / `retry transaction` error.
63
63
64
64
~~~sql
65
-
>ROLLBACK TO cockroach_restart;
65
+
>ROLLBACK TO SAVEPOINT cockroach_restart;
66
66
~~~
67
67
68
68
For examples of retrying transactions in your application, check out the transaction code samples in our [Build an App with CockroachDB](build-an-app-with-cockroachdb.html) tutorials.
Copy file name to clipboardExpand all lines: savepoint.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ The `SAVEPOINT cockroach_restart` statement defines the intent to retry [transac
9
9
{{site.data.alerts.callout_danger}}CockroachDB’s <code>SAVEPOINT</code> implementation only supports the <code>cockroach_restart</code> savepoint and does not support all savepoint functionality, such as nested transactions.{{site.data.alerts.end}}
10
10
11
11
<divid="toc"></div>
12
-
12
+
13
13
## Synopsis
14
14
15
15
{% include sql/diagrams/savepoint.html %}
@@ -38,7 +38,7 @@ After you `BEGIN` the transaction, you must create the savepoint to identify tha
38
38
>COMMIT;
39
39
~~~
40
40
41
-
When using `SAVEPOINT`, your application must also include functions to execute retries with [`ROLLBACK TO cockroach_restart`](rollback-transaction.html#retry-a-transaction).
41
+
When using `SAVEPOINT`, your application must also include functions to execute retries with [`ROLLBACK TO SAVEPOINT cockroach_restart`](rollback-transaction.html#retry-a-transaction).
Copy file name to clipboardExpand all lines: transactions.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,15 +21,15 @@ Each of the following SQL statements control transactions in some way.
21
21
|[`SAVEPOINT cockroach_restart`](savepoint.html)| Declare the transaction as [retryable](#client-side-transaction-retries). This lets you retry the transaction if it doesn't succeed because a higher priority transaction concurrently or recently accessed the same values. |
22
22
|[`RELEASE SAVEPOINT cockroach_restart`](release-savepoint.html)| Commit a [retryable transaction](#client-side-transaction-retries). |
23
23
|[`COMMIT`](commit-transaction.html)| Commit a non-retryable transaction or clear the connection after committing a retryable transaction. |
24
-
|[`ROLLBACK cockroach_restart`](rollback-transaction.html)| Handle [retryable errors](#error-handling) by rolling back a transaction's changes and increasing its priority. |
24
+
|[`ROLLBACK TO SAVEPOINT cockroach_restart`](rollback-transaction.html)| Handle [retryable errors](#error-handling) by rolling back a transaction's changes and increasing its priority. |
25
25
|[`ROLLBACK`](rollback-transaction.html)| Abort a transaction and roll the database back to its state before the transaction began. |
26
26
|[`SHOW TRANSACTION`](show-transaction.html)| Retrieve a transaction's [priority](#transaction-priorities) or [isolation level](#isolation-levels). |
27
27
28
28
## Syntax
29
29
30
30
In CockroachDB, a transaction is set up by surrounding SQL statements with the [`BEGIN`](begin-transaction.html) and [`COMMIT`](commit-transaction.html) statements.
31
31
32
-
To use [client-side transaction retries](#client-side-transaction-retries), you should also include the `SAVEPOINT cockroach_restart`, `ROLLBACK TO cockroach_restart` and `RELEASE SAVEPOINT` statements.
32
+
To use [client-side transaction retries](#client-side-transaction-retries), you should also include the `SAVEPOINT cockroach_restart`, `ROLLBACK TO SAVEPOINT cockroach_restart` and `RELEASE SAVEPOINT` statements.
33
33
34
34
~~~sql
35
35
>BEGIN;
@@ -144,9 +144,9 @@ Implementing client-side retries requires three statements:
144
144
145
145
-[`SAVEPOINT cockroach_restart`](savepoint.html) declares the client's intent to retry the transaction if there are contention errors. It must be executed after `BEGIN` but before the first statement that manipulates a database.
146
146
147
-
-[`ROLLBACK TO cockroach_restart`](rollback-transaction.html#retry-a-transaction) is used when your application detects `40001` / `retry transaction` errors. It provides you a chance to "retry" the transaction by rolling the database's state back to the beginning of the transaction and increasing the transaction's priority.
147
+
-[`ROLLBACK TO SAVEPOINT cockroach_restart`](rollback-transaction.html#retry-a-transaction) is used when your application detects `40001` / `retry transaction` errors. It provides you a chance to "retry" the transaction by rolling the database's state back to the beginning of the transaction and increasing the transaction's priority.
148
148
149
-
After issuing `ROLLBACK TO cockroach_restart`, you must issue any statements you want the transaction to contain. Typically, this means recalculating values and reissuing a similar set of statements to the previous attempt.
149
+
After issuing `ROLLBACK TO SAVEPOINT cockroach_restart`, you must issue any statements you want the transaction to contain. Typically, this means recalculating values and reissuing a similar set of statements to the previous attempt.
150
150
151
151
-[`RELEASE SAVEPOINT cockroach_restart`](release-savepoint.html) commits the transaction. At this point, CockroachDB checks to see if the transaction contends with others for access to the same values; the highest priority transaction succeeds, and the others return `40001` / `retry transaction` errors.
0 commit comments