@@ -38,9 +38,10 @@ use crate::actors::sequencer::{Sequencer, SequencerCommand};
3838use crate :: actors:: { Publisher , UploaderCounters , UploaderType } ;
3939use crate :: metrics:: INDEXER_METRICS ;
4040
41- /// Concurrent upload permits for metrics uploader.
42- /// Uses same permit pool as indexer uploads.
43- static CONCURRENT_UPLOAD_PERMITS_METRICS : OnceLock < Semaphore > = OnceLock :: new ( ) ;
41+ /// Concurrent upload permits for metrics ingest uploads.
42+ static CONCURRENT_UPLOAD_PERMITS_METRICS_INDEX : OnceLock < Semaphore > = OnceLock :: new ( ) ;
43+ /// Concurrent upload permits for metrics merge uploads.
44+ static CONCURRENT_UPLOAD_PERMITS_METRICS_MERGE : OnceLock < Semaphore > = OnceLock :: new ( ) ;
4445
4546/// Stage splits in the metastore, dispatching to the correct RPC based on split kind.
4647async fn stage_splits (
@@ -120,12 +121,24 @@ impl ParquetUploader {
120121 ctx : & ActorContext < Self > ,
121122 ) -> anyhow:: Result < SemaphorePermit < ' static > > {
122123 let _guard = ctx. protect_zone ( ) ;
123- let concurrent_upload_permits = CONCURRENT_UPLOAD_PERMITS_METRICS
124+ let ( concurrent_upload_permits_once_cell, concurrent_upload_permits_gauge) =
125+ match self . uploader_type {
126+ UploaderType :: IndexUploader => (
127+ & CONCURRENT_UPLOAD_PERMITS_METRICS_INDEX ,
128+ INDEXER_METRICS
129+ . available_concurrent_upload_permits
130+ . with_label_values ( [ "metrics_indexer" ] ) ,
131+ ) ,
132+ UploaderType :: MergeUploader | UploaderType :: DeleteUploader => (
133+ & CONCURRENT_UPLOAD_PERMITS_METRICS_MERGE ,
134+ INDEXER_METRICS
135+ . available_concurrent_upload_permits
136+ . with_label_values ( [ "metrics_merger" ] ) ,
137+ ) ,
138+ } ;
139+ let concurrent_upload_permits = concurrent_upload_permits_once_cell
124140 . get_or_init ( || Semaphore :: const_new ( self . max_concurrent_uploads ) ) ;
125- let gauge = INDEXER_METRICS
126- . available_concurrent_upload_permits
127- . with_label_values ( [ "metrics" ] ) ;
128- gauge. set ( concurrent_upload_permits. available_permits ( ) as i64 ) ;
141+ concurrent_upload_permits_gauge. set ( concurrent_upload_permits. available_permits ( ) as i64 ) ;
129142 concurrent_upload_permits
130143 . acquire ( )
131144 . await
@@ -185,7 +198,7 @@ impl Handler<ParquetSplitBatch> for ParquetUploader {
185198 publish_lock : batch. publish_lock ,
186199 publish_token_opt : batch. publish_token_opt ,
187200 parent_span : tracing:: Span :: current ( ) ,
188- _merge_permit_opt : batch. _merge_permit_opt ,
201+ _merge_task_opt : batch. _merge_task_opt ,
189202 } ;
190203 if tx. send ( SequencerCommand :: Proceed ( update) ) . is_err ( ) {
191204 warn ! ( "sequencer receiver dropped for empty batch" ) ;
@@ -223,7 +236,7 @@ impl Handler<ParquetSplitBatch> for ParquetUploader {
223236 let publish_token_opt = batch. publish_token_opt ;
224237 let splits = batch. splits ;
225238 let replaced_split_ids = batch. replaced_split_ids ;
226- let merge_permit_opt = batch. _merge_permit_opt ;
239+ let merge_task_opt = batch. _merge_task_opt ;
227240 // Hold the scratch directory alive until the upload task completes.
228241 // For the merge path, this prevents the TempDirectory from being
229242 // cleaned up before the upload task reads the merged files.
@@ -325,8 +338,8 @@ impl Handler<ParquetSplitBatch> for ParquetUploader {
325338 }
326339
327340 // Create ParquetSplitsUpdate and send downstream.
328- // The merge permit (if present) transfers to the update so it
329- // stays alive until the publisher drops the message .
341+ // The merge task (if present) transfers to the update so the
342+ // planner guard and semaphore permit stay alive until publish .
330343 let update = ParquetSplitsUpdate {
331344 index_uid,
332345 new_splits : splits,
@@ -335,7 +348,7 @@ impl Handler<ParquetSplitBatch> for ParquetUploader {
335348 publish_lock,
336349 publish_token_opt,
337350 parent_span : Span :: current ( ) ,
338- _merge_permit_opt : merge_permit_opt ,
351+ _merge_task_opt : merge_task_opt ,
339352 } ;
340353
341354 if tx. send ( SequencerCommand :: Proceed ( update) ) . is_err ( ) {
@@ -441,7 +454,7 @@ mod tests {
441454 publish_token_opt : None ,
442455 replaced_split_ids : Vec :: new ( ) ,
443456 _scratch_directory_opt : None ,
444- _merge_permit_opt : None ,
457+ _merge_task_opt : None ,
445458 } ;
446459
447460 uploader_mailbox. send_message ( batch) . await . unwrap ( ) ;
@@ -537,7 +550,7 @@ mod tests {
537550 publish_token_opt : None ,
538551 replaced_split_ids : Vec :: new ( ) ,
539552 _scratch_directory_opt : None ,
540- _merge_permit_opt : None ,
553+ _merge_task_opt : None ,
541554 } ;
542555
543556 uploader_mailbox. send_message ( batch) . await . unwrap ( ) ;
@@ -614,7 +627,7 @@ mod tests {
614627 publish_token_opt : None ,
615628 replaced_split_ids : Vec :: new ( ) ,
616629 _scratch_directory_opt : None ,
617- _merge_permit_opt : None ,
630+ _merge_task_opt : None ,
618631 } ;
619632
620633 uploader_mailbox. send_message ( batch) . await . unwrap ( ) ;
@@ -687,7 +700,7 @@ mod tests {
687700 publish_token_opt : None ,
688701 replaced_split_ids : Vec :: new ( ) ,
689702 _scratch_directory_opt : None ,
690- _merge_permit_opt : None ,
703+ _merge_task_opt : None ,
691704 } ;
692705 uploader_mailbox. send_message ( batch) . await . unwrap ( ) ;
693706 }
0 commit comments