cube-js/cube · error · Error

Query cancelled

Error message

Query cancelled

What it means

In MySqlDriver.withConnection, cancelObj.cancel KILLs the connection by its `select connection_id()` id; once cancelled the pending query promise rejects with 'Query cancelled'. This is an active abort of an in-flight MySQL query by the orchestrator or a timeout — the query did not fail on the server. Callers should treat it as cancellation semantics (retry if results are needed) rather than a data or SQL error.

Source

Thrown at packages/cubejs-mysql-driver/src/MySqlDriver.ts:256

  protected withConnection(fn: (conn: MySQLConnection) => Promise<any>) {
    const self = this;
    const connectionPromise = this.pool.acquire();

    let cancelled = false;
    const cancelObj: any = {};

    const promise: any = connectionPromise.then(async conn => {
      const [{ connectionId }] = await conn.execute('select connection_id() as connectionId');
      cancelObj.cancel = async () => {
        cancelled = true;
        await self.withConnection(async processConnection => {
          await processConnection.execute(`KILL ${connectionId}`);
        });
      };
      return fn(conn)
        .then(res => this.pool.release(conn).then(() => {
          if (cancelled) {
            throw new Error('Query cancelled');
          }
          return res;
        }))
        .catch((err) => this.pool.release(conn).then(() => {
          if (cancelled) {
            throw new Error('Query cancelled');
          }
          throw err;
        }));
    });
    promise.cancel = () => cancelObj.cancel();
    return promise;
  }

  public async testConnection() {
    // eslint-disable-next-line no-underscore-dangle
    const conn: MySQLConnection = await (<any> this.pool)._factory.create();

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Fires only because cancel() ran and the cancelled flag was set before fn() returned — expected behaviour for intentional cancellation
  2. If cancellation is unexpected, check query timeouts (executionTimeout, continueWaitTimeout) and client aborts that trigger KILL connection_id()
  3. Verify the MySQL user can run KILL; a failed KILL leaves the query running while the client still sees 'Query cancelled'
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/cubejs-mysql-driver/src/MySqlDriver.ts:256 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/03432cb52857fad6. Report an issue: GitHub.