Skip to content

Commit

Permalink
chore: protos for R/W transaction support on multiplexed sessions
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 683879049
  • Loading branch information
Google APIs authored and copybara-github committed Oct 9, 2024
1 parent 8692273 commit 2b6b93b
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
9 changes: 9 additions & 0 deletions google/spanner/v1/commit_response.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ syntax = "proto3";
package google.spanner.v1;

import "google/protobuf/timestamp.proto";
import "google/spanner/v1/transaction.proto";

option csharp_namespace = "Google.Cloud.Spanner.V1";
option go_package = "cloud.google.com/go/spanner/apiv1/spannerpb;spannerpb";
Expand Down Expand Up @@ -47,4 +48,12 @@ message CommitResponse {
// For more information, see
// [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats].
CommitStats commit_stats = 2;

// Clients should examine and retry the commit if any of the following
// reasons are populated.
oneof MultiplexedSessionRetry {
// If specified, transaction has not committed yet.
// Clients must retry the commit with the new precommit token.
MultiplexedSessionPrecommitToken precommit_token = 4;
}
}
21 changes: 21 additions & 0 deletions google/spanner/v1/result_set.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ syntax = "proto3";

package google.spanner.v1;

import "google/api/field_behavior.proto";
import "google/protobuf/struct.proto";
import "google/spanner/v1/query_plan.proto";
import "google/spanner/v1/transaction.proto";
Expand Down Expand Up @@ -53,6 +54,16 @@ message ResultSet {
// Other fields may or may not be populated, based on the
// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
ResultSetStats stats = 3;

// Optional. A precommit token will be included if the read-write transaction
// is on a multiplexed session.
// The precommit token with the highest sequence number from this transaction
// attempt should be passed to the
// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
// This feature is not yet supported and will result in an UNIMPLEMENTED
// error.
MultiplexedSessionPrecommitToken precommit_token = 5
[(google.api.field_behavior) = OPTIONAL];
}

// Partial results from a streaming read or SQL query. Streaming reads and
Expand Down Expand Up @@ -157,6 +168,16 @@ message PartialResultSet {
// This field will also be present in the last response for DML
// statements.
ResultSetStats stats = 5;

// Optional. A precommit token will be included if the read-write transaction
// is on a multiplexed session.
// The precommit token with the highest sequence number from this transaction
// attempt should be passed to the
// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
// This feature is not yet supported and will result in an UNIMPLEMENTED
// error.
MultiplexedSessionPrecommitToken precommit_token = 8
[(google.api.field_behavior) = OPTIONAL];
}

// Metadata about a [ResultSet][google.spanner.v1.ResultSet] or [PartialResultSet][google.spanner.v1.PartialResultSet].
Expand Down
27 changes: 27 additions & 0 deletions google/spanner/v1/spanner.proto
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,16 @@ message ExecuteBatchDmlResponse {
// If all DML statements are executed successfully, the status is `OK`.
// Otherwise, the error status of the first failed statement.
google.rpc.Status status = 2;

// Optional. A precommit token will be included if the read-write transaction
// is on a multiplexed session.
// The precommit token with the highest sequence number from this transaction
// attempt should be passed to the
// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
// This feature is not yet supported and will result in an UNIMPLEMENTED
// error.
MultiplexedSessionPrecommitToken precommit_token = 3
[(google.api.field_behavior) = OPTIONAL];
}

// Options for a PartitionQueryRequest and
Expand Down Expand Up @@ -1225,6 +1235,14 @@ message BeginTransactionRequest {
// transaction, set it on the reads and writes that are part of this
// transaction instead.
RequestOptions request_options = 3;

// Optional. Required for read-write transactions on a multiplexed session
// that commit mutations but do not perform any reads or queries. Clients
// should randomly select one of the mutations from the mutation set and send
// it as a part of this request.
// This feature is not yet supported and will result in an UNIMPLEMENTED
// error.
Mutation mutation_key = 4 [(google.api.field_behavior) = OPTIONAL];
}

// The request for [Commit][google.spanner.v1.Spanner.Commit].
Expand Down Expand Up @@ -1272,6 +1290,15 @@ message CommitRequest {

// Common options for this request.
RequestOptions request_options = 6;

// Optional. If the read-write transaction was executed on a multiplexed
// session, the precommit token with the highest sequence number received in
// this transaction attempt, should be included here. Failing to do so will
// result in a FailedPrecondition error.
// This feature is not yet supported and will result in an UNIMPLEMENTED
// error.
MultiplexedSessionPrecommitToken precommit_token = 9
[(google.api.field_behavior) = OPTIONAL];
}

// The request for [Rollback][google.spanner.v1.Spanner.Rollback].
Expand Down
34 changes: 34 additions & 0 deletions google/spanner/v1/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ syntax = "proto3";

package google.spanner.v1;

import "google/api/field_behavior.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

Expand Down Expand Up @@ -378,6 +379,14 @@ message TransactionOptions {

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

// 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.
// This feature is not yet supported and will result in an UNIMPLEMENTED
// error.
bytes multiplexed_session_previous_transaction_id = 2
[(google.api.field_behavior) = OPTIONAL];
}

// Message type to initiate a Partitioned DML transaction.
Expand Down Expand Up @@ -512,6 +521,17 @@ message Transaction {
// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
// Example: `"2014-10-02T15:01:23.045123456Z"`.
google.protobuf.Timestamp read_timestamp = 2;

// A precommit token will be included in the response of a BeginTransaction
// request if the read-write transaction is on a multiplexed session and
// a mutation_key was specified in the
// [BeginTransaction][google.spanner.v1.BeginTransactionRequest].
// The precommit token with the highest sequence number from this transaction
// attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit]
// request for this transaction.
// This feature is not yet supported and will result in an UNIMPLEMENTED
// error.
MultiplexedSessionPrecommitToken precommit_token = 3;
}

// This message is used to select the transaction in which a
Expand Down Expand Up @@ -539,3 +559,17 @@ message TransactionSelector {
TransactionOptions begin = 3;
}
}

// When a read-write transaction is executed on a multiplexed session,
// this precommit token is sent back to the client
// as a part of the [Transaction] message in the BeginTransaction response and
// also as a part of the [ResultSet] and [PartialResultSet] responses.
message MultiplexedSessionPrecommitToken {
// Opaque precommit token.
bytes precommit_token = 1;

// An incrementing seq number is generated on every precommit token
// that is returned. Clients should remember the precommit token with the
// highest sequence number from the current transaction attempt.
int32 seq_num = 2;
}

0 comments on commit 2b6b93b

Please sign in to comment.