{"record":{"id":"806f542395b90c35","repo":"influxdata/influxdb","slug":"unable-to-compose-record-batches-from-retention-policies-0","errorCode":null,"errorMessage":"unable to compose record batches from retention policies: {0}","messagePattern":"unable to compose record batches from retention policies: (.+?)","errorType":"exception","errorClass":"QueryExecutorError","httpStatus":null,"severity":"error","filePath":"influxdb3_internal_api/src/query_executor.rs","lineNumber":33,"sourceCode":"use schema::INFLUXQL_MEASUREMENT_COLUMN_NAME;\nuse std::fmt::Debug;\nuse std::sync::Arc;\nuse trace::ctx::SpanContext;\nuse trace::span::{Span, SpanExt};\nuse trace_http::ctx::RequestLogContext;\nuse tracker::InstrumentedAsyncOwnedSemaphorePermit;\n\n#[derive(Debug, thiserror::Error)]\npub enum QueryExecutorError {\n    #[error(\"database not found: {db_name}\")]\n    DatabaseNotFound { db_name: String },\n    #[error(\"error while planning query: {0}\")]\n    QueryPlanning(#[source] DataFusionError),\n    #[error(\"error while executing plan: {0}\")]\n    ExecuteStream(#[source] DataFusionError),\n    #[error(\"unable to compose record batches from databases: {0}\")]\n    DatabasesToRecordBatch(#[source] ArrowError),\n    #[error(\"unable to compose record batches from retention policies: {0}\")]\n    RetentionPoliciesToRecordBatch(#[source] ArrowError),\n    #[error(\"invokded a method that is not implemented: {0}\")]\n    MethodNotImplemented(&'static str),\n    #[error(transparent)]\n    Anyhow(#[from] anyhow::Error),\n}\n\n#[async_trait]\npub trait QueryExecutor: QueryDatabase + Debug + Send + Sync + 'static {\n    async fn get_db_namespace(\n        &self,\n        database_name: &str,\n        span_ctx: &Option<SpanContext>,\n    ) -> Result<Arc<dyn QueryNamespace>, QueryExecutorError> {\n        self.namespace(\n            database_name,\n            span_ctx.child_span(\"get_db_namespace\"),\n            false,","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_internal_api/src/query_executor.rs#L15-L51","documentation":"This QueryExecutorError::RetentionPoliciesToRecordBatch variant wraps an ArrowError raised while building RecordBatches from retention policy metadata (InfluxQL-era SHOW RETENTION POLICIES style results). It mirrors DatabasesToRecordBatch but for retention-policy rows.","triggerScenarios":"Executing a retention-policy query through the internal executor where Arrow fails while composing batches from retention policy records (schema construction or batch building error).","commonSituations":"Legacy InfluxQL queries against a 3.x instance where retention policy metadata is partially populated; custom retention policy entries with unexpected field values causing Arrow batch build failures.","solutions":["Inspect the wrapped ArrowError to find which field of the retention policy batches fails","Verify retention policy metadata in the catalog is complete and well-formed","Re-run against a single database to isolate the offending retention policy","Update influxdb3 to a version with corrected retention-policy batch composition"],"exampleFix":"// before\nlet rp = executor.show_retention_policies(db).await?; // ArrowError inside\n// after\nmatch executor.show_retention_policies(db).await {\n    Ok(rp) => rp,\n    Err(QueryExecutorError::RetentionPoliciesToRecordBatch(e)) => {\n        eprintln!(\"RP batch compose failed: {e}\");\n        return Err(e.into());\n    }\n    Err(e) => return Err(e),\n}","handlingStrategy":"try-catch","validationCode":"// validate retention policy metadata shape before composing\nif retention_policies.iter().any(|rp| rp.name.is_empty() || rp.duration.is_none()) {\n    return Err(\"malformed retention policy metadata\".into());\n}","typeGuard":"fn is_rp_batch_err(e: &QueryExecutorError) -> Option<&ArrowError> {\n    if let QueryExecutorError::RetentionPoliciesToRecordBatch(ae) = e { Some(ae) } else { None }\n}","tryCatchPattern":"match executor.retention_policies_to_record_batch(&rps) {\n    Ok(b) => Ok(b),\n    Err(QueryExecutorError::RetentionPoliciesToRecordBatch(ae)) => {\n        log::warn!(\"retention policy batch failed: {ae}\");\n        Err(QueryExecutorError::RetentionPoliciesToRecordBatch(ae))\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Keep retention policy metadata complete in the catalog","Test InfluxQL retention-policy queries after upgrades","Isolate per-database composition to find bad entries","Log wrapped ArrowError chains"],"tags":["rust","arrow","retention-policy","record-batch"],"backgroundTag":"database-query-failed","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}