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.

Explaining the Postgres iceberg

201 pointsby avesturaover 1 year ago

10 comments

phamiltonover 1 year ago
We got hit with a good bit of the postgres iceberg this week.<p>VACUUM by default runs with the TRUNCATE option. This will, if possible and valuable, truncate the heap and return those pages to the operating system. This operation takes an AccessExclusive lock, which blocks reads and writes. It is written to be very deferential and only runs if nothing else is trying to take a competing lock.<p>AccessExclusive is a unique lock in that it is replicated to standbys. When the writer holds the lock, reads on the standbys will be blocked. However, the writer doesn&#x27;t know about them, so its conservative approach of only acquiring the lock if there&#x27;s no contention is completely thwarted.<p>Finally, if vacuum truncate is interrupted by lock contention it must repeat a scan of the heap to ensure the blocks are still empty before proceeding with the truncation.<p>All of these details combined meant our writer got stuck in a &quot;grab lock, scan, be interrupted, release lock, grab lock, restart scan, be interrupted, release lock... etc&quot; loop. The replication of this lock to the reader seemed to have batched together, so the readers never got to run in between the loop iterations. The vacuum never actually succeeded because it kept re-scanning. We had to intervene manually to disable autovacuum and cancel the in-progress jobs.<p>We&#x27;ve hit plenty of weird postgres issues, but this was a new one for us.<p>Edit: of note is the somewhat rare lack of clarity in the postgres docs. &quot;VACUUM (without FULL)&quot; is documented as only requiring ShareUpdateExclusive, which is why autovacuum is considered safe to run. Turns out that&#x27;s not true.
评论 #37420194 未加载
评论 #37372390 未加载
ta988over 1 year ago
Regular reminder, icebergs don&#x27;t look like that. <a href="https:&#x2F;&#x2F;joshdata.me&#x2F;iceberger.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;joshdata.me&#x2F;iceberger.html</a>
评论 #37359724 未加载
slotransover 1 year ago
Heh, this is pretty great. Is it good or bad that I know almost all of these?<p>Not sure &quot;SERIAL is non-transactional&quot; belongs at the bottom, I thought that was common knowledge... but that might be from years doing Oracle where sequences are more explicit.
评论 #37358810 未加载
nomilkover 1 year ago
This is a pretty awesome way of summarising a topic. Perhaps an advanced version could offer an ELI5 explanation on hoverover. I&#x27;m in the first or second layer of the postgres version of the meme, yet would gladly spend hours exploring layers I don&#x27;t yet know about (simply reading the names of the ideas in each layer was incredibly interesting tbh).
upon_drumheadover 1 year ago
I struggle to understand why the Halloween Problem is listed as a Postgres issue. The concept that a where condition would run until all rows are condition false is just categorically false for Postgresql.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Halloween_Problem" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Halloween_Problem</a>
评论 #37365929 未加载
评论 #37357624 未加载
ksarwover 1 year ago
This was super neat, really appreciate all the examples :)
the_impover 1 year ago
I am left wondering how far down one must go to find row level security.
hernantzover 1 year ago
Law of Leaky Abstractions states: All non-trivial abstractions, to some degree, are leaky.
azophy_2over 1 year ago
found another youtube video that explain the seme meme<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;JZRWkfXNQOk" rel="nofollow noreferrer">https:&#x2F;&#x2F;youtu.be&#x2F;JZRWkfXNQOk</a>
gsk22over 1 year ago
Are &quot;topic icebergs&quot; really a meme? Sure, they&#x27;re an internet phenomenon, but that doesn&#x27;t automatically qualify as a meme.
评论 #37357876 未加载
评论 #37358041 未加载
评论 #37357884 未加载
评论 #37357829 未加载