pgbench: Add --init-batch-size with automatic retry on disconnect #820
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.
Add a new --init-batch-size option to pgbench initialization mode that enables batched commits and automatic reconnection/retry on errors.
The --init-batch-size parameter accepts a value in scale units (same as --scale). When specified, the initialization process commits after each batch instead of using one large transaction. This allows pgbench to recover from network disconnections or other transient errors during long-running initializations that can take hours for multi-TB datasets.
Key features:
The implementation:
Also adds TAP tests to verify the retry behavior works correctly when connections are terminated during initialization.
Example usage:
pgbench -i --scale=1000 --init-batch-size=10 dbname
This commits every 10 scale units (1 million accounts rows per batch).