Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
e560a9b
feat(store): pause compressing blocks when WAL or old rows pile up
MoonBoi9001 Dec 3, 2026
7bbe644
docs(graphman): describe the pauses that keep WAL and old rows in check
MoonBoi9001 Dec 3, 2026
2ab4401
fix(store): stop counting other VACUUMs as holding back cleanup
MoonBoi9001 Dec 3, 2026
e4e655d
fix(store): pause compressing blocks when the archiver's lag is unknown
MoonBoi9001 Dec 3, 2026
c9a75ea
fix(store): stop a compress VACUUM when slots or archiving lag
MoonBoi9001 Dec 3, 2026
453c1a5
Merge branch 'mb9/compress-existing-blocks' into mb9/pause-compressin…
MoonBoi9001 Dec 4, 2026
98ea404
Merge branch 'mb9/compress-existing-blocks' into mb9/pause-compressin…
MoonBoi9001 Dec 4, 2026
7d515d0
Merge branch 'mb9/compress-existing-blocks' into mb9/pause-compressin…
MoonBoi9001 Dec 4, 2026
41dec85
Merge branch 'mb9/compress-existing-blocks' into mb9/pause-compressin…
MoonBoi9001 Dec 4, 2026
d86a4be
fix(store): say how to see who holds back VACUUM when details are hidden
MoonBoi9001 Dec 5, 2026
1c9c0ff
Merge branch 'mb9/compress-existing-blocks' into mb9/pause-compressin…
MoonBoi9001 Dec 5, 2026
9c080f5
Merge branch 'mb9/compress-existing-blocks' into mb9/pause-compressin…
MoonBoi9001 Dec 5, 2026
7d5c5d1
Merge branch 'mb9/compress-existing-blocks' into mb9/pause-compressin…
MoonBoi9001 Dec 5, 2026
8d3048c
Merge branch 'mb9/compress-existing-blocks' into mb9/pause-compressin…
MoonBoi9001 Dec 5, 2026
e8485a0
Merge branch 'mb9/compress-existing-blocks' into mb9/pause-compressin…
MoonBoi9001 Dec 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions docs/graphman.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,17 @@ does not answer, or Ctrl-C is pressed again, the command stops at once and close
dies without cancelling what its connections were doing, the server stops that within a few seconds on systems
where Postgres supports `client_connection_check_interval`.

The command also pauses, saying why, while a replication slot or the WAL archiver holds back more than
`--max-wal-backlog` of WAL, while the archiver fails or reports no file it archived, which leaves how far
behind it is unknown, and while a session, replication slot or prepared transaction older than its latest
writes keeps `VACUUM` from removing old rows; it names what holds them back, and ignores other `VACUUM`s,
which hold nothing back. Its `VACUUM` stops, too, when slots or the archiver hold back more than
`--max-wal-backlog` while it runs, and tries again once they have caught up. It needs to see how far replicas
are behind, which a user who is not a superuser can only do with the `pg_read_all_stats` or `pg_monitor`
role, and refuses to start without it when there are replicas. Without that role it can not see the state of
another user's session that holds back `VACUUM` or when its transaction started either, shows those as `?` and
says so.

### COSTS

- Rewriting blocks writes much more WAL than the compressed blocks take up: about 1.6 times the old size of the
Expand All @@ -445,8 +456,8 @@ where Postgres supports `client_connection_check_interval`.
whose TOAST chunks leave some space unused. With a `--vacuum-every` of 50 GB that is 100 GB, or 150 GB for blocks
of a few KB. Add the batches still being written when `VACUUM` is due, up to `--jobs` minus 1 of at most 32 MiB
each, and, when uncompressing, the difference between the uncompressed and compressed size of the blocks.
`pg_wal` needs room for the WAL written until the next checkpoint and for any WAL that replication slots or
archiving hold back.
`pg_wal` needs room for the WAL written until the next checkpoint plus up to `--max-wal-backlog` that
replication slots or archiving hold back.
- `--vacuum-every` is by default the larger of 50 GB and the size of the index of the `blocks` table's TOAST
table.
- Filesystem snapshots and incremental backups keep the old blocks, so the space on their disks is only freed
Expand All @@ -468,6 +479,8 @@ blocks again.
- `--vacuum-every`: run `VACUUM` after rewriting this many GB of blocks. The default is 50, or the size of the
index of the TOAST table of the `blocks` table if that is bigger, since each `VACUUM` reads all of that index.
With small blocks each `VACUUM` also reads most of the TOAST table, so lower values make the run much slower
- `--max-wal-backlog`: pause while a replication slot or the WAL archiver holds back more than this many GB of
WAL. The default is 8
- `--jobs`: how many batches to write at once, each on a connection of its own. The default is 4

### EXAMPLES
Expand Down
17 changes: 16 additions & 1 deletion node/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,10 @@ pub enum CompressBlocksCommand {
/// or the size of the index of the TOAST table if that is bigger
#[clap(long, value_parser = clap::value_parser!(u64).range(1..))]
vacuum_every: Option<u64>,
/// Pause while a replication slot or the WAL archiver holds back
/// more than this many GB of WAL
#[clap(long, default_value = "8", value_parser = clap::value_parser!(u64).range(1..))]
max_wal_backlog: u64,
/// How many batches to write at once, each on a connection of its own;
/// --pool-size is raised to make room for them
#[clap(long, default_value = "4", value_parser = clap::value_parser!(u64).range(1..=1000))]
Expand Down Expand Up @@ -1600,8 +1604,19 @@ async fn main() -> anyhow::Result<()> {
compression,
max_rate,
vacuum_every,
max_wal_backlog,
jobs,
} => run(chain_store, compression, max_rate, vacuum_every, jobs).await,
} => {
run(
chain_store,
compression,
max_rate,
vacuum_every,
max_wal_backlog,
jobs,
)
.await
}
Status => status(chain_store).await,
}
}
Expand Down
2 changes: 2 additions & 0 deletions node/src/manager/commands/compress_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ pub async fn run(
compression: BlockCompression,
max_rate: u64,
vacuum_every: Option<u64>,
max_wal_backlog: u64,
jobs: u64,
) -> Result<(), Error> {
let req = CompressBlocksRequest {
compression,
max_wal_rate: max_rate * MB,
vacuum_every: vacuum_every.map(|gb| gb * GB),
max_wal_backlog: max_wal_backlog * GB,
jobs: jobs as usize,
};
let progress = chain_store
Expand Down
Loading
Loading