Skip to content

Commit

Permalink
feat: Update transaction.proto to include different lock modes
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 481838475
  • Loading branch information
Google APIs authored and Copybara-Service committed Oct 18, 2022
1 parent 6511fde commit 922f1f3
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions google/spanner/v1/transaction.proto
Expand Up @@ -56,7 +56,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
//
// Queries on change streams must be performed with the snapshot read-only
// transaction mode, specifying a strong read. Please see
// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong] for more details.
// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong]
// for more details.
//
// 3. Partitioned DML. This type of transaction is used to execute
// a single Partitioned DML statement. Partitioned DML partitions
Expand Down Expand Up @@ -192,7 +193,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
// Queries on change streams (see below for more details) must also specify
// the strong read timestamp bound.
//
// See [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong].
// See
// [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong].
//
// Exact staleness:
//
Expand All @@ -213,7 +215,9 @@ option ruby_package = "Google::Cloud::Spanner::V1";
// equivalent boundedly stale concurrency modes. On the other hand,
// boundedly stale reads usually return fresher results.
//
// See [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp] and
// See
// [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp]
// and
// [TransactionOptions.ReadOnly.exact_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact_staleness].
//
// Bounded staleness:
Expand Down Expand Up @@ -243,7 +247,9 @@ option ruby_package = "Google::Cloud::Spanner::V1";
// which rows will be read, it can only be used with single-use
// read-only transactions.
//
// See [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness] and
// See
// [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness]
// and
// [TransactionOptions.ReadOnly.min_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min_read_timestamp].
//
// Old read timestamps and garbage collection:
Expand Down Expand Up @@ -349,14 +355,34 @@ message TransactionOptions {
// Message type to initiate a read-write transaction. Currently this
// transaction type has no options.
message ReadWrite {
// `ReadLockMode` is used to set the read lock mode for read-write
// transactions.
enum ReadLockMode {
// Default value.
//
// If the value is not specified, the pessimistic read lock is used.
READ_LOCK_MODE_UNSPECIFIED = 0;

}
// Pessimistic lock mode.
//
// Read locks are acquired immediately on read.
PESSIMISTIC = 1;

// Message type to initiate a Partitioned DML transaction.
message PartitionedDml {
// Optimistic lock mode.
//
// Locks for reads within the transaction are not acquired on read.
// Instead the locks are acquired on a commit to validate that
// read/queried data has not changed since the transaction started.
OPTIMISTIC = 2;
}

// Read lock mode for the transaction.
ReadLockMode read_lock_mode = 1;
}

// Message type to initiate a Partitioned DML transaction.
message PartitionedDml {}

// Message type to initiate a read-only transaction.
message ReadOnly {
// How to choose the timestamp for the read-only transaction.
Expand Down Expand Up @@ -421,7 +447,8 @@ message TransactionOptions {
}

// If true, the Cloud Spanner-selected read timestamp is included in
// the [Transaction][google.spanner.v1.Transaction] message that describes the transaction.
// the [Transaction][google.spanner.v1.Transaction] message that describes
// the transaction.
bool return_read_timestamp = 6;
}

Expand Down Expand Up @@ -475,7 +502,8 @@ message Transaction {
// [Read][google.spanner.v1.Spanner.Read] or
// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs.
//
// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more information about transactions.
// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more
// information about transactions.
message TransactionSelector {
// If no fields are set, the default is a single use transaction
// with strong concurrency.
Expand All @@ -490,7 +518,8 @@ message TransactionSelector {

// Begin a new transaction and execute this read or SQL query in
// it. The transaction ID of the new transaction is returned in
// [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction], which is a [Transaction][google.spanner.v1.Transaction].
// [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction],
// which is a [Transaction][google.spanner.v1.Transaction].
TransactionOptions begin = 3;
}
}

0 comments on commit 922f1f3

Please sign in to comment.