tag:blogger.com,1999:blog-8899645800948009496.post7455734617252802367..comments2024-12-25T12:06:10.476-08:00Comments on DBMS Musings: Correctness Anomalies Under Serializable IsolationDaniel Abadihttp://www.blogger.com/profile/16753133043157018521[email protected]Blogger11125tag:blogger.com,1999:blog-8899645800948009496.post-1898517483104834082020-11-05T13:33:32.561-08:002020-11-05T13:33:32.561-08:00Hi Daniel, although I understand the motivation be...Hi Daniel, although I understand the motivation behind this interesting post and clearly see the utility in carefully cataloging defects in the behavior, as a DB purist I must say that in my opinion, the definition of serializable in its essence (code away, dear programmers, and don&#39;t worry about the concurrency and assume that the system creates an illusion of perfect isolation for you, and as if you were working with a single system, one at a time, and with the perceived behavior of the system that in no way would go against your intuition about the flow of time, causality, etc.) is valid in the sense that any implementations true to the essence of serializable must be anomaly free.<br /><br />Or, to put it shortly, If a specific implementation of serializable is not anomaly free, then it ain&#39;t serializable.Tengizhttps://www.blogger.com/profile/18124028627990745709[email protected]tag:blogger.com,1999:blog-8899645800948009496.post-54447520626001424662019-08-19T15:20:27.976-07:002019-08-19T15:20:27.976-07:00Vladimir and Umesh: I really appreciate your comme...Vladimir and Umesh: I really appreciate your comments and suggestions about the naming of the isolation levels. After thinking about this further, I have changed my naming scheme and updated the text and tables accordingly. I think this new naming scheme is much cleaner (and clearer).<br /><br />Thanks again.Daniel Abadihttps://www.blogger.com/profile/16753133043157018521[email protected]tag:blogger.com,1999:blog-8899645800948009496.post-78789636574353450732019-07-31T14:29:54.723-07:002019-07-31T14:29:54.723-07:00Thanks for writing this post! I too think that th...Thanks for writing this post!<br /><br />I too think that the names are a bit confusing. Here is a thought. Suppose we first name aspects of distributed systems that result in a particular behavior. E.g.,<br />- One-partition (1P) vs. multi-partition (MP or XP)<br />- One-leader/master/writer (1W) vs. multi (MW)<br />- Synchronously copied (SC, because SR for synchronously replicated would be confusing with SR for serializable) vs. asynchronously copied (AC)<br /><br />Then we can create various isolation levels based on combining these aspects. E.g.,<br />SC-1SR: avoids stale reads<br />1W-1SR: avoids immortal writes<br />1W-1P-1SR: avoids immortal writes and causal reverse. I am not sure if synchronous copying is needed to avoid causal reverse. I am assuming not. If it is, we would write this isolation level as 1W-1P-SC-1SR.<br /><br />Admittedly, this nomenclature is based on aspects of database design, not what is experienced by the user. But so is &quot;Snapshot Isolation&quot;, so may be it is OK.<br /><br />An alternative is to describe the isolation levels based purely on behavior in a self-evident manner. E.g.,<br />- Fresh reads: avoids stale reads<br />- Fresh writes: avoids immortal writes (and perhaps avoids non-linearizable writes in general)<br />- Externally consistent: avoids causal reversal, even through external channels.<br />- Causal: avoids causal reversal through internal channels.<br /><br />Having written this note, it does seem that isolation levels might be best described based on behavior. Then we can map database design aspects to these isolation levels.umesh.maheshwarihttps://www.blogger.com/profile/18429960633615628303[email protected]tag:blogger.com,1999:blog-8899645800948009496.post-84078271708783451562019-07-17T16:37:57.287-07:002019-07-17T16:37:57.287-07:00Hi Scott, here is another way to explain how a wri...Hi Scott, here is another way to explain how a write might become immortal: suppose a distributed system uses global timestamps to serialize transactions, where a global timestamp is made up of the local time at the stamper concatenated with the stamper&#39;s uid to break ties (as the less significant part of the timestamp). If the local clock where write W1 is accepted happens to be far ahead of clocks at other nodes, it would be serialized later than writes accepted on other nodes. umesh.maheshwarihttps://www.blogger.com/profile/18429960633615628303[email protected]tag:blogger.com,1999:blog-8899645800948009496.post-47068278025395834682019-07-11T18:24:03.987-07:002019-07-11T18:24:03.987-07:00Hi Scott --- as far as why banks do transfers in t...Hi Scott --- as far as why banks do transfers in two transactions: I&#39;m not in that industry so I can&#39;t really explain it. However, the point I&#39;m making in the post is that it is not uncommon to have logical dependencies across transactions. If you have a database system that only guarantees correctness if all logical connections across updates must be present in the same transaction, application developers would find that to be extremely constraining. Sometimes, a later transaction is only submitted because an earlier transaction committed. It is considered a desirable feature for a system to uphold implicit time-based causality.<br /><br />As far as the blind write: it&#39;s not that Danger is being scheduled before the first name change. The first name change happened and was completed. When the second name change comes along, the system is allowed to ignore the second transaction --- and can do this without violating its serializability guarantee. It just pretends that it was scheduled before the other transaction. In reality the the first one happened first, and the second one was ignored. But since that&#39;s the same final outcome as the second one being scheduled first, and the first one being scheduled second, the serialization guarantee is not violated.Daniel Abadihttps://www.blogger.com/profile/16753133043157018521[email protected]tag:blogger.com,1999:blog-8899645800948009496.post-87324328394199520512019-07-03T11:59:33.451-07:002019-07-03T11:59:33.451-07:00I am having a hard time understanding the causal r...I am having a hard time understanding the causal reverse. First why would you do 2 transfers in 2 transactions? Wouldn&#39;t it just make more sense to perform both changes in a single transaction? Technically you could write it in 2 transactions but it seems obviously wrong to do that. I fear that I am missing something in this discussion. I also have a problem with the immortal write as I don&#39;t see why Danger is always being scheduled before the name change to Daniel. Maybe I have used read commited for too long with Oracle and that is what is hanging me up but I can&#39;t see how this is possible. Does this only occur in Async Multi Master setups with something like Galera Clusters? ScottWhttps://www.blogger.com/profile/00773313797138309626[email protected]tag:blogger.com,1999:blog-8899645800948009496.post-7751624937402670792019-06-30T12:41:21.108-07:002019-06-30T12:41:21.108-07:00OK, thanks for the clarification. It wasn&#39;t cl...OK, thanks for the clarification. It wasn&#39;t clear to me from the prose or the diagrams that you were assuming an external service. As written, it sounds like you&#39;re saying that any two causally-related transactions could exhibit this anomaly. But it&#39;s important that the database has no knowledge of any linkage between the two transactions (overlapping keys, foreign key relationships, &quot;transfers&quot; table that tracks progress of the external transfer, etc.).AndyAndRachelhttps://www.blogger.com/profile/17684854848290797842[email protected]tag:blogger.com,1999:blog-8899645800948009496.post-24922044181574692342019-06-29T19:50:01.070-07:002019-06-29T19:50:01.070-07:00I agree that &quot;asynchronous serializable&quot;...I agree that &quot;asynchronous serializable&quot; and &quot;partitioned serializable&quot; are not perfectly named. I will think about this further and perhaps update the post with better names.Daniel Abadihttps://www.blogger.com/profile/16753133043157018521[email protected]tag:blogger.com,1999:blog-8899645800948009496.post-8225150786029821282019-06-29T19:37:29.970-07:002019-06-29T19:37:29.970-07:00The example in the post is correct. If you look ca...The example in the post is correct. If you look carefully at the figure, you will see that there are no overlapping keys. Causal reverse is absolutely possible in this example.<br /><br />As far as why there is no bank account C in the example, that is because the clearing account if often not maintained by the same database system as the customer account balances. In this example, the DB (e.g. CockroachDB) only sees the changes to accounts A and B. Some other system maintains account C. Yes, that&#39;s an external system. But that&#39;s the point!! To assume that all relevant data for an application is all stored in one DB is extremely naive. In real life, relevant data lives everywhere, and you can&#39;t control external coordination.<br /><br />The causal reverse is actually more likely to happen in real life than in the research lab. Daniel Abadihttps://www.blogger.com/profile/16753133043157018521[email protected]tag:blogger.com,1999:blog-8899645800948009496.post-86753948461600406172019-06-29T16:14:55.014-07:002019-06-29T16:14:55.014-07:00Hi Daniel, your CockroachDB example is incorrect. ...Hi Daniel, your CockroachDB example is incorrect. You&#39;re forgetting that there&#39;s a 3rd bank-owned account involved (I&#39;ll refer to that as account C). No causal reverse would occur in this case, because both Txn A and Txn B synchronize on account C. Causal reverse can only happen in CRDB when there are no overlapping read/write or write/write keys between transactions. If there is even one overlapping key, as with account C, then the commit order of those transactions will *always* correspond to wall clock time.<br /><br />It&#39;s actually quite difficult to find a case where the CRDB consistency model could result in real-world problems. Here&#39;s a CRDB blog article explaining when/how it can happen: https://www.cockroachlabs.com/blog/consistency-model/. Basically, it requires some form of coordination external to the database (which is presumably how &quot;external consistency&quot; got its name).<br /><br />Perhaps you could get Kyle Kingsbury (of Jepsen fame) to review your next blog post for correctness?AndyAndRachelhttps://www.blogger.com/profile/17684854848290797842[email protected]tag:blogger.com,1999:blog-8899645800948009496.post-552096141709910282019-06-29T00:57:02.537-07:002019-06-29T00:57:02.537-07:00Hi Daniel, This combined list of anomalies looks ...Hi Daniel,<br /><br />This combined list of anomalies looks a bit complicated because it mixes *logical* isolation levels (ANSI + snapshot), with *physical* properties of specifics systems, such as partitioning and async reads/writes. <br />For example, not all partitioned systems rely on wall-clock time, so they don&#39;t necessarily exhibit &quot;causal reverse&quot;. Other systems with asynchronous replication provide means for adjusting their guarantees, e.g. disallow read from backups. At the same time, &quot;STRICT SERIALIZABLE&quot; is logical again. <br />So what is a practical use of putting logical and physical properties into a single table?Vladimirhttps://www.blogger.com/profile/16984820327246039636[email protected]