@@ -546,6 +546,19 @@ pub async fn command(config: Config) -> Result<()> {
546
546
let f = SendPanicsToTracing :: new_with_metrics ( & metrics) ;
547
547
std:: mem:: forget ( f) ;
548
548
549
+ // hmmm when you have extra executor, you need extra metrics! This is expected to be a
550
+ // singleton
551
+ let write_path_metrics = setup_metric_registry ( ) ;
552
+
553
+ // Install custom panic handler and forget about it.
554
+ //
555
+ // This leaks the handler and prevents it from ever being dropped during the
556
+ // lifetime of the program - this is actually a good thing, as it prevents
557
+ // the panic handler from being removed while unwinding a panic (which in
558
+ // turn, causes a panic - see #548)
559
+ let write_path_panic_handler_fn = SendPanicsToTracing :: new_with_metrics ( & write_path_metrics) ;
560
+ std:: mem:: forget ( write_path_panic_handler_fn) ;
561
+
549
562
// Construct a token to trigger clean shutdown
550
563
let frontend_shutdown = CancellationToken :: new ( ) ;
551
564
let shutdown_manager = ShutdownManager :: new ( frontend_shutdown. clone ( ) ) ;
@@ -619,6 +632,30 @@ pub async fn command(config: Config) -> Result<()> {
619
632
Arc :: clone ( & metrics) ,
620
633
) ,
621
634
) ) ;
635
+
636
+ // Note: using same metrics registry causes runtime panic.
637
+ let write_path_executor = Arc :: new ( Executor :: new_with_config_and_executor (
638
+ ExecutorConfig {
639
+ // should this be divided? or should this contend for threads with executor that's
640
+ // setup for querying only
641
+ target_query_partitions : tokio_datafusion_config. num_threads . unwrap ( ) ,
642
+ object_stores : [ & parquet_store]
643
+ . into_iter ( )
644
+ . map ( |store| ( store. id ( ) , Arc :: clone ( store. object_store ( ) ) ) )
645
+ . collect ( ) ,
646
+ metric_registry : Arc :: clone ( & write_path_metrics) ,
647
+ // use as much memory for persistence, can this be UnboundedMemoryPool?
648
+ mem_pool_size : usize:: MAX ,
649
+ } ,
650
+ DedicatedExecutor :: new (
651
+ "datafusion_write_path" ,
652
+ tokio_datafusion_config
653
+ . builder ( )
654
+ . map_err ( Error :: TokioRuntime ) ?,
655
+ Arc :: clone ( & write_path_metrics) ,
656
+ ) ,
657
+ ) ) ;
658
+
622
659
let runtime_env = exec. new_context ( ) . inner ( ) . runtime_env ( ) ;
623
660
register_iox_object_store ( runtime_env, parquet_store. id ( ) , Arc :: clone ( & object_store) ) ;
624
661
@@ -685,7 +722,7 @@ pub async fn command(config: Config) -> Result<()> {
685
722
last_cache,
686
723
distinct_cache,
687
724
time_provider : Arc :: < SystemProvider > :: clone ( & time_provider) ,
688
- executor : Arc :: clone ( & exec ) ,
725
+ executor : Arc :: clone ( & write_path_executor ) ,
689
726
wal_config,
690
727
parquet_cache,
691
728
metric_registry : Arc :: clone ( & metrics) ,
0 commit comments