alibaba/arthas · error · SessionNotFoundException
Failed to create temporary session
Error message
Failed to create temporary session
What it means
Thrown as SessionNotFoundException by getCurrentSession when a one-time call was permitted (oneTimeIsAllowed=true) but sessionManager.createSession() returned null. This indicates the session manager refused to allocate a session — typically because a configured limit (max sessions) was reached or the manager is shut down.
Source
Thrown at core/src/main/java/com/taobao/arthas/core/command/CommandExecutorImpl.java:62
private final SessionManager sessionManager;
private final JobController jobController;
private final InternalCommandManager commandManager;
public CommandExecutorImpl(SessionManager sessionManager) {
this.sessionManager = sessionManager;
this.commandManager = sessionManager.getCommandManager();
this.jobController = sessionManager.getJobController();
}
public Session getCurrentSession(String sessionId, boolean oneTimeIsAllowed) {
if (sessionId == null || sessionId.trim().isEmpty()) {
if (!oneTimeIsAllowed) {
throw new SessionNotFoundException("SessionId is required for this operation");
}
Session session = sessionManager.createSession();
if (session == null) {
throw new SessionNotFoundException("Failed to create temporary session");
}
session.put(ONETIME_SESSION_KEY, new Object());
logger.debug("Created one-time session {}", session.getSessionId());
return session;
} else {
Session session = sessionManager.getSession(sessionId);
if (session == null) {
throw new SessionNotFoundException("Session not found: " + sessionId);
}
sessionManager.updateAccessTime(session);
logger.debug("Using existing session {}", sessionId);
return session;
}
}
/**
* 内部同步执行方法,统一处理认证和session管理
* View on GitHub (pinned to 21cf2e9ba5)
Solutions
- Increase the max-sessions limit in Arthas options.
- Close/expire idle sessions so createSession can succeed (check sessionManager for active sessions).
- Verify Arthas is not shutting down at call time.
- Switch to passing an explicit sessionId rather than relying on one-time creation.
Example fix
// before
// relies on implicit one-time session that fails under load
Session s = executor.getCurrentSession(null, true);
// after
// reuse a long-lived session
Session s = sessionManager.getSession(mySid);
if (s == null) { s = sessionManager.createSession(); mySid = s.getSessionId(); } Defensive patterns
Strategy: retry
Validate before calling
int active = sessionManager.activeSessionCount(); // pseudo
if (active >= maxLimit) { /* expire idle sessions or raise the cap */ } Try / catch
try {
Session s = executor.getCurrentSession(null, true);
} catch (SessionNotFoundException e) {
// expire/close an idle session, then retry; or reuse an existing session id
} Prevention
- Close idle sessions promptly to keep below the max-session cap.
- Raise the max-sessions option if workloads need more concurrency.
- Avoid one-time sessions under load; reuse explicit session ids.
When it happens
Trigger: Call getCurrentSession(null/blank, true) where sessionManager.createSession() returns null. Happens when the max-session cap is hit, the manager is stopped, or resource limits prevent new session allocation.
Common situations: Too many concurrent sessions exhausting the configured maximum; leaked sessions never expiring; calling after Arthas shutdown has begun; memory/thread pressure causing session creation to fail.
Related errors
- SessionId is required for this operation
- Session not found: {sessionId}
- Error! command not permitted, try to use 'auth' command to a
- 'sessionId' is required
- session not found: {}
AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14).
Data as JSON: /api/errors/400d226c97385c67.
Report an issue: GitHub.