influxdata/influxdb · error · Error::InfluxqlRetentionPolicyMismatch

provided a retention policy in both the parameters

Error message

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

What it means

Thrown when a retention policy is provided both in the request parameter (`rp`) and inside the query string, and the two values differ. Like the database mismatch case, the API rejects the request instead of guessing. The message includes both `param_rp` and `query_rp` values.

Solutions

  1. Make the `rp` parameter and the query retention policy identical.
  2. Remove the `rp` parameter when the query already qualifies the retention policy.
  3. Update the client/datasource default `rp` to match the queries being issued.

Example fix

// before
GET /query?db=mydb&rp=autogen&q=SELECT+*+FROM+"mydb"."downsampled".cpu
// after
GET /query?db=mydb&rp=downsampled&q=SELECT+*+FROM+"mydb"."downsampled".cpu
Defensive patterns

Strategy: validation

Validate before calling

function assertRpConsistent(rpParam, q) {
  const m = /FROM\s+"[\w-]+"\s*\.\s*"([\w-]+)"\s*\./.exec(q);
  if (rpParam && m && m[1] !== rpParam) {
    throw new Error(`rp mismatch: param=${rpParam} query=${m[1]}`);
  }
}

Prevention

When it happens

Trigger: GET/POST to the v1 /query endpoint with `rp=autogen` and a query qualified with a different retention policy, e.g. `?db=mydb&rp=autogen&q=SELECT * FROM "mydb"."downsampled".cpu`.

Common situations: Clients with a default `rp` setting while queries are hand-written with another RP; environment drift between staging and production retention policies; templated queries overriding the connection-level rp.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

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

    #[error("error in InfluxQL statement: {0}")]
    InfluxqlRewrite(#[from] rewrite::Error),

    #[error("must provide only one InfluxQl statement per query")]
    InfluxqlSingleStatement,

    #[error("must specify a 'db' parameter, or provide the database in the InfluxQL query")]
    InfluxqlNoDatabase,

    #[error(
        "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),

View on GitHub (pinned to 06200ef96b)