{"record":{"id":"65a908ab5819a3bf","repo":"t8y2/dbx","slug":"strings-join-failures","errorCode":null,"errorMessage":"strings.Join(failures, \"; \")","messagePattern":"strings\\.Join\\(failures, \"; \"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agents/drivers/argo-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/argo-go/main.go#L512-L548","documentation":"disconnect tears down the session's database and connection and aggregates every teardown error into a single error whose message is the failure strings joined with \"; \". If any Close() (or related cleanup) fails, disconnect returns that combined error so the caller knows cleanup was only partial. The bracketed message is the joined-error text itself, e.g. \"connection already closed\".","triggerScenarios":"Calling disconnect (directly or via openSession, dispatch, testConnection) when closing the *sql.DB/database or the sql.Conn fails — e.g. the network already dropped, the driver returns an error on Close, or both cleanup steps fail and messages are concatenated with \"; \".","commonSituations":"Disconnecting after the HiveServer2 process restarted (socket already dead); TLS or auth state making the close handshake fail; double-disconnect from concurrent callers; flaky network causing partial cleanup.","solutions":["Inspect the joined message(s) to see which cleanup step failed; a 'closed' style message is usually safe to ignore","Ensure disconnect is called exactly once per session (idempotent guards/once semantics)","Catch and log this error on shutdown paths rather than failing the whole shutdown","If the connection is already dead, force-reset server connection state instead of relying on graceful Close"],"exampleFix":"// before\nerr := server.disconnect() // err: \"driver: bad connection\"\nif err != nil { return err } // aborts shutdown\n// after\nif err := server.disconnect(); err != nil {\n    log.Printf(\"disconnect cleanup issues (ignoring): %v\", err)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := server.disconnect(); err != nil {\n    log.Printf(\"disconnect cleanup issues: %v\", err) // joined with '; '\n    // do not abort shutdown; inspect individual messages\n}","preventionTips":["Call disconnect exactly once per session","Log rather than propagate teardown errors on shutdown paths","Reset connection state when the peer is already gone","Avoid concurrent disconnect calls with a mutex/once guard"],"tags":["cleanup","connection","disconnect"],"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-14T00:17:10.932Z"}