{"record":{"id":"d68e46162868aa2e","repo":"t8y2/dbx","slug":"hive-connection-is-not-open-d68e46","errorCode":null,"errorMessage":"Hive connection is not open","messagePattern":"Hive connection is not open","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/hive-go/main.go","lineNumber":540,"sourceCode":"\t\t}\n\t}\n\tif database != nil {\n\t\tif err := database.Close(); err != nil {\n\t\t\tfailures = append(failures, err.Error())\n\t\t}\n\t}\n\tif len(failures) > 0 {\n\t\treturn errors.New(strings.Join(failures, \"; \"))\n\t}\n\treturn nil\n}\n\nfunc (server *server) requireConnection() (*sql.Conn, error) {\n\tserver.connectionMu.Lock()\n\tconnection := server.connection\n\tserver.connectionMu.Unlock()\n\tif connection == nil {\n\t\treturn nil, errors.New(\"Hive connection is not open\")\n\t}\n\treturn connection, nil\n}\n\nfunc (server *server) setActiveOperation(cancel context.CancelFunc) {\n\tserver.activeMu.Lock()\n\tserver.activeCancel = cancel\n\tserver.activeMu.Unlock()\n}\n\nfunc (server *server) clearActiveOperation(cancel context.CancelFunc) {\n\tcancel()\n\tserver.activeMu.Lock()\n\tserver.activeCancel = nil\n\tserver.activeMu.Unlock()\n}\n\nfunc (server *server) cancelActiveQuery() {","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/main.go#L522-L558","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open the Hive connection (successful openSession/connect) before issuing any query or metadata call.","Verify no code path disconnects the server while it is still in use; serialize disconnect against query traffic.","Re-open the connection after any error that indicates the session dropped, then retry the operation.","Check the connection state (validateConnection) before executing long-running work."],"exampleFix":"// before\nrows, err := srv.Dispatch(queryOptions{SQL: \"SELECT 1\"}) // fails if not open\n// after\nif err := srv.Open(); err != nil {\n    return err\n}\nrows, err := srv.Dispatch(queryOptions{SQL: \"SELECT 1\"})","handlingStrategy":"validation","validationCode":"// Go\nif !srv.IsOpen() { // or attempt validateConnection first\n    if err := srv.Open(); err != nil { return err }\n}","typeGuard":null,"tryCatchPattern":"rows, err := srv.Dispatch(queryOptions{SQL: sql})\nif err != nil && strings.Contains(err.Error(), \"Hive connection is not open\") {\n    if err := srv.Open(); err != nil { return err }\n    rows, err = srv.Dispatch(queryOptions{SQL: sql})\n}","preventionTips":["Open the connection at application startup and verify with validateConnection.","Serialize disconnect against in-flight queries.","Auto-reconnect on first 'not open' error.","Do not cache driver handles across server restarts."],"tags":["hive","connection-state","go","lifecycle"],"backgroundTag":"connection-not-open","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}