TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

If Eventual Consistency Seems Hard, Wait Till You Try MVCC

121 pointsby boynamedsueover 10 years ago

18 comments

AlisdairOover 10 years ago
I certainly wouldn&#x27;t dispute that it can be hard to reason about concurrent operations in traditional database systems - particularly if you want to do it across multiple database systems, which do indeed have differing implementations. That said, if the author thinks eventual consistency is easy&#x2F;not-that-bad&#x2F;whatever by comparison, I would tend to question their understanding of programming for eventually consistency. Eventual consistency for non-trivial applications is really, really, really hard to get right.<p>Consistency in relational databases is a hard topic because maintaining consistency in any concurrent system is hard. Traditional systems provide you with a set of tools (isolation levels, foreign keys) that make a decent programmer capable of building a safe concurrent application. Throwing away those tools and replacing them with nothing does not make life easier. The tool is easier to understand, but the problem is harder to solve.
评论 #8722536 未加载
jeffdavisover 10 years ago
PostgreSQL supports true serializability, while maintaining good performance and concurrency:<p><a href="http://www.postgresql.org/docs/9.4/static/transaction-iso.html#XACT-SERIALIZABLE" rel="nofollow">http:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;9.4&#x2F;static&#x2F;transaction-iso.ht...</a><p>It&#x27;s based on fairly recent research by Michael J. Cahill, et al.<p>It&#x27;s simple. If you are confused, then set default_transaction_isolation=true. You will get errors if there&#x27;s a data race.<p>Given that, what&#x27;s the point of the article? That sub-SERIALIZABLE modes have complex semantics? Yes, that&#x27;s true, but they are still much more likely to help you then the NoSQL &quot;you&#x27;re on your own to avoid races&quot; approach.<p>If you want to avoid lots of really challenging problems, PostgreSQL is often the best bet by far.
评论 #8721763 未加载
Dave_Rosenthalover 10 years ago
I agree with the author that the various levels of isolation, etc. within the current crop of SQL databases is a morass. I’ll point to some recent fine work by Martin Kleppmann (<a href="https://github.com/ept/hermitage" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ept&#x2F;hermitage</a>) that explores the issue and shows how many systems fall short of serializable isolation in their default modes. (And sometimes in modes labeled “serializable”!) In his test three databases actually achieve full serializability: PostgreSQL, MS SQL Server, and FoundationDB.<p>But don’t give up on ACID yet! If can actually get real serializability, you have a very powerful model that is also very simple to reason about. Serializable isolation gives you a virtual “whole database lock” that lets you modify lots of things all over the database before you “unlock” it and hand the database to the next client. The amazing thing about MVCC combined with serializable isolation is that you get to use this &quot;simplest possible&quot; mental model even though hundreds or thousands of concurrent clients might be all hitting the database at the same time.
评论 #8721058 未加载
quizoticover 10 years ago
One of the functions of an Operating System is to provide (the illusion of) isolation between Processes and the resources they acquire. Roughly,<p>Transaction : Database :: Process : OperatingSystem<p>The four transaction isolation levels, defined nearly fifty years ago, were an attempt at categorizing incomplete isolation. Can you imagine launching an operating system process and saying &quot;It&#x27;s OK if my memory locations are changed by another process&quot; Or &quot;Don&#x27;t let my memory locations be changed by another process, but it&#x27;s OK if another process prevents me from deleting a resource&quot;. That&#x27;s what we&#x27;re asking of our non-serializable database transactions.<p>Why not just provide strong isolation? Partly because it is hard and partly because the performance impact of strong transaction isolation is greater than the performance impact of process context switching.<p>But if you&#x27;re living with less than strong transaction isolation, then tautologically, strange and unexpected things eventually happen: seeing state that never existed, seeing state changes that you didn&#x27;t make, failing to see state that you should have seen. Rarely, the application can reliably detect and handle some of these situations. Typically, the application only thinks it can.<p>Sometimes, I think the core issue is with the notions of isolation and serializability themselves. Developers want to believe that events are noticed simultaneously with their occurrence, and that all observers (transactions) see the same history unfold in the same order. But the pesky physical world doesn&#x27;t work that way.
nickikover 10 years ago
While reading this I was thinking about Datomic. I know that transactions are serialisable and actually serialised and stored in the database. Essentially what you get is a full DB lock and you can access the full database, or even do whatever you want. That of course does lock the database transacter, reading can still go on consistently.<p>Was is not also the research in VoltDB, that coordination is the problem, and that you have to do all transaction on a single core. Am I remembering this correctly?<p>Seams to me Datomic hits a very nice spot very you have relativly fast writing and concptionally unlimited reads.<p>If somebody know more then me, I happy to learn.<p>PS:<p>Also, why are we still using NoSQL and make any generalisation about it, by know there are so many NoSQL databases that they have literally nothing in common exept that its not a traditionall SQL database.
评论 #8723166 未加载
评论 #8721667 未加载
评论 #8733856 未加载
评论 #8722820 未加载
spacemanmattover 10 years ago
It would seem a much more honest argument to me if MVCC were being compared to another implementation of consistency management, rather than compared to NO IMPLEMENTATION at all.
评论 #8722949 未加载
epeover 10 years ago
I find this: <a href="http://martin.kleppmann.com/2014/11/25/hermitage-testing-the-i-in-acid.html" rel="nofollow">http:&#x2F;&#x2F;martin.kleppmann.com&#x2F;2014&#x2F;11&#x2F;25&#x2F;hermitage-testing-the...</a> a more informative read on essentially the same topic.
评论 #8721318 未加载
friendzisover 10 years ago
&gt; “what’s the difference between Consistency and Isolation again?”<p>This is what bothers me most about this article. How can a person seemingly having advanced knowledge of relational databases cannot understand that Consistency is about <i></i>dataset state<i></i> and Isolation is about <i></i>transactions<i></i>. It&#x27;s not that you get consistent results between transactions or even queries, but that if key is integral number, then `itoa()` works (given that bit length not too large) no matter what, period.<p>If you want to support concurrent read and write operations on a database, then it&#x27;s not much different from multithreaded programming - hard and impossible to get right without compromises.
评论 #8722782 未加载
taericover 10 years ago
I&#x27;m not entirely sure I understand how things are any better in either world. Especially if you are approaching the problem with the idea that you will have no failure conditions, things are going to be tough. Prohibitively so.
Terr_over 10 years ago
I think part of the goal with Eventual Consistency is that it lets you attack the underlying issues in a qualitatively different way.<p>Relying on the DB, your options are constrained by your choice of relational tables and rows, and further affected by your DB vendor and configuration. When you lift the conflicts out to a higher layer of abstraction, you can do something more object-oriented, leveraging some of the same tools you&#x27;ll need anyway to deal with other inconsistencies and quirks.
mwcampbellover 10 years ago
&gt; Sorry, I&#x27;m not impressed with serializable isolation via a single writer mutex.<p>I think that for a large number of applications, this would work just fine. Especially if the underlying storage is SSD-based -- something that&#x27;s now easily obtained via VPS providers like DigitalOcean, Linode, and Vultr. After all, most database-driven applications aren&#x27;t large-scale operations. So it&#x27;s probably better to favor correctness and simplicity over concurrency and scalability.
grogersover 10 years ago
I&#x27;m probably the minority on this, but I think innodb&#x27;s docs on its isolation modes are clearer and easier to understand than postgres&#x27;. That could be because I have internalized them over many years though.<p>To me, the only sensible isolation level for transactions is serializable. We&#x27;ve had so many consistency issues because developers didn&#x27;t understand when to lock and when not to. Everyone (including me) gets it wrong from time to time.<p>Very careful use of nonlocking selects can be correct and improve concurrency, but across a huge codebase, bugs slip in. If I could turn on a mode where the default is &quot;select ... lock in share mode&quot; but opt into a &quot;select ... nonlocking&quot; I would be eternally grateful. Judicious use of wrappers where we force the user to specify the lock mode has helped curb this trend quite a bit.<p>I&#x27;d still take MVCC with tons of warts over eventual consistency any day of the week. It is impossible to reason about eventual consistency because the database is literally allowed to do basically anything. Causal should really be the default starting point for AP systems.
评论 #8721305 未加载
rectangover 10 years ago
While they aren&#x27;t distributed, Apache Lucene and Apache Lucy (the &quot;loose C&quot; port of Lucene that I work on) both implement MVCC: each index reader object represents a point-in-time view of the index that persists for the object&#x27;s lifetime.<p>Core developers such as myself have to deal with some subtleties when implementing MVCC, but I wouldn&#x27;t say that MVCC is too terribly hard for our users. The thing is, our interface does not look anything like SQL -- you have to use a different mental model when interacting with our data stores, and of course they are not suitable for all applications where you might use SQL.<p>What I took away from the article is that MVCC does not fit well within SQL semantics.
grandalfover 10 years ago
This is a great thing to read and discuss, as opposed to blindly jumping on one bandwagon or another.<p>A relational database is a framework for storing data that comes with some rules in in exchange helps to guarantee certain characteristics. A flat file is too. The choice of which one to use depends on the problem.<p>Often there are several good choices. Imagine all the relational db zealots who frown upon using a relational db in a slightly unconventional way, such as strong events in a single table using a json column in postgres. Yet postgres provides some useful features and so it may actually be very smart to use it that way.
klochnerover 10 years ago
<p><pre><code> &gt; Does the first part of this excerpt contradict the second part? (Emphasis mine) </code></pre> No, it&#x27;s perfectly clear and consistent. Does anyone else find it confusing?
debacleover 10 years ago
I wish people would not blog as experts about things they don&#x27;t know a great deal about.
empthoughtover 10 years ago
&gt; Many developers, including myself, have written applications that fall afoul of the MVCC implementation and rules.<p>Color me shocked.
imanaccount247over 10 years ago
He&#x27;s trying to claim that MVCC pushes complexity on to the user, but the examples of that are just typical &quot;mysql does it wrong&quot;. So, that means mysql pushes complexity on to the user, not MVCC.
评论 #8722104 未加载