6 ms·
Strict-serializability, but at what cost, for what purpose?
- someon3 4y agoSo you can serialize stuff ?
- liuliu 4y agoRead this post a few days ago. I am trying to articulate my answer properly, mostly from a client-side dev's perspective. Here is my half-baked thoughts: Strict-serializability pretty much guarantees that you don't need any extra business logic to resolve logical states you know you won't, but turns out end up with. If your changes go out in-order over the wire, you know it will be go in with that order on the other end, either that end is temporal or spatial away. However, strict-serializability doesn't solve either business logic errors or collaboration issues. If you have wrong transaction wrapping (things should happen in one transaction got split), or you have race condition locally, SS doesn't help on that. SS doesn't solve collaboration issues because the real-time ordering means both of you will end up in the same state, but if naively implemented, that same state may not be what you would expect (you still need to solve conflicts, and how you solve the conflict has to match the user expectation). Then it goes back to what I originally said, for client-side devs, what they are looking for is to not write any extra business logic to handle states they know they won't end up with when their requests to the server went out in order. For many of these business logics, SS is too strong. A combination of serializability and linearizabily, as the author suggested, could be sufficient. It is just hard to articulate what combination that will be for broad spectrum of business applications.
- truncate 4y agoI feel is kind of similar to static vs dynamic type system argument. Dynamic Type systems can work great if you have strong contracts and everyone understands how to define/maintain that, but as you grow up the team, you'd have people having gaps in understanding those contracts and break them eventually leading to bugs. Enforcing rules sometimes just keeps the rules alive in everyone's head as it is harder to get around that usually.
- richieartoul 4y agoI’ve had this debate with people numerous times and I think the “you don’t need strong consistency” crowd has really gotten it backwards. These same people will also agree with you that premature optimization is bad, but then argue that application developers should be forced to grapple with looser isolation models for vague reasons like “latency” and “costs”. Most applications don’t push their databases that hard, and the ones that do usually have their most expensive queries as large “read only” queries where strict serializability of other transactions adds little additional overhead. It’s already hard enough to write correct software, we should be pushing hard problems like transaction isolation deep into the database so they can be solved correctly once, instead of 1000s of times incorrectly. Most applications that depend on strong consistency in their database could be rewritten to require less strict guarantees, but why? Strict serializability should be the default. Engineers working in performance sensitive settings and who really know what they’re doing can always loosen this constraint in the narrow part of the application where it matters. It’s crazy to me that anyone would ask a developer to justify why they need strict serializability. It should be the opposite, you should be forced to justify why you’re using a looser isolation level for performance reasons just like we force developers to justify why they’re introducing more performant, but less readable code!
- liuliu 4y agoThe post has more leg than you give it credit for. The author thinks serializable is table stake, and linearizability can be implemented cheaply (through sharding). Strict-serializable however, cannot really break "scale-out" barrier with some serious compromises (either time-bounds it (Spanner's 7ms bounds), or central ordering service that cannot scale out). It additionally provides a proof that strict-serializable != serializable + linearizable and then go on to question what you responded: does strict-serializable worth all these troubles?
- richieartoul 4y agoIn my opinion the answer is unequivocally, yes, it is worth it, and developers should accept nothing less from modern databases. Even with strict serializability, developers will still be surprised by transactional behavior in distributed environments, but at least strict serializability provides a relatively straight forward framework for developers to reason about with almost no “ifs, ands, or buts” except for some confusing behavior around idempotency and transaction retries. As soon as you drop below strict serializability, the cognitive load of reasoning about your applications correctness increases dramatically. Most developers just accept this, but it’s not the right trade off for most applications IMO. If this was some theoretical question that we hadn’t figured out if it was practical or possible yet, I would have more sympathy for this line of thinking, but it’s not anymore. Spanner, CockroachDB, and FoundationDB have all proven that these systems can be scaled, and economically so. FoundationDB scales incredibly well with great performance characteristics. That’s evidence enough to me that the cost of strict serializability is worth it for 99% of applications.
- adamnemecek 4y agoWhat's crazy to me is that the idea of linearizability is essentially the same as the idea of fixed-points or dimensionality reduction. I have been collecting some links on this topic https://github.com/adamnemecek/adjoint https://github.com/adamnemecek/adjoint
- kevincox 4y agoThe TL;DR is that every anomaly that your database can experience is one thing that every developer needs to consider for every change they make. This is a huge overhead. Most importantly every developer won't correctly consider these anomalies for every change because humans aren't perfect. This means that you will encounter bugs from time to time. So that is the purpose. If you solve this at the database layer you relieve your developers of this burden and reduce bugs. You can argue that the cost is too high (it may be) but there is clearly a benefit to balance it out. Especially if the cost keeps dropping (as it seems to be doing) the balance tips every in favour of stricter consistency models.
- deathanatos 4y agoI'm just sitting here wanting "read-your-writes" from systems.
- richieartoul 4y agoFunny enough, this actually cuts to the core of why strict serializability is so important. “Technically speaking, every read-only transaction could return the empty-set (which was the initial state of the database) and not be in violation of the serializability guarantee --- this is legal since the system can bring read-only transactions “back in time” and get a slot in the serial order before any transactions that write to the database.” https://fauna.com/blog/serializability-vs-strict-serializability-the-dirty-secret-of-database-isolation-levels https://fauna.com/blog/serializability-vs-strict-serializabi...
- jwr 4y agoI've spent enough time dealing with problems caused by lack of strict serializability. Theoretical discussions are great, but eventually your data model isn't just a bunch of separate key-value pairs. The usual approach is to avoid problems by redesigning your application and doing gymnastics with your data. But what's the point if we have FoundationDB (which I'm in the process of migrating to)?
- Gwypaas 4y agoDon't really have an axe to grind regarding strict-serializability, serializability, snapshot isolation or whatever. Start at the highest level of consistency and consciously step away if you encounter issues. The Postgres default of "Read committed" gives me shivers on the other hand... > If I were to make a concurrent map data structure whose operations are not linearizable and then put it on a library and give it to my users, any user of that library would come back to me and say that my library has a bug. They may not be able to tell me exactly what it is, but they'll understand that there is a bug in it. > However, if I take the same concurrent map data structure, and put in an application and call that application a "Key-Value store" or a "Database" (DBMS) and give it to the typical database users, it seems they may certainly use it for a several decades without ever complaining that this "Database" is not linearizable (or serializable as the DB folks call it). https://concurrencyfreaks.blogspot.com/2020/06/you-say-read-committed-i-say-buggy-code.html https://concurrencyfreaks.blogspot.com/2020/06/you-say-read-...
- WJW 4y agoI like my strictness just as much as anyone else, but this seems like a "works in practice" vs "works in theory" issue to me. Linearizability is just not as important as some people make it out to be. (On a slightly meta level, you can see this happening for a great many issues in programming. Memory safety is undeniably nice, but approximately none of the worlds databases or kernels are written in memory safe languages. Type safety is nice but a huge majority of frontend code is untyped. Don't even get me started on the value of unit testing vs its absence in academic code)
- Gwypaas 4y ago> Linearizability is just not as important as some people make it out to be. That's my entire point. Start with strong models and weaken when you decide you need it. Thus rule out entire classes of bugs for 99% of your code and closely scrutinize the 1% with weakened guarantees to know that it works. That is kind of the entire premise behind Rust. Make it extremely visible where the dragons may exist, because you have the key to unlock that door. Regarding memory safety, 70% of CVEs at Microsoft and in Chrome are memory safety bugs. I would say the choice of languages without memory safety is more based on legacy than some kind of insightful choice. https://msrc-blog.microsoft.com/2019/07/16/a-proactive-approach-to-more-secure-code/ https://msrc-blog.microsoft.com/2019/07/16/a-proactive-appro... https://security.googleblog.com/2022/03/whats-up-with-in-wild-exploits-plus.html https://security.googleblog.com/2022/03/whats-up-with-in-wil...
- siddontang 4y agoDisclosure: The maintainer of TiDB here. When we started to build the distributed database TiDB, we had the similar discussion - whether we need to provide a so strong consistence for the customers? Inspired by Google Spanner, we also wanted to let the application programmers to take easy and not struggle with the consistent problems in applications layer by themselves. So we decided to provide the strong consistency. But unlike Google Spanner, we couldn’t use TureTime API, so we introduced a standalone timestamp service named TSO to allocate timestamp. Using TSO is simple to guarantee all transactions’ order, but this introduces another problem - if the TiDB is deployed crossing different regions, the transaction latency is high. Another example for consistency is from our realtime analytical processing design. TiDB is a HTAP(hybrid transaction/analytical processing) database. It is normal to keep consistency in the TP part, but for the AP part, is it necessary to keep consistency? If there is an update in the table, does the customer really need to get the latest data from the AP part? Here we still choose “YES”, we want our customers to focus on their business and not worry whether the query data result is consistent of not. Of course, keeping consistency in the database comes at a cost. Now we have been trying our best to optimize the latency and performance problems :sob: IMO, we choose a right way. We now have supported strong consistency at first, and then we can provide a loose consistency for performance too, but on the other hand, if we only build a loose consistent database at first, it is hard to provide a strong consistency for the customers.