Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to Set Dynamic Minimum Chunk Size #854

Open
wants to merge 2 commits into
base: 3.x
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions bin/pt-online-schema-change
Original file line number Diff line number Diff line change
Expand Up @@ -10099,6 +10099,12 @@ sub main {
my $avg_rate = 0; # rows/second
my $limit = $o->get('chunk-size-limit'); # brevity
my $chunk_time = $o->get('chunk-time'); # brevity
my $min_chunk_size = $o->get('dynamic-min-chunk-size');
# Exit if the user passes a value less than 1
if ($min_chunk_size < 1) {
_die("The value passed for --dynamic-min-chunk-size is less than 1. Please pass a value greater than or equal to 1.");
}
print ts("Minimum chunk size is $min_chunk_size\n");

my $callbacks = {
init => sub {
Expand Down Expand Up @@ -10312,6 +10318,12 @@ sub main {
$tbl->{nibble_time}, # is this amount of time
);

# Enforce minimum chunk size. If the value is lower than the specified min, update
# the chunk size value accordingly.
if ($tbl->{chunk_size} < $min_chunk_size) {
$tbl->{chunk_size} = $min_chunk_size;
}

if ( $tbl->{chunk_size} < 1 ) {
# This shouldn't happen. WeightedAvgRate::update() may
# return a value < 1, but minimum chunk size is 1.
Expand Down Expand Up @@ -13298,6 +13310,14 @@ them. The existing rows which contain NULL values will be converted to the defau
based on datatype, e.g. 0 for number datatypes, '' for string datatypes.
New rows will use the user defined default value if specified for the column.

=item --dynamic-min-chunk-size

type: int; default: 1

When using dynamic chunk sizing, do not copy chunks smaller than this desired minimum chunk size.

The minimum value for this option is 1 and default value is 1.

=item --only-same-schema-fks

Check foreigns keys only on tables on the same schema than the original table.
Expand Down