{"record":{"id":"444b9a4dcd8c9ccb","repo":"influxdata/influxdb","slug":"unexpected-error-0-provider","errorCode":null,"errorMessage":"unexpected error: {0:#}","messagePattern":"unexpected error: (.+?)","errorType":"exception","errorClass":"ProviderError","httpStatus":null,"severity":"error","filePath":"influxdb3_cache/src/distinct_cache/provider.rs","lineNumber":21,"sourceCode":"use super::{\n    CacheError,\n    cache::{CreateDistinctCacheArgs, DistinctCache},\n};\nuse arrow::datatypes::SchemaRef;\nuse influxdb3_catalog::catalog::{Catalog, CatalogEvent, CatalogUpdateReceiver, IfNotDeleted};\nuse influxdb3_id::{DbId, DistinctCacheId, TableId};\nuse influxdb3_wal::{WalContents, WalOp};\nuse iox_time::TimeProvider;\nuse observability_deps::tracing::error;\nuse parking_lot::RwLock;\n\n#[derive(Debug, thiserror::Error)]\npub enum ProviderError {\n    #[error(\"cache error: {0}\")]\n    Cache(#[from] CacheError),\n    #[error(\"cache not found\")]\n    CacheNotFound,\n    #[error(\"unexpected error: {0:#}\")]\n    Unexpected(#[from] anyhow::Error),\n}\n\n/// Triple nested map for storing a multiple distinct value caches per table.\n///\n/// That is, the map nesting is `database -> table -> cache id`\ntype CacheMap = RwLock<HashMap<DbId, HashMap<TableId, HashMap<DistinctCacheId, DistinctCache>>>>;\n\n/// Provides the distinct value caches for the running instance of InfluxDB\n#[derive(Debug)]\npub struct DistinctCacheProvider {\n    pub(crate) time_provider: Arc<dyn TimeProvider>,\n    pub(crate) catalog: Arc<Catalog>,\n    pub(crate) cache_map: CacheMap,\n}\n\nimpl DistinctCacheProvider {\n    /// Initialize a [`DistinctCacheProvider`] from a [`Catalog`], populating the provider's","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_cache/src/distinct_cache/provider.rs#L3-L39","documentation":"ProviderError::Unexpected wraps any anyhow::Error raised inside the distinct cache provider that does not map to a specific cache error, exposing it with the format \"unexpected error: {0:#}\". It indicates an internal/unanticipated failure (e.g. poisoning, unexpected state, lower-level issue) rather than a normal caller-facing condition. The {0:#} alternate formatting renders the anyhow error chain readably.","triggerScenarios":"Any ?-propagated anyhow::Error inside provider code paths (e.g. unexpected internal state while creating, deleting, or reading a distinct cache); bugs in the cache subsystem that are not classified as CacheError.","commonSituations":"Hitting a code path the library authors did not anticipate, such as concurrent creation racing with deletion; internal invariants broken in the nested map; bugs surfaced after a library version upgrade; misconfiguration that only fails deep inside provider internals.","solutions":["Inspect the wrapped anyhow error chain in the message ({0:#} prints the full context chain) to find the root cause","Check for concurrent operations on the same cache (create/delete/write races) and serialize them","Reproduce with the same inputs and file an issue with the error chain if it looks like a library bug","Pin or bump the influxdb3_cache version to rule out a known regression"],"exampleFix":"// before\nlet cache = provider.create_cache(db, table, id, cfg)?; // Unexpected bubbles up opaquely\n// after\nif let Err(e) = provider.create_cache(db, table, id, cfg) {\n    tracing::error!(error = ?e, \"distinct cache provider failed\");\n    return Err(e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn is_unexpected(err: &ProviderError) -> bool {\n    matches!(err, ProviderError::Unexpected(_))\n}","tryCatchPattern":"match result {\n    Err(ProviderError::Unexpected(cause)) => {\n        // log full anyhow chain and escalate — this is an internal bug\n        tracing::error!(\"unexpected provider failure: {cause:#}\");\n    }\n    other => other?,\n}","preventionTips":["Log the full formatted error chain ({:#}) for root-cause analysis","Avoid concurrent create/delete of the same cache without synchronization","Report reproducible Unexpected errors upstream — they usually indicate library bugs"],"tags":["unexpected-error","anyhow","internal","rust"],"backgroundTag":"internal-invariant-violation","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"}