Skip to content

Commit 5c9602d

Browse files
Google APIscopybara-github
authored andcommitted
feat(spanner): include cache updates and routing hint into BeginTransaction and Commit request/response respectively
docs: A comment in message `.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode` is changed docs: A comment for field `routing_hint` in messages `.google.spanner.v1.ResultSet` and `.google.spanner.v1.PartialResultSet` are changed PiperOrigin-RevId: 878019893
1 parent 938377b commit 5c9602d

File tree

3 files changed

+66
-20
lines changed

3 files changed

+66
-20
lines changed

google/spanner/v1/commit_response.proto

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

1717
package google.spanner.v1;
1818

19+
import "google/api/field_behavior.proto";
1920
import "google/protobuf/timestamp.proto";
21+
import "google/spanner/v1/location.proto";
2022
import "google/spanner/v1/transaction.proto";
2123

2224
option csharp_namespace = "Google.Cloud.Spanner.V1";
@@ -61,4 +63,12 @@ message CommitResponse {
6163
// timestamp at which all reads in the transaction ran. This timestamp is
6264
// never returned.
6365
google.protobuf.Timestamp snapshot_timestamp = 5;
66+
67+
// Optional. A cache update expresses a set of changes the client should
68+
// incorporate into its location cache. The client should discard the changes
69+
// if they are older than the data it already has. This data can be obtained
70+
// in response to requests that included a `RoutingHint` field, but may also
71+
// be obtained by explicit location-fetching RPCs which may be added in the
72+
// future.
73+
CacheUpdate cache_update = 6 [(google.api.field_behavior) = OPTIONAL];
6474
}

google/spanner/v1/spanner.proto

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ message ExecuteSqlRequest {
827827
// be assumed until a subsequent `Commit` call completes successfully.
828828
bool last_statement = 17 [(google.api.field_behavior) = OPTIONAL];
829829

830-
// Optional. If present, it makes the Spanner requests location-aware.
830+
// Optional. Makes the Spanner requests location-aware if present.
831831
//
832832
// It gives the server hints that can be used to route the request
833833
// to an appropriate server, potentially significantly decreasing latency and
@@ -1268,7 +1268,7 @@ message ReadRequest {
12681268
// transactions.
12691269
LockHint lock_hint = 17 [(google.api.field_behavior) = OPTIONAL];
12701270

1271-
// Optional. If present, it makes the Spanner requests location-aware.
1271+
// Optional. Makes the Spanner requests location-aware if present.
12721272
//
12731273
// It gives the server hints that can be used to route the request
12741274
// to an appropriate server, potentially significantly decreasing latency and
@@ -1301,6 +1301,14 @@ message BeginTransactionRequest {
13011301
// randomly select one of the mutations from the mutation set and send it as a
13021302
// part of this request.
13031303
Mutation mutation_key = 4 [(google.api.field_behavior) = OPTIONAL];
1304+
1305+
// Optional. Makes the Spanner requests location-aware if present.
1306+
//
1307+
// It gives the server hints that can be used to route the request
1308+
// to an appropriate server, potentially significantly decreasing latency and
1309+
// improving throughput. To achieve improved performance, most fields must be
1310+
// filled in with accurate values.
1311+
RoutingHint routing_hint = 5 [(google.api.field_behavior) = OPTIONAL];
13041312
}
13051313

13061314
// The request for [Commit][google.spanner.v1.Spanner.Commit].
@@ -1355,6 +1363,14 @@ message CommitRequest {
13551363
// results in a `FailedPrecondition` error.
13561364
MultiplexedSessionPrecommitToken precommit_token = 9
13571365
[(google.api.field_behavior) = OPTIONAL];
1366+
1367+
// Optional. Makes the Spanner requests location-aware if present.
1368+
//
1369+
// It gives the server hints that can be used to route the request
1370+
// to an appropriate server, potentially significantly decreasing latency and
1371+
// improving throughput. To achieve improved performance, most fields must be
1372+
// filled in with accurate values.
1373+
RoutingHint routing_hint = 10 [(google.api.field_behavior) = OPTIONAL];
13581374
}
13591375

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

google/spanner/v1/transaction.proto

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package google.spanner.v1;
1919
import "google/api/field_behavior.proto";
2020
import "google/protobuf/duration.proto";
2121
import "google/protobuf/timestamp.proto";
22+
import "google/spanner/v1/location.proto";
2223

2324
option csharp_namespace = "Google.Cloud.Spanner.V1";
2425
option go_package = "cloud.google.com/go/spanner/apiv1/spannerpb;spannerpb";
@@ -39,35 +40,46 @@ message TransactionOptions {
3940
// Default value.
4041
//
4142
// * If isolation level is
43+
// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE],
44+
// locking semantics default to `PESSIMISTIC`.
45+
// * If isolation level is
4246
// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ],
43-
// then it is an error to specify `read_lock_mode`. Locking semantics
44-
// default to `OPTIMISTIC`. No validation checks are done for reads,
45-
// except to validate that the data that was served at the snapshot time
46-
// is unchanged at commit time in the following cases:
47-
// 1. reads done as part of queries that use `SELECT FOR UPDATE`
48-
// 2. reads done as part of statements with a `LOCK_SCANNED_RANGES`
49-
// hint
50-
// 3. reads done as part of DML statements
51-
// * At all other isolation levels, if `read_lock_mode` is the default
52-
// value, then pessimistic read locks are used.
47+
// locking semantics default to `OPTIMISTIC`.
48+
// * See
49+
// [Concurrency
50+
// control](https://cloud.google.com/spanner/docs/concurrency-control)
51+
// for more details.
5352
READ_LOCK_MODE_UNSPECIFIED = 0;
5453

5554
// Pessimistic lock mode.
5655
//
57-
// Read locks are acquired immediately on read.
58-
// Semantics described only applies to
56+
// Lock acquisition behavior depends on the isolation level in use. In
5957
// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]
60-
// isolation.
58+
// isolation, reads and writes acquire necessary locks during transaction
59+
// statement execution. In
60+
// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]
61+
// isolation, reads that explicitly request to be locked and writes
62+
// acquire locks.
63+
// See
64+
// [Concurrency
65+
// control](https://cloud.google.com/spanner/docs/concurrency-control) for
66+
// details on the types of locks acquired at each transaction step.
6167
PESSIMISTIC = 1;
6268

6369
// Optimistic lock mode.
6470
//
65-
// Locks for reads within the transaction are not acquired on read.
66-
// Instead the locks are acquired on a commit to validate that
67-
// read/queried data has not changed since the transaction started.
68-
// Semantics described only applies to
71+
// Lock acquisition behavior depends on the isolation level in use. In
72+
// both
6973
// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]
70-
// isolation.
74+
// and
75+
// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]
76+
// isolation, reads and writes do not acquire locks during transaction
77+
// statement execution.
78+
// See
79+
// [Concurrency
80+
// control](https://cloud.google.com/spanner/docs/concurrency-control) for
81+
// details on how the guarantees of each isolation level are provided at
82+
// commit time.
7183
OPTIMISTIC = 2;
7284
}
7385

@@ -264,6 +276,14 @@ message Transaction {
264276
// attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit]
265277
// request for this transaction.
266278
MultiplexedSessionPrecommitToken precommit_token = 3;
279+
280+
// Optional. A cache update expresses a set of changes the client should
281+
// incorporate into its location cache. The client should discard the changes
282+
// if they are older than the data it already has. This data can be obtained
283+
// in response to requests that included a `RoutingHint` field, but may also
284+
// be obtained by explicit location-fetching RPCs which may be added in the
285+
// future.
286+
CacheUpdate cache_update = 5 [(google.api.field_behavior) = OPTIONAL];
267287
}
268288

269289
// This message is used to select the transaction in which a

0 commit comments

Comments
 (0)