refactor(frontend): drop dead trace reconcile error messages (#10858)

* refactor(frontend): drop unused OTLP trace reconcile error text

choose_trace_reconcile_decision built InvalidParameter errors whose
message was never read: schema planning turns any error into a batch
exclusion, and per-chunk reconciliation replaces it with the
column-specific enrich_trace_reconcile_error. Return the existing
TraceCoerceError instead.

Also remove the test-only TraceRequestSchema::remove_batches, which
modelled exclusion differently from production
(exclude_trace_v1_schema_observations rebuilds the schema and is tested
directly), and reword two comments that carried a private marker.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* docs(frontend): describe what a stale trace aux cache key suppresses

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
This commit is contained in:
dennis zhuang
2026-12-03 05:13:50 +00:00
committed by GitHub
parent 236febdd2a
commit aa742b6565
3 changed files with 33 additions and 76 deletions
+4 -22
View File
@@ -66,8 +66,8 @@ use crate::metrics::{
/// Confirmed auxiliary writes, shared across requests and instance clones.
///
/// ponytail: these tables are ingestion-managed; add invalidation if external
/// mutations must be supported without restarting every serving frontend.
/// External mutations do not invalidate cached keys, so ingestion can skip
/// recreating a deleted row until the key is evicted or the frontend restarts.
#[derive(Clone)]
pub(crate) struct TraceAuxCache {
entries: Cache<TraceAuxCacheKey, ()>,
@@ -869,23 +869,6 @@ impl TraceRequestSchema {
pending_rewrites
}
#[cfg(test)]
fn remove_batches(&mut self, batch_indexes: &HashSet<usize>) {
for column in &mut self.columns {
column
.batches
.retain(|batch_index, _| !batch_indexes.contains(batch_index));
column.target_type = None;
}
self.columns.retain(|column| !column.batches.is_empty());
self.column_indexes.clear();
for (index, column) in self.columns.iter().enumerate() {
self.column_indexes
.insert(column.schema.column_name.clone(), index);
}
}
#[cfg(test)]
fn resolved_target_types(&self) -> Vec<Option<ColumnDataType>> {
self.columns
@@ -1383,9 +1366,8 @@ impl Instance {
let output = self
.insert_trace_requests(requests, pipeline, Arc::new(aux_ctx))
.await?;
// ponytail: cache skip_wal writes too. After datanode data loss, lookup
// rows may stay missing until eviction/restart; require durable writes
// before caching if that limitation becomes unacceptable.
// skip_wal writes are cached too, so after datanode data loss lookup
// rows may stay missing until the entry is evicted or the frontend restarts.
self.trace_aux_cache.record(keys);
Ok(output)
}
@@ -1006,14 +1006,6 @@ fn test_trace_request_schema_isolates_non_candidate_new_column_batch() {
request_schema.incompatible_schema_observations(None),
HashMap::from([(column_name.to_string(), HashSet::from([binary_batch]),)])
);
request_schema.remove_batches(&HashSet::from([binary_batch]));
let plan = ready_plan(request_schema.resolve_table_schema(None));
assert_eq!(plan.ensure_columns.len(), 1);
assert_eq!(
plan.ensure_columns[0].datatype,
ColumnDataType::Int64 as i32
);
}
}
@@ -1039,15 +1031,6 @@ fn test_trace_request_schema_isolates_unsupported_type_batches() {
exclusions,
HashMap::from([(mixed_column.to_string(), HashSet::from([0, 1]))])
);
let batch_indexes = exclusions
.values()
.flatten()
.copied()
.collect::<HashSet<_>>();
request_schema.remove_batches(&batch_indexes);
let plan = ready_plan(request_schema.resolve_table_schema(None));
assert!(!plan.requires_ddl());
}
#[test]
+29 -37
View File
@@ -14,10 +14,10 @@
use api::v1::value::ValueData;
use api::v1::{ColumnDataType, Row, Rows};
use servers::error::{self, Result as ServerResult};
use servers::error;
use servers::otlp::coerce::{
coerce_value_data, is_supported_trace_coercion, resolve_new_trace_column_type,
trace_value_datatype,
TraceCoerceError, coerce_value_data, is_supported_trace_coercion,
resolve_new_trace_column_type, trace_value_datatype,
};
use crate::instance::otlp::trace_semconv::trace_semconv_fixed_type;
@@ -128,24 +128,19 @@ impl PreparedTraceColumnRewrites {
///
/// Existing table schema is authoritative unless the only incompatible case is
/// widening an existing Int64 column to Float64 for incoming Int64/Float64 data.
/// Callers attach the table and column context to an unsupported mix.
pub(super) fn choose_trace_reconcile_decision(
column_name: &str,
observed_types: &[ColumnDataType],
existing_type: Option<ColumnDataType>,
) -> ServerResult<Option<TraceReconcileDecision>> {
) -> Result<Option<TraceReconcileDecision>, TraceCoerceError> {
if let Some(fixed_type) = trace_semconv_fixed_type(column_name) {
return choose_fixed_trace_reconcile_decision(fixed_type, observed_types, existing_type);
}
let Some(existing_type) = existing_type else {
return resolve_new_trace_column_type(observed_types.iter().copied())
.map(|target_type| target_type.map(TraceReconcileDecision::UseRequestLocal))
.map_err(|_| {
error::InvalidParameterSnafu {
reason: "unsupported trace type mix".to_string(),
}
.build()
});
.map(|target_type| target_type.map(TraceReconcileDecision::UseRequestLocal));
};
if observed_types.iter().all(|&request_type| {
@@ -168,17 +163,14 @@ pub(super) fn choose_trace_reconcile_decision(
)));
}
error::InvalidParameterSnafu {
reason: "unsupported trace type mix".to_string(),
}
.fail()
Err(TraceCoerceError::Unsupported)
}
fn choose_fixed_trace_reconcile_decision(
fixed_type: ColumnDataType,
observed_types: &[ColumnDataType],
existing_type: Option<ColumnDataType>,
) -> ServerResult<Option<TraceReconcileDecision>> {
) -> Result<Option<TraceReconcileDecision>, TraceCoerceError> {
let Some(existing_type) = existing_type else {
return Ok(Some(TraceReconcileDecision::UseRequestLocal(fixed_type)));
};
@@ -199,10 +191,7 @@ fn choose_fixed_trace_reconcile_decision(
return Ok(Some(TraceReconcileDecision::AlterExistingTo(fixed_type)));
}
error::InvalidParameterSnafu {
reason: "unsupported trace type mix".to_string(),
}
.fail()
Err(TraceCoerceError::Unsupported)
}
/// Prepares an atomic rewrite plan without mutating the input rows.
@@ -333,9 +322,10 @@ mod tests {
use common_error::status_code::StatusCode;
use super::{
PendingTraceColumnRewrite, TraceReconcileDecision, choose_trace_reconcile_decision,
describe_trace_value, enrich_trace_reconcile_error, is_trace_reconcile_candidate_type,
prepare_trace_column_rewrites, push_observed_trace_type, truncate_for_diagnostics,
PendingTraceColumnRewrite, TraceCoerceError, TraceReconcileDecision,
choose_trace_reconcile_decision, describe_trace_value, enrich_trace_reconcile_error,
is_trace_reconcile_candidate_type, prepare_trace_column_rewrites, push_observed_trace_type,
truncate_for_diagnostics,
};
#[test]
@@ -399,13 +389,14 @@ mod tests {
#[test]
fn test_choose_trace_reconcile_decision_existing_int64_with_boolean_is_error() {
let err = choose_trace_reconcile_decision(
"span_attributes.attr_numeric",
&[ColumnDataType::Boolean, ColumnDataType::Int64],
Some(ColumnDataType::Int64),
)
.unwrap_err();
assert_eq!(err.status_code(), StatusCode::InvalidArguments);
assert_eq!(
choose_trace_reconcile_decision(
"span_attributes.attr_numeric",
&[ColumnDataType::Boolean, ColumnDataType::Int64],
Some(ColumnDataType::Int64),
),
Err(TraceCoerceError::Unsupported)
);
}
#[test]
@@ -468,13 +459,14 @@ mod tests {
#[test]
fn test_choose_trace_reconcile_decision_whitelisted_existing_conflicting_type_is_error() {
let err = choose_trace_reconcile_decision(
"span_attributes.server.port",
&[ColumnDataType::Int64],
Some(ColumnDataType::String),
)
.unwrap_err();
assert_eq!(err.status_code(), StatusCode::InvalidArguments);
assert_eq!(
choose_trace_reconcile_decision(
"span_attributes.server.port",
&[ColumnDataType::Int64],
Some(ColumnDataType::String),
),
Err(TraceCoerceError::Unsupported)
);
}
#[test]