@@ -60,13 +60,30 @@ ExportPartitionTaskScheduler::ExportPartitionTaskScheduler(StorageReplicatedMerg
6060
6161void ExportPartitionTaskScheduler::run ()
6262{
63+ const auto available_move_executors = storage.background_moves_assignee .getAvailableMoveExecutors ();
64+ if (available_move_executors == 0 )
65+ {
66+ LOG_INFO (storage.log , " ExportPartition scheduler task: No available move executors, skipping" );
67+ return ;
68+ }
69+
70+ LOG_INFO (storage.log , " ExportPartition scheduler task: Available move executors: {}" , available_move_executors);
71+
72+ std::size_t scheduled_exports_count = 0 ;
73+
6374 std::lock_guard lock (storage.export_merge_tree_partition_mutex );
6475
6576 auto zk = storage.getZooKeeper ();
6677
6778 // Iterate sorted by create_time
6879 for (auto & entry : storage.export_merge_tree_partition_task_entries_by_create_time )
6980 {
81+ if (scheduled_exports_count >= available_move_executors)
82+ {
83+ LOG_INFO (storage.log , " ExportPartition scheduler task: Scheduled exports count is greater than available move executors, skipping" );
84+ break ;
85+ }
86+
7087 const auto & manifest = entry.manifest ;
7188 const auto key = entry.getCompositeKey ();
7289 const auto database = storage.getContext ()->resolveDatabase (manifest.destination_database );
@@ -144,6 +161,12 @@ void ExportPartitionTaskScheduler::run()
144161
145162 for (const auto & zk_part_name : parts_in_processing_or_pending)
146163 {
164+ if (scheduled_exports_count >= available_move_executors)
165+ {
166+ LOG_INFO (storage.log , " ExportPartition scheduler task: Scheduled exports count is greater than available move executors, skipping" );
167+ break ;
168+ }
169+
147170 if (locked_parts_set.contains (zk_part_name))
148171 {
149172 LOG_INFO (storage.log , " ExportPartition scheduler task: Part {} is locked, skipping" , zk_part_name);
@@ -157,6 +180,8 @@ void ExportPartitionTaskScheduler::run()
157180 continue ;
158181 }
159182
183+ LOG_INFO (storage.log , " ExportPartition scheduler task: Scheduling part export: {}" , zk_part_name);
184+
160185 std::lock_guard part_export_lock (storage.export_manifests_mutex );
161186
162187 auto context = getContextCopyWithTaskSettings (storage.getContext (), manifest);
0 commit comments