Skip to content

Commit 922f1f3

Browse files
Google APIscopybara-github
authored andcommitted
feat: Update transaction.proto to include different lock modes
PiperOrigin-RevId: 481838475
1 parent 6511fde commit 922f1f3

1 file changed

Lines changed: 39 additions & 10 deletions

File tree

google/spanner/v1/transaction.proto

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
5656
//
5757
// Queries on change streams must be performed with the snapshot read-only
5858
// transaction mode, specifying a strong read. Please see
59-
// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong] for more details.
59+
// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong]
60+
// for more details.
6061
//
6162
// 3. Partitioned DML. This type of transaction is used to execute
6263
// a single Partitioned DML statement. Partitioned DML partitions
@@ -192,7 +193,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
192193
// Queries on change streams (see below for more details) must also specify
193194
// the strong read timestamp bound.
194195
//
195-
// See [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong].
196+
// See
197+
// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong].
196198
//
197199
// Exact staleness:
198200
//
@@ -213,7 +215,9 @@ option ruby_package = "Google::Cloud::Spanner::V1";
213215
// equivalent boundedly stale concurrency modes. On the other hand,
214216
// boundedly stale reads usually return fresher results.
215217
//
216-
// See [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp] and
218+
// See
219+
// [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp]
220+
// and
217221
// [TransactionOptions.ReadOnly.exact_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact_staleness].
218222
//
219223
// Bounded staleness:
@@ -243,7 +247,9 @@ option ruby_package = "Google::Cloud::Spanner::V1";
243247
// which rows will be read, it can only be used with single-use
244248
// read-only transactions.
245249
//
246-
// See [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness] and
250+
// See
251+
// [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness]
252+
// and
247253
// [TransactionOptions.ReadOnly.min_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min_read_timestamp].
248254
//
249255
// Old read timestamps and garbage collection:
@@ -349,14 +355,34 @@ message TransactionOptions {
349355
// Message type to initiate a read-write transaction. Currently this
350356
// transaction type has no options.
351357
message ReadWrite {
358+
// `ReadLockMode` is used to set the read lock mode for read-write
359+
// transactions.
360+
enum ReadLockMode {
361+
// Default value.
362+
//
363+
// If the value is not specified, the pessimistic read lock is used.
364+
READ_LOCK_MODE_UNSPECIFIED = 0;
352365

353-
}
366+
// Pessimistic lock mode.
367+
//
368+
// Read locks are acquired immediately on read.
369+
PESSIMISTIC = 1;
354370

355-
// Message type to initiate a Partitioned DML transaction.
356-
message PartitionedDml {
371+
// Optimistic lock mode.
372+
//
373+
// Locks for reads within the transaction are not acquired on read.
374+
// Instead the locks are acquired on a commit to validate that
375+
// read/queried data has not changed since the transaction started.
376+
OPTIMISTIC = 2;
377+
}
357378

379+
// Read lock mode for the transaction.
380+
ReadLockMode read_lock_mode = 1;
358381
}
359382

383+
// Message type to initiate a Partitioned DML transaction.
384+
message PartitionedDml {}
385+
360386
// Message type to initiate a read-only transaction.
361387
message ReadOnly {
362388
// How to choose the timestamp for the read-only transaction.
@@ -421,7 +447,8 @@ message TransactionOptions {
421447
}
422448

423449
// If true, the Cloud Spanner-selected read timestamp is included in
424-
// the [Transaction][google.spanner.v1.Transaction] message that describes the transaction.
450+
// the [Transaction][google.spanner.v1.Transaction] message that describes
451+
// the transaction.
425452
bool return_read_timestamp = 6;
426453
}
427454

@@ -475,7 +502,8 @@ message Transaction {
475502
// [Read][google.spanner.v1.Spanner.Read] or
476503
// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs.
477504
//
478-
// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more information about transactions.
505+
// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more
506+
// information about transactions.
479507
message TransactionSelector {
480508
// If no fields are set, the default is a single use transaction
481509
// with strong concurrency.
@@ -490,7 +518,8 @@ message TransactionSelector {
490518

491519
// Begin a new transaction and execute this read or SQL query in
492520
// it. The transaction ID of the new transaction is returned in
493-
// [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction], which is a [Transaction][google.spanner.v1.Transaction].
521+
// [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction],
522+
// which is a [Transaction][google.spanner.v1.Transaction].
494523
TransactionOptions begin = 3;
495524
}
496525
}

0 commit comments

Comments
 (0)