influxdata/influxdb · error · QueryExecutorError

database not found

Error message

database not found: {db_name}

What it means

`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}".

Solutions

  1. Check the exact database name with the catalog/API listing
  2. Create the database before querying (`influxdb3 create database <name>`)
  3. Fix typos and stray whitespace in the db_name parameter

Example fix

// before
executor.query("my-db ")...  // trailing whitespace
// after
executor.query("my-db")...  // after confirming the database exists
Defensive patterns

Strategy: try-catch

Validate before calling

// rust: check existence before querying
if !catalog.database_exists(db_name) {
    return Err(anyhow!("database {db_name} does not exist"));
}

Try / catch

// rust
match executor.query(db_name, ...).await {
    Err(QueryExecutorError::DatabaseNotFound { db_name }) => {
        eprintln!("database '{db_name}' not found; create it or check the name")
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/719bd534da301b66. Report an issue: GitHub.

Appendix: source

Thrown at influxdb3_internal_api/src/query_executor.rs:25

use datafusion::physical_plan::memory::MemoryStream;
use influxdb_influxql_parser::statement::Statement;
use influxdb3_catalog::catalog::Catalog;
use iox_query::query_log::QueryLogEntries;
use iox_query::{QueryDatabase, QueryNamespace};
use iox_query_influxql::show_databases::{InfluxQlShowDatabases, generate_metadata};
use iox_query_influxql::show_retention_policies::InfluxQlShowRetentionPolicies;
use iox_query_params::StatementParams;
use schema::INFLUXQL_MEASUREMENT_COLUMN_NAME;
use std::fmt::Debug;
use std::sync::Arc;
use trace::ctx::SpanContext;
use trace::span::{Span, SpanExt};
use trace_http::ctx::RequestLogContext;
use tracker::InstrumentedAsyncOwnedSemaphorePermit;

#[derive(Debug, thiserror::Error)]
pub enum QueryExecutorError {
    #[error("database not found: {db_name}")]
    DatabaseNotFound { db_name: String },
    #[error("error while planning query: {0}")]
    QueryPlanning(#[source] DataFusionError),
    #[error("error while executing plan: {0}")]
    ExecuteStream(#[source] DataFusionError),
    #[error("unable to compose record batches from databases: {0}")]
    DatabasesToRecordBatch(#[source] ArrowError),
    #[error("unable to compose record batches from retention policies: {0}")]
    RetentionPoliciesToRecordBatch(#[source] ArrowError),
    #[error("invokded a method that is not implemented: {0}")]
    MethodNotImplemented(&'static str),
    #[error(transparent)]
    Anyhow(#[from] anyhow::Error),
}

#[async_trait]
pub trait QueryExecutor: QueryDatabase + Debug + Send + Sync + 'static {
    async fn get_db_namespace(

View on GitHub (pinned to 06200ef96b)