BigTable:我什么时候应该启用单行事务?

BigTable: When should I enable Single-Row Transaction?

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.

所以,如果我没有理解错的话,如果我使用"Read-modify-write"或"Check-and-mutate"操作,需要启用单行事务。

那些操作都是API方法,比如CheckAndMutateRow,对吧? 那么,如果程序使用该方法并且未启用单行事务怎么办?应用程序会失败吗?方向对吗?

我的目标是了解如何、何时何地(在应用中)使用应用配置文件中的单行事务设置。

谢谢!

加布里埃尔

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

这是不正确的。使用这些 API 会导致单行事务,您不需要事先启用任何东西。

Those operations are API methods like CheckAndMutateRow, right?

是的。

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

没有要启用的内容。调用这些 API 会导致对您尝试更改的行执行原子操作。

Will the app fail?

这不适用,见上文。

仅当您从应用程序调用 CheckAndMutateRow 或 ReadModifyWriteRow 时才应启用单行事务,因为如果不启用该设置,这些调用将失败。如果您不使用它们,我什至会 禁用 它们,因为它会减少您在使用复制时看到的警告数量。

请注意,正如 Jeff 在他的评论中指出的那样,这些是默认启用的,特别是如果您的实例是使用单个集群创建的。这只是为了避免遗留客户端损坏,因为在复制启动之前,这种区别并不重要。

有关此设置为何存在的更多信息,请参阅有关使用复制时单行事务之间的冲突的 here 部分。