googleapis / googleapis/ruby-spanner

tx.read() operation shouldn't increment seqno field

Offen
#64 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
api: spanner priority: p3 type: cleanup
Vorherrschende Sprache
Ruby
Sterne
6
Forks
24
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### Background:
Cloud Spanner uses the [`seqno`](https://github.com/googleapis/googleapis/blob/dd546bf83f7aa6dd24e17d3e83d9a397a6dd680c/google/spanner/v1/spanner.proto#L629-L639) field in DML statements of transactions to identify duplicate or out-of-order requests. This field is ignored for other queries. The value must always be monotonically increasing for every DML operation.

### Problem:
The [`Transaction#read()`](https://github.com/googleapis/ruby-spanner/blob/c6cde4010632724449bc4a653221f94a9c262669/google-cloud-spanner/lib/google/cloud/spanner/transaction.rb#L711) method isn't a DML operation, and doesn't use the `seqno` field. Yet, when the user calls it, the `@seqno` value is auto-incremented. This is because the read query is executed inside the context of [`safe_execute()`](https://github.com/googleapis/ruby-spanner/blob/c6cde4010632724449bc4a653221f94a9c262669/google-cloud-spanner/lib/google/cloud/spanner/transaction.rb#L1169-L1185) block.

While this won't cause any failure, we should avoid incrementing `seqno` for non-DML operations. This might lead to confusing debugging situations in the future, when the value is noticed to jump from `n` to `n + 2` directly (for any n >= 1). This can happen if there are DML operations interleaved with a `.read()` operation.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.