Options to use for transactions.
| JSON representation |
|---|
{ "excludeTxnFromChangeStreams" : boolean , "isolationLevel" : enum ( |
excludeTxnFromChangeStreams
boolean
When excludeTxnFromChangeStreams
is set to true
, it prevents read or write transactions from being tracked in change streams.
-
If the DDL option
allow_txn_exclusionis set totrue, then the updates made within this transaction aren't recorded in the change stream. -
If you don't set the DDL option
allow_txn_exclusionor if it's set tofalse, then the updates made within this transaction are recorded in the change stream.
When excludeTxnFromChangeStreams
is set to false
or not set, modifications from this transaction are recorded in all change streams that are tracking columns modified by these transactions.
The excludeTxnFromChangeStreams
option can only be specified for read-write or partitioned DML transactions, otherwise the API returns an INVALID_ARGUMENT
error.
isolationLevel
enum (
IsolationLevel
)
Isolation level for the transaction.
mode
. Required. The type of transaction. mode
can be only one of the following:readWrite
object (
ReadWrite
)
Transaction may write.
Authorization to begin a read-write transaction requires spanner.databases.beginOrRollbackReadWriteTransaction
permission on the session
resource.
partitionedDml
object (
PartitionedDml
)
Partitioned DML transaction.
Authorization to begin a Partitioned DML transaction requires spanner.databases.beginPartitionedDmlTransaction
permission on the session
resource.
readOnly
object (
ReadOnly
)
Transaction does not write.
Authorization to begin a read-only transaction requires spanner.databases.beginReadOnlyTransaction
permission on the session
resource.
ReadWrite
Message type to initiate a read-write transaction. Currently this transaction type has no options.
| JSON representation |
|---|
{ "multiplexedSessionPreviousTransactionId" : string } |
| Fields | |
|---|---|
multiplexedSessionPreviousTransactionId
|
Optional. Clients should pass the transaction ID of the previous transaction attempt that was aborted if this transaction is being executed on a multiplexed session. A base64-encoded string. |
PartitionedDml
This type has no fields.
Message type to initiate a Partitioned DML transaction.
ReadOnly
Message type to initiate a read-only transaction.
| JSON representation |
|---|
{ "returnReadTimestamp" : boolean , // Union field |
strong
boolean
sessions.read at a timestamp where all previously committed transactions are visible.
maxStaleness
string (
Duration
format)
sessions.read data at a timestamp >= NOW - maxStaleness
seconds. Guarantees that all writes that have committed more than the specified number of seconds ago are visible. Because Cloud Spanner chooses the exact timestamp, this mode works even if the client's local clock is substantially skewed from Cloud Spanner commit timestamps.
Useful for reading the freshest data available at a nearby replica, while bounding the possible staleness if the local replica has fallen behind.
Note that this option can only be used in single-use transactions.
A duration in seconds with up to nine fractional digits, ending with ' s
'. Example: "3.5s"
.
exactStaleness
string (
Duration
format)
Executes all reads at a timestamp that is exactStaleness
old. The timestamp is chosen soon after the read is started.
Guarantees that all writes that have committed more than the specified number of seconds ago are visible. Because Cloud Spanner chooses the exact timestamp, this mode works even if the client's local clock is substantially skewed from Cloud Spanner commit timestamps.
Useful for reading at nearby replicas without the distributed timestamp negotiation overhead of maxStaleness
.
A duration in seconds with up to nine fractional digits, ending with ' s
'. Example: "3.5s"
.
IsolationLevel
IsolationLevel
is used when setting the isolation level
for a transaction.
| Enums | |
|---|---|
ISOLATION_LEVEL_UNSPECIFIED
|
Default value. If the value is not specified, the |
SERIALIZABLE
|
All transactions appear as if they executed in a serial order, even if some of the reads, writes, and other operations of distinct transactions actually occurred in parallel. Spanner assigns commit timestamps that reflect the order of committed transactions to implement this property. Spanner offers a stronger guarantee than serializability called external consistency. For more information, see TrueTime and external consistency . |
REPEATABLE_READ
|
All reads performed during the transaction observe a consistent snapshot of the database, and the transaction is only successfully committed in the absence of conflicts between its updates and any concurrent updates that have occurred since that snapshot. Consequently, in contrast to This isolation level does not support read-only and partitioned DML transactions. When |

