Skip to content

Commit 6a5ae51

Browse files
committed
fix: deadlock in metric pruning
in case schema hashes grow beyond NUM_CPU, deadlock can occur during sort and prune
1 parent c0ce0e5 commit 6a5ae51

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/handlers/http/ingest.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use actix_web::{HttpRequest, HttpResponse, http::header::ContentType};
2424
use arrow_array::RecordBatch;
2525
use bytes::Bytes;
2626
use chrono::Utc;
27+
use once_cell::sync::Lazy;
28+
use rayon::{ThreadPool, ThreadPoolBuilder};
2729
use tokio::sync::oneshot;
2830
use tracing::error;
2931

@@ -55,6 +57,9 @@ use super::modal::utils::ingest_utils::{flatten_and_push_logs, get_custom_fields
5557
use super::users::dashboards::DashboardError;
5658
use super::users::filters::FiltersError;
5759

60+
pub static INGESTION_THREADPOOL: Lazy<ThreadPool> =
61+
Lazy::new(|| ThreadPoolBuilder::new().build().unwrap());
62+
5863
// Handler for POST /api/v1/ingest
5964
// ingests events by extracting stream name from header
6065
// creates if stream does not exist

src/parseable/streams.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use crate::{
5656
DEFAULT_TIMESTAMP_KEY,
5757
format::{LogSource, LogSourceEntry},
5858
},
59-
handlers::DatasetTag,
59+
handlers::{DatasetTag, http::ingest::INGESTION_THREADPOOL},
6060
hottier::StreamHotTier,
6161
metadata::{LogStreamMetadata, SchemaVersion},
6262
metrics,
@@ -757,7 +757,7 @@ impl Stream {
757757
time_partition_field: String,
758758
) -> std::sync::mpsc::Receiver<Result<PreparedMetricRowGroup, StagingError>> {
759759
let (tx, rx) = std::sync::mpsc::sync_channel(1);
760-
rayon::spawn(move || {
760+
INGESTION_THREADPOOL.spawn(move || {
761761
let _ = tx.send(Self::prepare_metric_row_group(
762762
schema,
763763
buffer,

0 commit comments

Comments
 (0)