Repository navigation
feat(node,store): shrink the blocks table after compressing - #6861
Draft
MoonBoi9001 wants to merge 11 commits into
Draft
MoonBoi9001 wants to merge 11 commits into
MoonBoi9001 wants to merge 11 commits into
Conversation
Rewriting blocks frees space inside the table, but its files stay as big. Add a shrink command for Postgres 17 and later that moves the blocks at the end of the table into that free space and lets VACUUM cut off the empty end, a slice at a time, with the same pacing and pauses.
Explain how compress-blocks shrink gives the space that rewriting blocks freed back to the disk, what it needs, the map it keeps while it works, and what its truncation costs replicas.
Shrinking the blocks table compressed every uncompressed block it moved unless told otherwise, which changed how blocks are stored without being asked. Move blocks as they are by default, and change how they are stored only when --compression is given.
Shrinking kept its map from TOAST values to blocks in an unlogged table in the chain's schema, which an interrupted run left behind. Keep it in a temporary table of the connection that shrinks, and close that connection afterwards, so the map goes away however shrinking ends.
Check that an owner who is no superuser can shrink the blocks table once it may read TOAST tables, and that blocks a node changes or adds while shrinking runs keep what the node wrote.
Shrinking added the missing data_zstd column before it checked that the user owns the blocks table, so a user who does not own it tried to add the column for about a minute. Check first.
The test that shrinks the blocks table as an owner who is no superuser ran VACUUM as the superuser and never checked the result. Run that VACUUM as the owner and check the table shrank.
…-compressed-block-space-back-to-disk
Shrinking moves as many blocks at once as compressing does, which is now up to 10,000, so a batch of big blocks could take GBs of memory. Its batches now also end at 32 MiB of blocks.
…-compressed-block-space-back-to-disk # Conflicts: # store/postgres/src/compress_blocks.rs
…-compressed-block-space-back-to-disk
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
graphman chain compress-blocks <chain> shrink, which gives the space freed by compressing blocks back to the disk. It moves the last blocks in the TOAST table into free space nearer the start, so VACUUM can truncate the end. It needs Postgres 17 or later, plusgrant usage on schema pg_toastfor a user that is not a superuser.