t8y2/dbx · error

query timed out after %ds

Error message

query timed out after %ds

What it means

The driver wraps statement execution with a context timeout; when the timeout elapses (timedOut branch) it cancels the context, closes any rows, and returns queryErr = fmt.Errorf("query timed out after %ds", timeoutSecs) instead of rows. Callers such as listIndexes, the DDL helpers, and integration tests treat a nil queryErr as success and merge results.

Source

Thrown at agents/drivers/oracle-go/main.go:5112

			return nil, err
		}
		rows, queryErr = db.QueryContext(ctx, sqlText, args...)
	}
	s.activeCancelMu.Lock()
	s.activeCancel = nil
	if s.activeTimer != nil {
		s.activeTimer.Stop()
		s.activeTimer = nil
	}
	timedOut := s.activeTimedOut
	if queryErr != nil {
		cancel()
	} else if timedOut {
		cancel()
		if rows != nil {
			rows.Close()
		}
		queryErr = fmt.Errorf("query timed out after %ds", timeoutSecs)
	} else {
		s.activeRows[rows] = cancel
	}
	s.activeCancelMu.Unlock()
	return rows, queryErr
}

func (s *server) cancelActiveQuery() {
	s.activeCancelMu.Lock()
	cancels := make([]context.CancelFunc, 0, len(s.activeRows)+1)
	if s.activeCancel != nil {
		cancels = append(cancels, s.activeCancel)
	}
	for _, cancel := range s.activeRows {
		cancels = append(cancels, cancel)
	}
	s.activeCancelMu.Unlock()
	for _, cancel := range cancels {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Increase the query timeout (raise the timeoutSecs / context timeout passed to the driver).
  2. Retry the specific metadata query — transient load often causes this; add backoff around listIndexes/DDL calls.
  3. Narrow the metadata query scope (filter by schema/table instead of listing everything).
  4. Check DB-side health: slow queries, GC pauses, network latency between client and server.

Example fix

// before
rows, err := s.queryWithTimeout(ctx, 5, query)
// after
rows, err := s.queryWithTimeout(ctx, 60, query) // larger budget for large catalogs
Defensive patterns

Strategy: retry

Validate before calling

// no pre-call validation possible; ensure timeout budget is adequate for catalog size
estTables := countTables(); timeout := max(30, estTables/100) // seconds

Try / catch

for attempt := 0; attempt < 3; attempt++ {
	indexes, err := drv.ListIndexes(schema, table)
	if err != nil && strings.Contains(err.Error(), "query timed out") {
		time.Sleep(backoff(attempt)); continue
	}
	return indexes, err
}

Prevention

When it happens

Trigger: Any query executed through the timed-query helper (used by listIndexes, getTreeDialectDDL, getTableDialectDDL, TestKingbaseIntegration, and cassandra-go metadata.querySystemIndexes) taking longer than timeoutSecs — e.g. slow system-catalog queries on huge schemas or an unresponsive DB node.

Common situations: Introspecting a database with thousands of tables/indexes over a WAN, a Cassandra/Oracle node under load or doing GC pauses, network latency or packet loss, or a timeout value configured too low for large catalogs.

Understand the failure class

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/007d55780268e7a3. Report an issue: GitHub.