-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat: separate out write path executor with unbounded memory limit #26455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
//! Entrypoint for InfluxDB 3 Core Server | ||
|
||
use anyhow::{Context, bail}; | ||
use datafusion_util::config::register_iox_object_store; | ||
use futures::{FutureExt, future::FusedFuture, pin_mut}; | ||
use influxdb3_authz::TokenAuthenticator; | ||
use influxdb3_cache::{ | ||
|
@@ -546,6 +545,20 @@ pub async fn command(config: Config) -> Result<()> { | |
let f = SendPanicsToTracing::new_with_metrics(&metrics); | ||
std::mem::forget(f); | ||
|
||
// When you have extra executor, you need separate metrics registry! It is not clear what | ||
// the impact would be | ||
// TODO: confirm this is not going to mess up downstream metrics consumers | ||
let write_path_metrics = setup_metric_registry(); | ||
|
||
// Install custom panic handler and forget about it. | ||
// | ||
// This leaks the handler and prevents it from ever being dropped during the | ||
// lifetime of the program - this is actually a good thing, as it prevents | ||
// the panic handler from being removed while unwinding a panic (which in | ||
// turn, causes a panic - see #548) | ||
let write_path_panic_handler_fn = SendPanicsToTracing::new_with_metrics(&write_path_metrics); | ||
std::mem::forget(write_path_panic_handler_fn); | ||
|
||
// Construct a token to trigger clean shutdown | ||
let frontend_shutdown = CancellationToken::new(); | ||
let shutdown_manager = ShutdownManager::new(frontend_shutdown.clone()); | ||
|
@@ -619,8 +632,36 @@ pub async fn command(config: Config) -> Result<()> { | |
Arc::clone(&metrics), | ||
), | ||
)); | ||
let runtime_env = exec.new_context().inner().runtime_env(); | ||
register_iox_object_store(runtime_env, parquet_store.id(), Arc::clone(&object_store)); | ||
|
||
// Note: using same metrics registry causes runtime panic. | ||
let write_path_executor = Arc::new(Executor::new_with_config_and_executor( | ||
ExecutorConfig { | ||
// should this be divided? or should this contend for threads with executor that's | ||
// setup for querying only | ||
target_query_partitions: tokio_datafusion_config.num_threads.unwrap(), | ||
object_stores: [&parquet_store] | ||
.into_iter() | ||
.map(|store| (store.id(), Arc::clone(store.object_store()))) | ||
.collect(), | ||
metric_registry: Arc::clone(&write_path_metrics), | ||
// use as much memory for persistence, can this be UnboundedMemoryPool? | ||
mem_pool_size: usize::MAX, | ||
// These are new additions, just skimming through the code it does not look like we can | ||
// achieve the same effect as having a separate executor. It looks like it's for "all" | ||
// queries, it'd be nice to have a filter to say when the query matches this pattern | ||
// apply these limits. If that's possible maybe we could avoid creating a separate | ||
// executor. | ||
per_query_mem_pool_config: PerQueryMemoryPoolConfig::Disabled, | ||
heap_memory_limit: None, | ||
Comment on lines
+649
to
+655
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, these came in from |
||
}, | ||
DedicatedExecutor::new( | ||
"datafusion_write_path", | ||
tokio_datafusion_config | ||
.builder() | ||
.map_err(Error::TokioRuntime)?, | ||
Arc::clone(&write_path_metrics), | ||
), | ||
)); | ||
|
||
let trace_header_parser = TraceHeaderParser::new() | ||
.with_jaeger_trace_context_header_name( | ||
|
@@ -685,7 +726,7 @@ pub async fn command(config: Config) -> Result<()> { | |
last_cache, | ||
distinct_cache, | ||
time_provider: Arc::<SystemProvider>::clone(&time_provider), | ||
executor: Arc::clone(&exec), | ||
executor: Arc::clone(&write_path_executor), | ||
wal_config, | ||
parquet_cache, | ||
metric_registry: Arc::clone(&metrics), | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely be an issue, since the HTTP endpoint that serves prometheus (
/metrics
) assumes a single registry:influxdb/influxdb3_server/src/http.rs
Lines 734 to 740 in be25c6f
Is the issue that using the same registry for multiple executors causes them to overwrite each other, or contend for locks with each other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It runs into panic,
I can look into the panic and see if I can address that in a different way if this is going to mess downstream consumers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into the code that runs into panic
https://github.com/influxdata/influxdb3_core/blob/fd0e474a6c0af5ba867399d753f5df18f59907cb/iox_query/src/exec.rs#L268-L284
It looks like there is an assumption that you violate single memory pool -> executor relationship if the "datafusion_pool" is already registered. Even though we don't break that relationship, i.e in this branch there are two executors and each has it's own memory pool so the relationship is still correct but because registry is shared it runs into this error.
I need to spend a bit more time to see if I can create the executor outside without hooking it up to metrics to start with (or use a different name for instrument "datafusion_write_pool") and then experiment with how it's reporting.