{"record":{"id":"702ea8358f6b70e2","repo":"t8y2/dbx","slug":"strings-join-failures-702ea8","errorCode":null,"errorMessage":"${strings.Join(failures, \"; \")}","messagePattern":"\\$\\{strings\\.Join\\(failures, \"; \"\\)\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agents/drivers/hive-go/main.go","lineNumber":530,"sourceCode":"\tserver.connectionMu.Lock()\n\tconnection := server.connection\n\tdatabase := server.database\n\tserver.connection = nil\n\tserver.database = nil\n\tserver.connectionMu.Unlock()\n\tvar failures []string\n\tif connection != nil {\n\t\tif err := connection.Close(); err != nil {\n\t\t\tfailures = append(failures, err.Error())\n\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()","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/main.go#L512-L548","documentation":"disconnect() aggregates all failures that occurred while closing the active Hive query session, the active operation, and the underlying database connection, then returns them joined with '; ' as a single error. It means one or more resources could not be released cleanly during shutdown. The message text is the concatenation of the individual error strings, so all root causes appear in one line.","triggerScenarios":"Calling server disconnect (via openSession re-init, dispatch, testConnection, or the GetObjectSource/ListDatabases test paths) while database.Close(), session cancel/close, or active-operation cleanup returns a non-nil error; the underlying gohive connection is already broken or the session close RPC fails.","commonSituations":"Network drop or HiveServer2 restart while a driver instance is being recycled; repeated disconnect calls (second Close on an already-closed connection errors); test suites tearing down sessions whose connections the server already dropped.","solutions":["Inspect the joined message to see which sub-close failed (it contains each error text separated by '; ') and fix that root cause first.","Ensure disconnect is called only once per session and that all queries/active operations are finished or cancelled before disconnecting.","Check HiveServer2 availability and network stability; a dropped TCP connection makes Close() fail.","If the error is benign (already-closed connection), treat disconnect failures as non-fatal and log instead of failing the caller."],"exampleFix":"// before\nif err := srv.Disconnect(); err != nil {\n    return fmt.Errorf(\"teardown failed: %w\", err)\n}\n// after\nif err := srv.Disconnect(); err != nil {\n    log.Printf(\"disconnect cleanup issue (non-fatal): %v\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Go\nif connOpen { // only disconnect sessions that were opened\n    if err := srv.Disconnect(); err != nil { log.Printf(\"disconnect: %v\", err) }\n}","typeGuard":null,"tryCatchPattern":"if err := srv.Disconnect(); err != nil {\n    for _, part := range strings.Split(err.Error(), \"; \") {\n        log.Printf(\"cleanup issue: %s\", part)\n    }\n}","preventionTips":["Call disconnect exactly once per session; use sync.Once for teardown.","Cancel active queries before disconnecting.","Log disconnect failures instead of failing the whole operation when the connection is already gone."],"tags":["hive","connection-lifecycle","cleanup","go"],"backgroundTag":"connection-close-failed","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"}