Skip to content

rserver can't tell which session process a request outcome came from, so a predecessor's response can clear a new launch's pending entry #18963

Closed

Description

@kevinushey

Summary

rserver avoids launching the same session twice by keeping a pending-launch entry per session context (src/cpp/server/session/ServerSessionManager.cpp), and it clears that entry when a request for the context succeeds or fails. It can't tell whether the outcome came from the process it just launched or from the one being replaced. A request answered by, or failing on, an exiting predecessor can therefore clear the new launch's entry, and the next request that finds the session unavailable launches it again.

Two guards cover parts of this:

Gaps that remain:

  1. After the launch function returns, a successful response from the exiting predecessor still erases the entry; the rserver can double-launch a session during restart, leaking an orphaned rsession #18572 guard only applies to errors.
  2. removePendingSessionLaunch(username, sessionId), the variant Workbench calls when forwarding launcher session RPCs, erases the entry unconditionally and ignores both guards.
  3. (Minor) endLaunching() runs only if sessionLaunchFunction_ returns normally. If it throws, the entry keeps launching = true, and relaunches for that context are suppressed until the one-minute pending window expires. A scope guard would fix this.

For server sessions on a local stream, #18944's session-side claim makes a duplicate exit early in startup, so the practical cost there is one wasted process launch. Sessions that don't listen on a local stream (such as Workbench launcher sessions) don't have that backstop.

Possible fix

Only let an outcome from the launched process clear its entry, rather than adding a guard for each window. For example, compare the answering peer's pid (SO_PEERCRED / getpeereid() on the local stream) with the pid recorded for the pending launch, or stamp each launch with a generation that the session echoes back. Either would subsume both the #18572 guard and the launching flag.

Related: #18572, #18941, #18944.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions