@@ -297,17 +297,18 @@ fn compute_repartition_count(
297297 input_size : usize ,
298298 target_size : usize ,
299299 max_partition_count : usize ,
300+ allow_slack : bool ,
300301) -> usize {
301302 let target_size = target_size. max ( 1 ) ;
302303 let effective_target = target_size. min ( COMPUTE_SOFT_MAX_BYTES ) ;
303304 // If the current partition is already within the target, keep the same fan-out
304305 // to avoid pointless recursive repartitioning.
305- if input_size <= effective_target {
306+ if allow_slack && input_size <= effective_target {
306307 return partition_count. min ( max_partition_count) ;
307308 }
308309 // Allow some slack: if we're within 2x of the target, keep the fan-out to avoid
309310 // a costly extra pass when the current size will still fit in memory.
310- if input_size <= effective_target. saturating_mul ( 2 ) {
311+ if allow_slack && input_size <= effective_target. saturating_mul ( 2 ) {
311312 return partition_count. min ( max_partition_count) ;
312313 }
313314
@@ -350,6 +351,7 @@ fn build_repartition_future(
350351 input_size,
351352 target_size,
352353 max_partition_count,
354+ true ,
353355 ) ;
354356 if new_partition_count == max_partition_count
355357 && partition_count < max_partition_count
@@ -683,7 +685,7 @@ impl GraceHashJoinStream {
683685 }
684686 }
685687
686- let skip_load = ( estimated_size > effective_limit
688+ let mut skip_load = ( estimated_size > effective_limit
687689 && work. pass < self . max_partition_passes )
688690 || force_compute_repartition;
689691
@@ -891,8 +893,18 @@ impl GraceHashJoinStream {
891893 self . adaptive_budget . current_limit ( )
892894 } ,
893895 MAX_REPARTITION_PARTITIONS ,
896+ !force_compute_repartition,
894897 ) ;
895- if prospective <= work. partition_count && !force_compute_repartition {
898+ if prospective <= work. partition_count && force_compute_repartition {
899+ debug ! (
900+ "Grace hash join partition {} compute-split planned fan-out {} -> {} (no increase), loading and joining instead" ,
901+ work. partition_id,
902+ work. partition_count,
903+ prospective
904+ ) ;
905+ skip_load = false ;
906+ need_repartition = false ;
907+ } else if prospective <= work. partition_count {
896908 debug ! (
897909 "Grace hash join partition {} already at fan-out {}, skipping repartition (prospective {})" ,
898910 work. partition_id, work. partition_count, prospective
0 commit comments