TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Why CockroachDB doesn't use EvalPlanQual

135 点作者 michae2大约 1 年前

11 条评论

michae2大约 1 年前
Author here. We&#x27;ve spent the past year adding read committed isolation to CockroachDB.<p>There were many interesting design decisions, such as:<p>- whether to use multiple snapshots or a single snapshot per statement<p>- how to handle read uncertainty intervals<p>- how to incorporate SELECT FOR UPDATE locking into Raft<p>- how to handle SELECT FOR UPDATE subqueries<p>- how to prevent lost update anomalies between two UPDATEs<p>Some of the gory details are in the public RFC: <a href="https:&#x2F;&#x2F;github.com&#x2F;cockroachdb&#x2F;cockroach&#x2F;blob&#x2F;master&#x2F;docs&#x2F;RFCS&#x2F;20230122_read_committed_isolation.md">https:&#x2F;&#x2F;github.com&#x2F;cockroachdb&#x2F;cockroach&#x2F;blob&#x2F;master&#x2F;docs&#x2F;RF...</a><p>This blog post just discusses the last point, but please AMA.
评论 #39950217 未加载
评论 #39957772 未加载
foota大约 1 年前
It&#x27;s often talked about how new sql databases offer better scalability than standard SQL databases, but I think it&#x27;s maybe sometimes underappreciated how (some, not all) of them are also much simpler in terms of their consistency models.<p>I&#x27;d speculate this is because postgres and friends try to eek out every bit of single node performance (which helps with single row throughout and overall throughout, which is obviously much better for them than newsql) but the scalability of new SQL databases might allow them to prefer easy consistency over single node performance.<p>Possibly this is also just the passage of time benefiting newer systems.
评论 #39950258 未加载
评论 #39949510 未加载
CGamesPlay大约 1 年前
How does the CockroachDB approach not deadlock? Surely retrying could encounter a situation where two competing UPDATE will lock rows in different order, and no amount of retrying will unlock the required rows, right?
评论 #39950366 未加载
评论 #39950474 未加载
erhaetherth大约 1 年前
I&#x27;m having trouble with the example given.<p>If `UPDATE player SET level = &#x27;AA&#x27; WHERE team = &#x27;Gophers&#x27;;` is executed before the player swap, then why should &quot;Stonebreaker&quot; be upgraded to &quot;AA&quot;? I&#x27;d be pretty mad at my database if I sent those 2 queries <i>in sequence</i> and my DB decided to re-order them.<p>The sleep actually really complicates things here. I understand some queries run slower than others and the sleep is a useful tool to artificially slow things down, but now I don&#x27;t know I don&#x27;t know if I should interpret that as one command or two. If `WITH sleep AS (SELECT pg_sleep(5)) UPDATE player SET level = &#x27;AA&#x27; FROM sleep WHERE team = &#x27;Gophers&#x27;;` is atomic then I&#x27;d expect it to put a lock on the 3 Gophers (which doesn&#x27;t include Stonebreaker), wait the 5 seconds and then complete the update. The player swap would be blocked for those 5 seconds because it touches a row that&#x27;s being updated.
评论 #39949542 未加载
评论 #39950603 未加载
ngalstyan4大约 1 年前
For similar isolation level anomalies in real world applications check out this SIGMOD &#x27;17 paper:<p>ACIDRain: Concurrency-Related Attacks on Database-Backed Web Applications: <a href="http:&#x2F;&#x2F;www.bailis.org&#x2F;papers&#x2F;acidrain-sigmod2017.pdf" rel="nofollow">http:&#x2F;&#x2F;www.bailis.org&#x2F;papers&#x2F;acidrain-sigmod2017.pdf</a>
ramchip大约 1 年前
Great article. The `pg_sleep` is a nice trick to test for concurrency issues in postgres.
jb1991大约 1 年前
I sometimes wonder if the database would be more widely used if they had picked a different name.
评论 #39953124 未加载
评论 #39978839 未加载
评论 #39952257 未加载
评论 #39952965 未加载
评论 #39952426 未加载
CurtHagenlocher大约 1 年前
UPDATE player set name = &#x27;Stonebraker&#x27; where name = &#x27;Stonebreaker&#x27;
评论 #39953483 未加载
qazxcvbnm大约 1 年前
Which of these strategies does Postgres use under Repeatable Read?
评论 #39950516 未加载
slavabobik大约 1 年前
How you incorporate SELECT FOR UPDATE locking into Raft? Also maybe slightly off topic, but how does the CockroachDB deals with read-only queries and raft log?
评论 #39983638 未加载
npstr大约 1 年前
Idk to me this looks like a modeling issue of the data. There should be a team table that contains team specific data such as the skill level, then these two queries wouldn&#x27;t run into any problems.
评论 #39952351 未加载