influxdata/influxdb · error · Error::Database

Cannot retrieve database

Error message

Cannot retrieve database: {0}

What it means

Thrown when the API cannot retrieve the target database, wrapping a DataFusionError (`Database(DataFusionError)`). Unlike DatabaseNotFound, this means the lookup of the database itself failed inside DataFusion (planning/execution failure), not that the database is simply absent. The wrapped error describes the underlying failure.

Solutions

  1. Inspect the wrapped DataFusionError ({0}) for the root cause.
  2. Confirm the catalog/backend serving the database is healthy and reachable.
  3. Retry the request if the failure is transient (storage timeout, etc.).
  4. Verify the database name is well-formed for the target namespace.
Defensive patterns

Strategy: retry

Validate before calling

async function queryDbSafe(db, q, opts = { attempts: 2 }) {
  for (let i = 0; i < opts.attempts; i++) {
    try { return await queryV1({ db, q }); }
    catch (e) {
      if (/Cannot retrieve database/.test(e.message) && i < opts.attempts - 1) continue;
      throw e;
    }
  }
}

Type guard

function isDbRetrievalError(e) {
  return e instanceof Error && e.message.startsWith('Cannot retrieve database:');
}

Try / catch

try {
  await queryV1({ db, q });
} catch (e) {
  if (/Cannot retrieve database/.test(e.message)) {
    alertOps('catalog/storage failure resolving database', e);
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Executing a v1 /query request where resolving the database (e.g. listing or opening the namespace/table provider through DataFusion) raises a DataFusionError instead of a clean not-found.

Common situations: Backend/catalog errors while opening the namespace; transient storage or catalog failures; DataFusion context misconfiguration after version upgrades.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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

Appendix: source

Thrown at core/iox_v1_query_api/src/error.rs:80

        "provided a database in both the parameters ({param_db}) and \
        query string ({query_db}) that do not match, if providing a query \
        that specifies the database, you can omit the 'database' parameter \
        from your request"
    )]
    InfluxqlDatabaseMismatch { param_db: String, query_db: String },

    #[error(
        "provided a retention policy in both the parameters ({param_rp}) and \
        query string ({query_rp}) that do not match, if providing a query \
        that specifies the retention_policy, you can omit the 'rp' parameter \
        from your request"
    )]
    InfluxqlRetentionPolicyMismatch { param_rp: String, query_rp: String },

    #[error("error reading field from body: {name} -- {error}")]
    FieldRead { name: &'static str, error: String },

    #[error("Cannot retrieve database: {0}")]
    Database(DataFusionError),

    #[error("Database {0} not found")]
    DatabaseNotFound(String),

    #[error("v1 query API error: {0}")]
    V1Query(#[from] QueryError),
}

#[derive(Debug, Clone)]
pub enum HttpError {
    NotFound(String),
    Unauthorized(String),
    Invalid(String),
    InternalError(String),
}

impl From<Error> for HttpError {

View on GitHub (pinned to 06200ef96b)