Skip to content

Commit 2b6b93b

Browse files
Google APIscopybara-github
authored andcommitted
chore: protos for R/W transaction support on multiplexed sessions
PiperOrigin-RevId: 683879049
1 parent 8692273 commit 2b6b93b

4 files changed

Lines changed: 91 additions & 0 deletions

File tree

google/spanner/v1/commit_response.proto

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ syntax = "proto3";
1717
package google.spanner.v1;
1818

1919
import "google/protobuf/timestamp.proto";
20+
import "google/spanner/v1/transaction.proto";
2021

2122
option csharp_namespace = "Google.Cloud.Spanner.V1";
2223
option go_package = "cloud.google.com/go/spanner/apiv1/spannerpb;spannerpb";
@@ -47,4 +48,12 @@ message CommitResponse {
4748
// For more information, see
4849
// [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats].
4950
CommitStats commit_stats = 2;
51+
52+
// Clients should examine and retry the commit if any of the following
53+
// reasons are populated.
54+
oneof MultiplexedSessionRetry {
55+
// If specified, transaction has not committed yet.
56+
// Clients must retry the commit with the new precommit token.
57+
MultiplexedSessionPrecommitToken precommit_token = 4;
58+
}
5059
}

google/spanner/v1/result_set.proto

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ syntax = "proto3";
1616

1717
package google.spanner.v1;
1818

19+
import "google/api/field_behavior.proto";
1920
import "google/protobuf/struct.proto";
2021
import "google/spanner/v1/query_plan.proto";
2122
import "google/spanner/v1/transaction.proto";
@@ -53,6 +54,16 @@ message ResultSet {
5354
// Other fields may or may not be populated, based on the
5455
// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
5556
ResultSetStats stats = 3;
57+
58+
// Optional. A precommit token will be included if the read-write transaction
59+
// is on a multiplexed session.
60+
// The precommit token with the highest sequence number from this transaction
61+
// attempt should be passed to the
62+
// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
63+
// This feature is not yet supported and will result in an UNIMPLEMENTED
64+
// error.
65+
MultiplexedSessionPrecommitToken precommit_token = 5
66+
[(google.api.field_behavior) = OPTIONAL];
5667
}
5768

5869
// Partial results from a streaming read or SQL query. Streaming reads and
@@ -157,6 +168,16 @@ message PartialResultSet {
157168
// This field will also be present in the last response for DML
158169
// statements.
159170
ResultSetStats stats = 5;
171+
172+
// Optional. A precommit token will be included if the read-write transaction
173+
// is on a multiplexed session.
174+
// The precommit token with the highest sequence number from this transaction
175+
// attempt should be passed to the
176+
// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
177+
// This feature is not yet supported and will result in an UNIMPLEMENTED
178+
// error.
179+
MultiplexedSessionPrecommitToken precommit_token = 8
180+
[(google.api.field_behavior) = OPTIONAL];
160181
}
161182

162183
// Metadata about a [ResultSet][google.spanner.v1.ResultSet] or [PartialResultSet][google.spanner.v1.PartialResultSet].

google/spanner/v1/spanner.proto

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,16 @@ message ExecuteBatchDmlResponse {
909909
// If all DML statements are executed successfully, the status is `OK`.
910910
// Otherwise, the error status of the first failed statement.
911911
google.rpc.Status status = 2;
912+
913+
// Optional. A precommit token will be included if the read-write transaction
914+
// is on a multiplexed session.
915+
// The precommit token with the highest sequence number from this transaction
916+
// attempt should be passed to the
917+
// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
918+
// This feature is not yet supported and will result in an UNIMPLEMENTED
919+
// error.
920+
MultiplexedSessionPrecommitToken precommit_token = 3
921+
[(google.api.field_behavior) = OPTIONAL];
912922
}
913923

914924
// Options for a PartitionQueryRequest and
@@ -1225,6 +1235,14 @@ message BeginTransactionRequest {
12251235
// transaction, set it on the reads and writes that are part of this
12261236
// transaction instead.
12271237
RequestOptions request_options = 3;
1238+
1239+
// Optional. Required for read-write transactions on a multiplexed session
1240+
// that commit mutations but do not perform any reads or queries. Clients
1241+
// should randomly select one of the mutations from the mutation set and send
1242+
// it as a part of this request.
1243+
// This feature is not yet supported and will result in an UNIMPLEMENTED
1244+
// error.
1245+
Mutation mutation_key = 4 [(google.api.field_behavior) = OPTIONAL];
12281246
}
12291247

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

12731291
// Common options for this request.
12741292
RequestOptions request_options = 6;
1293+
1294+
// Optional. If the read-write transaction was executed on a multiplexed
1295+
// session, the precommit token with the highest sequence number received in
1296+
// this transaction attempt, should be included here. Failing to do so will
1297+
// result in a FailedPrecondition error.
1298+
// This feature is not yet supported and will result in an UNIMPLEMENTED
1299+
// error.
1300+
MultiplexedSessionPrecommitToken precommit_token = 9
1301+
[(google.api.field_behavior) = OPTIONAL];
12751302
}
12761303

12771304
// The request for [Rollback][google.spanner.v1.Spanner.Rollback].

google/spanner/v1/transaction.proto

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ syntax = "proto3";
1616

1717
package google.spanner.v1;
1818

19+
import "google/api/field_behavior.proto";
1920
import "google/protobuf/duration.proto";
2021
import "google/protobuf/timestamp.proto";
2122

@@ -378,6 +379,14 @@ message TransactionOptions {
378379

379380
// Read lock mode for the transaction.
380381
ReadLockMode read_lock_mode = 1;
382+
383+
// Optional. Clients should pass the transaction ID of the previous
384+
// transaction attempt that was aborted if this transaction is being
385+
// executed on a multiplexed session.
386+
// This feature is not yet supported and will result in an UNIMPLEMENTED
387+
// error.
388+
bytes multiplexed_session_previous_transaction_id = 2
389+
[(google.api.field_behavior) = OPTIONAL];
381390
}
382391

383392
// Message type to initiate a Partitioned DML transaction.
@@ -512,6 +521,17 @@ message Transaction {
512521
// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
513522
// Example: `"2014-10-02T15:01:23.045123456Z"`.
514523
google.protobuf.Timestamp read_timestamp = 2;
524+
525+
// A precommit token will be included in the response of a BeginTransaction
526+
// request if the read-write transaction is on a multiplexed session and
527+
// a mutation_key was specified in the
528+
// [BeginTransaction][google.spanner.v1.BeginTransactionRequest].
529+
// The precommit token with the highest sequence number from this transaction
530+
// attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit]
531+
// request for this transaction.
532+
// This feature is not yet supported and will result in an UNIMPLEMENTED
533+
// error.
534+
MultiplexedSessionPrecommitToken precommit_token = 3;
515535
}
516536

517537
// This message is used to select the transaction in which a
@@ -539,3 +559,17 @@ message TransactionSelector {
539559
TransactionOptions begin = 3;
540560
}
541561
}
562+
563+
// When a read-write transaction is executed on a multiplexed session,
564+
// this precommit token is sent back to the client
565+
// as a part of the [Transaction] message in the BeginTransaction response and
566+
// also as a part of the [ResultSet] and [PartialResultSet] responses.
567+
message MultiplexedSessionPrecommitToken {
568+
// Opaque precommit token.
569+
bytes precommit_token = 1;
570+
571+
// An incrementing seq number is generated on every precommit token
572+
// that is returned. Clients should remember the precommit token with the
573+
// highest sequence number from the current transaction attempt.
574+
int32 seq_num = 2;
575+
}

0 commit comments

Comments
 (0)