From c69d36d057efac1755c9a622e79ffbe03d8c74ca Mon Sep 17 00:00:00 2001 From: Ahir Reddy Date: Wed, 21 Aug 2024 15:51:17 -0700 Subject: [PATCH 1/2] min chunk --- bin/pt-online-schema-change | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index d7d118d95..0199070f0 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -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 { @@ -10312,6 +10318,11 @@ sub main { $tbl->{nibble_time}, # is this amount of time ); + # Enforce minimum chunk size + $tbl->{chunk_size} = ($tbl->{chunk_size} < $min_chunk_size) + ? $min_chunk_size + : $tbl->{chunk_size}; + if ( $tbl->{chunk_size} < 1 ) { # This shouldn't happen. WeightedAvgRate::update() may # return a value < 1, but minimum chunk size is 1. @@ -13298,6 +13309,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. From dbbc4f1768fd3ddb63d0e8569bc7f0cb1fd62ae5 Mon Sep 17 00:00:00 2001 From: Ahir Reddy Date: Thu, 22 Aug 2024 14:13:56 -0700 Subject: [PATCH 2/2] better comments --- bin/pt-online-schema-change | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 0199070f0..7f0c9d271 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -10318,10 +10318,11 @@ sub main { $tbl->{nibble_time}, # is this amount of time ); - # Enforce minimum chunk size - $tbl->{chunk_size} = ($tbl->{chunk_size} < $min_chunk_size) - ? $min_chunk_size - : $tbl->{chunk_size}; + # 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