@@ -543,6 +543,19 @@ pub async fn command(config: Config) -> Result<()> {
543
543
let f = SendPanicsToTracing :: new_with_metrics ( & metrics) ;
544
544
std:: mem:: forget ( f) ;
545
545
546
+ // hmmm when you have extra executor, you need extra metrics! This is expected to be a
547
+ // singleton
548
+ let write_path_metrics = setup_metric_registry ( ) ;
549
+
550
+ // Install custom panic handler and forget about it.
551
+ //
552
+ // This leaks the handler and prevents it from ever being dropped during the
553
+ // lifetime of the program - this is actually a good thing, as it prevents
554
+ // the panic handler from being removed while unwinding a panic (which in
555
+ // turn, causes a panic - see #548)
556
+ let write_path_panic_handler_fn = SendPanicsToTracing :: new_with_metrics ( & write_path_metrics) ;
557
+ std:: mem:: forget ( write_path_panic_handler_fn) ;
558
+
546
559
// Construct a token to trigger clean shutdown
547
560
let frontend_shutdown = CancellationToken :: new ( ) ;
548
561
let shutdown_manager = ShutdownManager :: new ( frontend_shutdown. clone ( ) ) ;
@@ -612,6 +625,30 @@ pub async fn command(config: Config) -> Result<()> {
612
625
Arc :: clone ( & metrics) ,
613
626
) ,
614
627
) ) ;
628
+
629
+ // Note: using same metrics registry causes runtime panic.
630
+ let write_path_executor = Arc :: new ( Executor :: new_with_config_and_executor (
631
+ ExecutorConfig {
632
+ // should this be divided? or should this contend for threads with executor that's
633
+ // setup for querying only
634
+ target_query_partitions : tokio_datafusion_config. num_threads . unwrap ( ) ,
635
+ object_stores : [ & parquet_store]
636
+ . into_iter ( )
637
+ . map ( |store| ( store. id ( ) , Arc :: clone ( store. object_store ( ) ) ) )
638
+ . collect ( ) ,
639
+ metric_registry : Arc :: clone ( & write_path_metrics) ,
640
+ // use as much memory for persistence, can this be UnboundedMemoryPool?
641
+ mem_pool_size : usize:: MAX ,
642
+ } ,
643
+ DedicatedExecutor :: new (
644
+ "datafusion_write_path" ,
645
+ tokio_datafusion_config
646
+ . builder ( )
647
+ . map_err ( Error :: TokioRuntime ) ?,
648
+ Arc :: clone ( & write_path_metrics) ,
649
+ ) ,
650
+ ) ) ;
651
+
615
652
let runtime_env = exec. new_context ( ) . inner ( ) . runtime_env ( ) ;
616
653
register_iox_object_store ( runtime_env, parquet_store. id ( ) , Arc :: clone ( & object_store) ) ;
617
654
@@ -678,7 +715,7 @@ pub async fn command(config: Config) -> Result<()> {
678
715
last_cache,
679
716
distinct_cache,
680
717
time_provider : Arc :: < SystemProvider > :: clone ( & time_provider) ,
681
- executor : Arc :: clone ( & exec ) ,
718
+ executor : Arc :: clone ( & write_path_executor ) ,
682
719
wal_config,
683
720
parquet_cache,
684
721
metric_registry : Arc :: clone ( & metrics) ,
0 commit comments