使用轻量级事务有什么影响?

What are the implications of using lightweight transactions?

特别是我在看 this page 上面写着:

If lightweight transactions are used to write to a row within a partition, only lightweight transactions for both read and write operations should be used.

我对使用 LWT 进行读取操作的情况感到困惑。具体来说,这与每个查询的一致性(和 serialConsistency)级别有何关系。

SERIAL 读取一致性的 description 引发了进一步的问题:

Allows reading the current (and possibly uncommitted) state of data without proposing a new addition or update.

这表明使用 SERIAL 进行读取不是 "using a LWT"。

但是

如果我忽略这个建议并制作连续和非连续reads/writes。 LWT 以何种方式失败?

How does Cassandra know to check for in-progress transactions when you do a read?

这正是 SERIAL 一致性级别所指示的。它确保在所有待处理事务都已完全执行后,查询才会 return 结果。

What is the new update that is proposed while you're trying to read, and how does this affect the read?

我认为该文档试图说明的是,读取将像 LWT 一样处理 - 只是不会自行进行任何更新。

How would that work if the consistency you're reading at (say ONE for example) is less than the serialConsistency used for writing?

使用 SERIAL 的读取将始终暗示 QUORUM 作为一致性级别。使用 ONE 读取不会为您提供 SERIAL 提供的任何保证,您最终可能会读取停滞的数据。

Once you use a LWT on a table (or row?, or column?), are all non-SERIAL reads forced to take the penalty of participating in quorums and the transaction algorithm?

没有。您可以为查询使用 non-SERIAL 一致性级别,并让它们以与任何其他 non-serial 查询完全相同的性能特征执行。

Does the requirement actually apply to the whole row, or just the columns involved in the conditional statement?

不,我认为只要您对序列 reads/writes(包括条件)和常规 reads/writes.

使用不同的列就可以了

If I ignore this advice and make both serial and non-serial reads/writes. In what way to the LWTs fail?

如果您执行常规写入,而不是作为 LWT 的一部分执行,那么这些写入将随时应用,而不会干扰 LWT 的共识过程。因此,理论上,定期写入可以在评估条件和应用更新之间一次更改作为 LWT 条件一部分的值,这是您希望使用 LWT 避免出现不一致的潜在原因。