Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion docs/graphman.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ 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.

### COSTS

- Rewriting blocks writes much more WAL than the compressed blocks take up: about 1.6 times the old size of the
Expand All @@ -446,7 +455,7 @@ where Postgres supports `client_connection_check_interval`.
1 GiB and the size of the index of the `blocks` table's TOAST table, or half again as much for blocks of a few
KB, whose TOAST chunks leave some space unused (plus, when uncompressing, the difference between the
uncompressed and compressed size of the blocks), and `pg_wal` room for the WAL written until the next
checkpoint and for any WAL that replication slots or archiving hold back.
checkpoint plus up to `--max-wal-backlog` that replication slots or archiving hold back.
- Filesystem snapshots and incremental backups keep the old blocks, so the space on their disks is only freed
once they expire.

Expand All @@ -465,6 +474,8 @@ blocks again.
- `--max-rate`: how many MB of WAL the server may write per second at most. The default is 20
- `--vacuum-every`: run `VACUUM` after rewriting this many GB of blocks. The default is the size of the index of
the TOAST table of the `blocks` table, but at least 1 GiB, since each `VACUUM` reads all of that index
- `--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 {
/// size of the index of the TOAST table, but at least 1 GiB
#[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