4

Cloud Bigtable docs on Single-row Transactions says:

Cloud Bigtable also supports some write operations that would require a transaction in other databases:

  • Read-modify-write operations, including increments and appends. A read-modify-write operation reads an existing value; increments or appends to the existing value; and writes the updated value to the table.

  • Check-and-mutate operations, also known as conditional mutations or conditional writes. In a check-and-mutate operation, Cloud Bigtable checks a row to see if it meets a specified condition. If the condition is met, Cloud Bigtable writes new values to the row.

So, if I understand correctly, if I use "Read-modify-write" or "Check-and-mutate" operations, enabling single-row transactions is required.

Those operations are API methods like CheckAndMutateRow, right? So what if a program uses that method and single-row transactions is not enabled? Will the app fail? Am on the right direction?

My goal is to understand how, when and where (in an app) the single-row transaction setting on the app profile is being utilized.

Thanks!

Gabriel

Conflate
  • 27
  • 6
Gabriel
  • 809
  • 1
  • 10
  • 21

2 Answers2

6

You should enable single-row transactions only if you make calls to CheckAndMutateRow or ReadModifyWriteRow from your app, as those calls will fail without the setting enabled. I would even go so far as to disable them if you don't use them, as it will reduce the number of warnings you see when using replication.

Note as Jeff pointed out in his comment that these are enabled by default, in particular if your instance was created with a single cluster. That's simply to avoid breakage of legacy clients, as this distinction didn't matter prior to the launch of replication.

For a little more color as to why this setting exists, see the section here on conflicts between single-row transactions when using replication.

-4

So, if I understand correctly, if I use "Read-modify-write" or "Check-and-mutate" operations, enabling single-row transactions is required.

That is not correct. Using those APIs results in single-row transactions, you do not need to enable anything beforehand.

Those operations are API methods like CheckAndMutateRow, right?

Yes.

So what if a program uses that method and single-row transactions is not enabled?

There is nothing to enable. Calling those APIs results in an atomic operation on the rows you are trying to change.

Will the app fail?

This is not applicable, see above.

coryan
  • 723
  • 3
  • 5
  • 1
    This answer is incorrect. As it says in the documentation that Gabriel linked to: "Cloud Bigtable requires each app profile to specify whether it allows single-row transactions." Single-row transactions are often enabled by default, depending on the way you configured your instance and its clusters. – Jeff Williams Mar 23 '19 at 20:27
  • So, in which cases should I enable single row transactions in the application profile? When that setting is required? – Gabriel Mar 24 '19 at 23:25
  • 1
    If you use any features that rely on these transactions and they are not enabled (either because you didn't enable them for single cluster routing or you are using multi-cluster routing where they *cannot* be enabled) then the relevant API calls will fail. Enable single row transactions when you need to use them, but be aware of how they interact with multi-master writes across clusters if you ever plan on writing to more than one cluster in our application. – Gary Elliott Mar 25 '19 at 15:17