t8y2/dbx · warning

close Hive Agent sessions: %s

Error message

close Hive Agent sessions: %s

What it means

This error aggregates every per-session disconnect failure encountered while the Hive Agent runtime is shutting down. closeAllSessions iterates all live agent sessions, calls server.disconnect() on each, and collects any failures as "<sessionID>: <err>" strings. It then joins them with "; " so a single error reports all sessions that failed to close cleanly, rather than only the first.

Source

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

	return session.server.disconnect()
}

func (runtimeServer *runtimeServer) closeAllSessions() error {
	runtimeServer.mu.Lock()
	sessions := runtimeServer.sessions
	runtimeServer.sessions = map[string]*agentSession{}
	runtimeServer.mu.Unlock()
	var failures []string
	for id, session := range sessions {
		session.mu.Lock()
		err := session.server.disconnect()
		session.mu.Unlock()
		if err != nil {
			failures = append(failures, fmt.Sprintf("%s: %v", id, err))
		}
	}
	if len(failures) > 0 {
		return fmt.Errorf("close Hive Agent sessions: %s", strings.Join(failures, "; "))
	}
	return nil
}

func newServer(params connectParams) (*server, error) {
	config, err := parseConnectionConfig(params)
	if err != nil {
		return nil, err
	}
	server := &server{
		params:        params,
		config:        config,
		querySessions: map[string]*querySession{},
	}
	if err := server.openConnection(); err != nil {
		return nil, err
	}
	return server, nil

View on GitHub (pinned to c0390bff16)

Solutions

  1. Inspect the per-session detail after 'close Hive Agent sessions:' to find which session and underlying cause failed
  2. Verify the HiveServer2 endpoint is reachable and sessions have not been expired server-side (hive.server2.session.close timeout)
  3. Treat this as a shutdown-time warning in most cases — sessions are being discarded anyway; re-check cleanup logic only if resources leak
  4. Retry the disconnect or ensure idle keepalives are configured so connections are not stale at shutdown

Example fix

// before: ignoring close errors can mask root causes
_ = runtimeServer.closeAllSessions()
// after: log the aggregated failure detail
if err := runtimeServer.closeAllSessions(); err != nil {
    log.Printf("shutdown: %v", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if err := runtimeServer.closeAllSessions(); err != nil { log.Printf("session close failures: %v", err) }

Try / catch

if err := closeAllSessions(); err != nil {
    for _, part := range strings.Split(strings.TrimPrefix(err.Error(), "close Hive Agent sessions: "), "; ") {
        log.Println("session close failure:", part)
    }
}

Prevention

When it happens

Trigger: Raised when the agent shuts down (shutdown RPC or process teardown via dispatch/closeAllSessions) and one or more underlying Hive/go hive connections fail to close — e.g. a broken network connection to HiveServer2, a session already terminated server-side, or a driver-level close timeout.

Common situations: Long-lived sessions whose HiveServer2 connection expired or was dropped by a firewall/load balancer idle timeout; killing the agent while queries are still streaming; HiveServer2 restarts that orphaned the client sessions.

Related errors


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