t8y2/dbx · error

Hive connection is not open

Error message

Hive connection is not open

What it means

requireConnection() returns this error when server.connection is nil, meaning no Hive database connection has been opened (or it was closed). Every operation that needs a connection — metadata calls, query execution, pagination, statement execution, cluster description — funnels through it, so any operation attempted before open or after disconnect surfaces this error.

Source

Thrown at agents/drivers/hive-go/main.go:540

		}
	}
	if database != nil {
		if err := database.Close(); err != nil {
			failures = append(failures, err.Error())
		}
	}
	if len(failures) > 0 {
		return errors.New(strings.Join(failures, "; "))
	}
	return nil
}

func (server *server) requireConnection() (*sql.Conn, error) {
	server.connectionMu.Lock()
	connection := server.connection
	server.connectionMu.Unlock()
	if connection == nil {
		return nil, errors.New("Hive connection is not open")
	}
	return connection, nil
}

func (server *server) setActiveOperation(cancel context.CancelFunc) {
	server.activeMu.Lock()
	server.activeCancel = cancel
	server.activeMu.Unlock()
}

func (server *server) clearActiveOperation(cancel context.CancelFunc) {
	cancel()
	server.activeMu.Lock()
	server.activeCancel = nil
	server.activeMu.Unlock()
}

func (server *server) cancelActiveQuery() {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Open the Hive connection (successful openSession/connect) before issuing any query or metadata call.
  2. Verify no code path disconnects the server while it is still in use; serialize disconnect against query traffic.
  3. Re-open the connection after any error that indicates the session dropped, then retry the operation.
  4. Check the connection state (validateConnection) before executing long-running work.

Example fix

// before
rows, err := srv.Dispatch(queryOptions{SQL: "SELECT 1"}) // fails if not open
// after
if err := srv.Open(); err != nil {
    return err
}
rows, err := srv.Dispatch(queryOptions{SQL: "SELECT 1"})
Defensive patterns

Strategy: validation

Validate before calling

// Go
if !srv.IsOpen() { // or attempt validateConnection first
    if err := srv.Open(); err != nil { return err }
}

Try / catch

rows, err := srv.Dispatch(queryOptions{SQL: sql})
if err != nil && strings.Contains(err.Error(), "Hive connection is not open") {
    if err := srv.Open(); err != nil { return err }
    rows, err = srv.Dispatch(queryOptions{SQL: sql})
}

Prevention

When it happens

Trigger: Calling executeQuery, executeQueryPage, executeStatements, hiveMetadata-backed calls (listDatabases, listTables, getColumns), validateConnection, connectionInfo, or describeCluster before a successful open, or after the connection was closed/disconnected.

Common situations: Forgetting to call open/connect before issuing queries; a prior disconnect or failed open left server.connection nil; concurrency race where a goroutine disconnects while another queries; server restart cleared the connection but clients keep using stale handles.

Related errors


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