{"record":{"id":"d99513f5e895ff37","repo":"t8y2/dbx","slug":"close-hive-agent-sessions-s","errorCode":null,"errorMessage":"close Hive Agent sessions: %s","messagePattern":"close Hive Agent sessions: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agents/drivers/argo-go/main.go","lineNumber":310,"sourceCode":"\treturn session.server.disconnect()\n}\n\nfunc (runtimeServer *runtimeServer) closeAllSessions() error {\n\truntimeServer.mu.Lock()\n\tsessions := runtimeServer.sessions\n\truntimeServer.sessions = map[string]*agentSession{}\n\truntimeServer.mu.Unlock()\n\tvar failures []string\n\tfor id, session := range sessions {\n\t\tsession.mu.Lock()\n\t\terr := session.server.disconnect()\n\t\tsession.mu.Unlock()\n\t\tif err != nil {\n\t\t\tfailures = append(failures, fmt.Sprintf(\"%s: %v\", id, err))\n\t\t}\n\t}\n\tif len(failures) > 0 {\n\t\treturn fmt.Errorf(\"close Hive Agent sessions: %s\", strings.Join(failures, \"; \"))\n\t}\n\treturn nil\n}\n\nfunc newServer(params connectParams) (*server, error) {\n\tconfig, err := parseConnectionConfig(params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tserver := &server{\n\t\tparams:        params,\n\t\tconfig:        config,\n\t\tquerySessions: map[string]*querySession{},\n\t}\n\tif err := server.openConnection(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn server, nil","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/argo-go/main.go#L292-L328","documentation":"Aggregate error from `closeAllSessions`: after swapping out and clearing the sessions map, the driver disconnects every remaining agentSession under its own mutex; any per-session `disconnect()` error is collected as \"id: err\" strings and, if any occurred, wrapped into a single \"close Hive Agent sessions: ...\" error joined with \"; \". The sessions are all removed from the registry regardless, so this error reports partial cleanup failures (typically network/transport errors while tearing down the underlying Hive connection), not a failure to close.","triggerScenarios":"Calling closeAllSessions (via dispatch's shutdown path) when one or more underlying `session.server.disconnect()` calls return errors — e.g. the Hive server already dropped the TCP connection, a disconnect timeout fired, or the driver/transport was already torn down for that session.","commonSituations":"Shutting the agent down while the Hive backend is unreachable or has idle-timed-out connections; closing after an abrupt network drop so disconnect gets 'connection reset'/'broken pipe'; sessions in the middle of an active request whose transport errors on teardown; multiple bad sessions accumulate into one joined message.","solutions":["Parse the joined message: each ';'-separated \"id: err\" pair names a session whose underlying connection already failed — these are usually benign at shutdown; log and treat as non-fatal if the process is exiting anyway.","Verify Hive server reachability; if disconnect reports network errors, fix connectivity or increase the disconnect/transport timeout before shutdown.","Avoid closing sessions with in-flight requests; wait for active requests to complete (or cancel them) before shutdown so disconnects are clean.","If errors repeat, check driver/server version mismatch on the Hive transport and reconnect sessions individually to confirm which teardown path fails."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := rt.closeAllSessions(); err != nil {\n    for _, failure := range strings.Split(strings.TrimPrefix(err.Error(), \"close Hive Agent sessions: \"), \"; \") {\n        log.Printf(\"session teardown failure (non-fatal at shutdown): %s\", failure)\n    }\n}","preventionTips":["Treat teardown errors at process exit as log-and-continue; all sessions are already deregistered.","Ensure idle-keepalive or shorter server-side timeouts so connections are alive when you disconnect.","Wait for in-flight requests to finish before calling closeAllSessions.","Monitor Hive server reachability; repeated disconnect failures usually indicate a pre-existing network fault."],"tags":["go","shutdown","connection-teardown","hive-agent","aggregate-error"],"backgroundTag":"connection-reset-during-teardown","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"}