{"record":{"id":"719bd534da301b66","repo":"influxdata/influxdb","slug":"database-not-found-db-name-query-executor","errorCode":null,"errorMessage":"database not found: {db_name}","messagePattern":"database not found: (.+?)","errorType":"exception","errorClass":"QueryExecutorError","httpStatus":null,"severity":"error","filePath":"influxdb3_internal_api/src/query_executor.rs","lineNumber":25,"sourceCode":"use datafusion::physical_plan::memory::MemoryStream;\nuse influxdb_influxql_parser::statement::Statement;\nuse influxdb3_catalog::catalog::Catalog;\nuse iox_query::query_log::QueryLogEntries;\nuse iox_query::{QueryDatabase, QueryNamespace};\nuse iox_query_influxql::show_databases::{InfluxQlShowDatabases, generate_metadata};\nuse iox_query_influxql::show_retention_policies::InfluxQlShowRetentionPolicies;\nuse iox_query_params::StatementParams;\nuse 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(","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_internal_api/src/query_executor.rs#L7-L43","documentation":"`QueryExecutorError::DatabaseNotFound` is returned by the internal query executor when a query targets a database that does not exist in the catalog. It carries the missing `db_name` and renders as \"database not found: {db_name}\".","triggerScenarios":"Executing a query via the internal query executor against a `db_name` that was deleted or never created; typos in database names resolved through the catalog.","commonSituations":"Environment mismatch (querying a DB that exists in prod but not locally); database dropped by retention/policy or manually; case-sensitivity or whitespace mistakes in the name.","solutions":["Check the exact database name with the catalog/API listing","Create the database before querying (`influxdb3 create database <name>`)","Fix typos and stray whitespace in the db_name parameter"],"exampleFix":"// before\nexecutor.query(\"my-db \")...  // trailing whitespace\n// after\nexecutor.query(\"my-db\")...  // after confirming the database exists","handlingStrategy":"try-catch","validationCode":"// rust: check existence before querying\nif !catalog.database_exists(db_name) {\n    return Err(anyhow!(\"database {db_name} does not exist\"));\n}","typeGuard":null,"tryCatchPattern":"// rust\nmatch executor.query(db_name, ...).await {\n    Err(QueryExecutorError::DatabaseNotFound { db_name }) => {\n        eprintln!(\"database '{db_name}' not found; create it or check the name\")\n    }\n    other => other?,\n}","preventionTips":["Validate database names against the catalog before querying","Trim and normalize db_name inputs","Recreate databases explicitly after environment resets"],"tags":["database","query","not-found"],"backgroundTag":"entity-not-found","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"}