Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 516ab0a

Browse files
Google APIscopybara-github
authored andcommitted
feat(spanner): A new enum IsolationLevel is added
feat(spanner): A new field `isolation_level` is added to message `.google.spanner.v1.TransactionOptions` docs(spanner): A comment for enum value `READ_LOCK_MODE_UNSPECIFIED` in enum `ReadLockMode` is changed docs(spanner): A comment for enum value `PESSIMISTIC` in enum `ReadLockMode` is changed docs(spanner): A comment for enum value `OPTIMISTIC` in enum `ReadLockMode` is changed PiperOrigin-RevId: 729265828
1 parent 7e791c0 commit 516ab0a

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

google/spanner/v1/transaction.proto

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,19 +361,31 @@ message TransactionOptions {
361361
enum ReadLockMode {
362362
// Default value.
363363
//
364-
// If the value is not specified, the pessimistic read lock is used.
364+
// * If isolation level is `REPEATABLE_READ`, then it is an error to
365+
// specify `read_lock_mode`. Locking semantics default to `OPTIMISTIC`.
366+
// No validation checks are done for reads, except for:
367+
// 1. reads done as part of queries that use `SELECT FOR UPDATE`
368+
// 2. reads done as part of statements with a `LOCK_SCANNED_RANGES`
369+
// hint
370+
// 3. reads done as part of DML statements
371+
// to validate that the data that was served at the snapshot time is
372+
// unchanged at commit time.
373+
// * At all other isolation levels, if `read_lock_mode` is the default
374+
// value, then pessimistic read lock is used.
365375
READ_LOCK_MODE_UNSPECIFIED = 0;
366376

367377
// Pessimistic lock mode.
368378
//
369379
// Read locks are acquired immediately on read.
380+
// Semantics described only applies to `SERIALIZABLE` isolation.
370381
PESSIMISTIC = 1;
371382

372383
// Optimistic lock mode.
373384
//
374385
// Locks for reads within the transaction are not acquired on read.
375386
// Instead the locks are acquired on a commit to validate that
376387
// read/queried data has not changed since the transaction started.
388+
// Semantics described only applies to `SERIALIZABLE` isolation.
377389
OPTIMISTIC = 2;
378390
}
379391

@@ -461,6 +473,38 @@ message TransactionOptions {
461473
bool return_read_timestamp = 6;
462474
}
463475

476+
// `IsolationLevel` is used when setting `isolation_level` for a transaction.
477+
enum IsolationLevel {
478+
// Default value.
479+
//
480+
// If the value is not specified, the `SERIALIZABLE` isolation level is
481+
// used.
482+
ISOLATION_LEVEL_UNSPECIFIED = 0;
483+
484+
// All transactions appear as if they executed in a serial order, even if
485+
// some of the reads, writes, and other operations of distinct transactions
486+
// actually occurred in parallel. Spanner assigns commit timestamps that
487+
// reflect the order of committed transactions to implement this property.
488+
// Spanner offers a stronger guarantee than serializability called external
489+
// consistency. For further details, please refer to
490+
// https://cloud.google.com/spanner/docs/true-time-external-consistency#serializability.
491+
SERIALIZABLE = 1;
492+
493+
// All reads performed during the transaction observe a consistent snapshot
494+
// of the database, and the transaction will only successfully commit in the
495+
// absence of conflicts between its updates and any concurrent updates that
496+
// have occurred since that snapshot. Consequently, in contrast to
497+
// `SERIALIZABLE` transactions, only write-write conflicts are detected in
498+
// snapshot transactions.
499+
//
500+
// This isolation level does not support Read-only and Partitioned DML
501+
// transactions.
502+
//
503+
// When `REPEATABLE_READ` is specified on a read-write transaction, the
504+
// locking semantics default to `OPTIMISTIC`.
505+
REPEATABLE_READ = 2;
506+
}
507+
464508
// Required. The type of transaction.
465509
oneof mode {
466510
// Transaction may write.
@@ -500,6 +544,9 @@ message TransactionOptions {
500544
// partitioned-dml transactions, otherwise the API will return an
501545
// `INVALID_ARGUMENT` error.
502546
bool exclude_txn_from_change_streams = 5;
547+
548+
// Isolation level for the transaction.
549+
IsolationLevel isolation_level = 6;
503550
}
504551

505552
// A transaction.

0 commit comments

Comments
 (0)