1- // Copyright 2021 Google LLC
1+ // Copyright 2022 Google LLC
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -35,7 +35,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
3535// completed, the session can immediately be re-used for the next transaction.
3636// It is not necessary to create a new session for each transaction.
3737//
38- // Transaction Modes:
38+ // Transaction modes:
39+ //
3940// Cloud Spanner supports three transaction modes:
4041//
4142// 1. Locking read-write. This type of transaction is the only way
@@ -44,11 +45,18 @@ option ruby_package = "Google::Cloud::Spanner::V1";
4445// Locking read-write transactions may abort, requiring the
4546// application to retry.
4647//
47- // 2. Snapshot read-only. This transaction type provides guaranteed
48- // consistency across several reads, but does not allow
49- // writes. Snapshot read-only transactions can be configured to
50- // read at timestamps in the past. Snapshot read-only
51- // transactions do not need to be committed.
48+ // 2. Snapshot read-only. Snapshot read-only transactions provide guaranteed
49+ // consistency across several reads, but do not allow
50+ // writes. Snapshot read-only transactions can be configured to read at
51+ // timestamps in the past, or configured to perform a strong read
52+ // (where Spanner will select a timestamp such that the read is
53+ // guaranteed to see the effects of all transactions that have committed
54+ // before the start of the read). Snapshot read-only transactions do not
55+ // need to be committed.
56+ //
57+ // Queries on change streams must be performed with the snapshot read-only
58+ // transaction mode, specifying a strong read. Please see
59+ // [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong] for more details.
5260//
5361// 3. Partitioned DML. This type of transaction is used to execute
5462// a single Partitioned DML statement. Partitioned DML partitions
@@ -63,11 +71,12 @@ option ruby_package = "Google::Cloud::Spanner::V1";
6371// not conflict with read-write transactions. As a consequence of not
6472// taking locks, they also do not abort, so retry loops are not needed.
6573//
66- // Transactions may only read/ write data in a single database. They
67- // may, however, read/ write data in different tables within that
74+ // Transactions may only read- write data in a single database. They
75+ // may, however, read- write data in different tables within that
6876// database.
6977//
70- // Locking Read-Write Transactions:
78+ // Locking read-write transactions:
79+ //
7180// Locking transactions may be used to atomically read-modify-write
7281// data anywhere in a database. This type of transaction is externally
7382// consistent.
@@ -78,7 +87,7 @@ option ruby_package = "Google::Cloud::Spanner::V1";
7887// active as long as the transaction continues to do reads, and the
7988// transaction has not been terminated by
8089// [Commit][google.spanner.v1.Spanner.Commit] or
81- // [Rollback][google.spanner.v1.Spanner.Rollback]. Long periods of
90+ // [Rollback][google.spanner.v1.Spanner.Rollback]. Long periods of
8291// inactivity at the client may cause Cloud Spanner to release a
8392// transaction's locks and abort it.
8493//
@@ -90,6 +99,7 @@ option ruby_package = "Google::Cloud::Spanner::V1";
9099// transaction.
91100//
92101// Semantics:
102+ //
93103// Cloud Spanner can commit the transaction if all read locks it acquired
94104// are still valid at commit time, and it is able to acquire write
95105// locks for all writes. Cloud Spanner can abort the transaction for any
@@ -101,7 +111,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
101111// use Cloud Spanner locks for any sort of mutual exclusion other than
102112// between Cloud Spanner transactions themselves.
103113//
104- // Retrying Aborted Transactions:
114+ // Retrying aborted transactions:
115+ //
105116// When a transaction aborts, the application can choose to retry the
106117// whole transaction again. To maximize the chances of successfully
107118// committing the retry, the client should execute the retry in the
@@ -116,7 +127,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
116127// instead, it is better to limit the total amount of time spent
117128// retrying.
118129//
119- // Idle Transactions:
130+ // Idle transactions:
131+ //
120132// A transaction is considered idle if it has no outstanding reads or
121133// SQL queries and has not started a read or SQL query within the last 10
122134// seconds. Idle transactions can be aborted by Cloud Spanner so that they
@@ -127,7 +139,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
127139// SQL query in the transaction (for example, `SELECT 1`) prevents the
128140// transaction from becoming idle.
129141//
130- // Snapshot Read-Only Transactions:
142+ // Snapshot read-only transactions:
143+ //
131144// Snapshot read-only transactions provides a simpler method than
132145// locking read-write transactions for doing several consistent
133146// reads. However, this type of transaction does not support writes.
@@ -159,13 +172,12 @@ option ruby_package = "Google::Cloud::Spanner::V1";
159172//
160173// If the Cloud Spanner database to be read is geographically distributed,
161174// stale read-only transactions can execute more quickly than strong
162- // or read-write transaction , because they are able to execute far
175+ // or read-write transactions , because they are able to execute far
163176// from the leader replica.
164177//
165178// Each type of timestamp bound is discussed in detail below.
166179//
167- // Strong:
168- // Strong reads are guaranteed to see the effects of all transactions
180+ // Strong: Strong reads are guaranteed to see the effects of all transactions
169181// that have committed before the start of the read. Furthermore, all
170182// rows yielded by a single read are consistent with each other -- if
171183// any part of the read observes a transaction, all parts of the read
@@ -177,9 +189,13 @@ option ruby_package = "Google::Cloud::Spanner::V1";
177189// reads should be executed within a transaction or at an exact read
178190// timestamp.
179191//
192+ // Queries on change streams (see below for more details) must also specify
193+ // the strong read timestamp bound.
194+ //
180195// See [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong].
181196//
182- // Exact Staleness:
197+ // Exact staleness:
198+ //
183199// These timestamp bounds execute reads at a user-specified
184200// timestamp. Reads at a timestamp are guaranteed to see a consistent
185201// prefix of the global transaction history: they observe
@@ -200,7 +216,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
200216// See [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp] and
201217// [TransactionOptions.ReadOnly.exact_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact_staleness].
202218//
203- // Bounded Staleness:
219+ // Bounded staleness:
220+ //
204221// Bounded staleness modes allow Cloud Spanner to pick the read timestamp,
205222// subject to a user-provided staleness bound. Cloud Spanner chooses the
206223// newest timestamp within the staleness bound that allows execution
@@ -229,7 +246,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
229246// See [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness] and
230247// [TransactionOptions.ReadOnly.min_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min_read_timestamp].
231248//
232- // Old Read Timestamps and Garbage Collection:
249+ // Old read timestamps and garbage collection:
250+ //
233251// Cloud Spanner continuously garbage collects deleted and overwritten data
234252// in the background to reclaim storage space. This process is known
235253// as "version GC". By default, version GC reclaims versions after they
@@ -239,7 +257,41 @@ option ruby_package = "Google::Cloud::Spanner::V1";
239257// timestamp become too old while executing. Reads and SQL queries with
240258// too-old read timestamps fail with the error `FAILED_PRECONDITION`.
241259//
242- // Partitioned DML Transactions:
260+ // You can configure and extend the `VERSION_RETENTION_PERIOD` of a
261+ // database up to a period as long as one week, which allows Cloud Spanner
262+ // to perform reads up to one week in the past.
263+ //
264+ // Querying change Streams:
265+ //
266+ // A Change Stream is a schema object that can be configured to watch data
267+ // changes on the entire database, a set of tables, or a set of columns
268+ // in a database.
269+ //
270+ // When a change stream is created, Spanner automatically defines a
271+ // corresponding SQL Table-Valued Function (TVF) that can be used to query
272+ // the change records in the associated change stream using the
273+ // ExecuteStreamingSql API. The name of the TVF for a change stream is
274+ // generated from the name of the change stream: READ_<change_stream_name>.
275+ //
276+ // All queries on change stream TVFs must be executed using the
277+ // ExecuteStreamingSql API with a single-use read-only transaction with a
278+ // strong read-only timestamp_bound. The change stream TVF allows users to
279+ // specify the start_timestamp and end_timestamp for the time range of
280+ // interest. All change records within the retention period is accessible
281+ // using the strong read-only timestamp_bound. All other TransactionOptions
282+ // are invalid for change stream queries.
283+ //
284+ // In addition, if TransactionOptions.read_only.return_read_timestamp is set
285+ // to true, a special value of 2^63 - 2 will be returned in the
286+ // [Transaction][google.spanner.v1.Transaction] message that describes the
287+ // transaction, instead of a valid read timestamp. This special value should be
288+ // discarded and not used for any subsequent queries.
289+ //
290+ // Please see https://cloud.google.com/spanner/docs/change-streams
291+ // for more details on how to query the change stream TVFs.
292+ //
293+ // Partitioned DML transactions:
294+ //
243295// Partitioned DML transactions are used to execute DML statements with a
244296// different execution strategy that provides different, and often better,
245297// scalability properties for large, table-wide operations than DML in a
0 commit comments