Skip to content

fix: serialize unix app-server startup#23516

Merged
efrazer-oai merged 1 commit into
mainfrom
fix/app-server-unix-startup-lock
May 19, 2026
Merged

fix: serialize unix app-server startup#23516
efrazer-oai merged 1 commit into
mainfrom
fix/app-server-unix-startup-lock

Conversation

@efrazer-oai
Copy link
Copy Markdown
Contributor

@efrazer-oai efrazer-oai commented May 19, 2026

Summary

Unix-socket app-server startup can currently race when multiple launch attempts target the same CODEX_HOME. Those processes can overlap before the control socket exists, which lets them enter SQLite state initialization concurrently and reproduce the startup corruption pattern seen in SSH mode.

This change makes the app-server own that singleton startup guarantee. Unix-socket startup now takes a CODEX_HOME-scoped advisory lock before SQLite initialization, runs the existing control-socket preparation check while holding that lock, returns the established AddrInUse error when another live listener already owns the socket, and releases the lock once the new listener has bound its socket.

Design decisions

  • The singleton rule lives in app-server --listen unix://, not in a desktop-only caller path, so every Unix-socket launch gets the same race protection.
  • A duplicate raw app-server launch returns an error instead of silently succeeding. The attach operation remains app-server proxy, which continues to connect to an already-running listener.
  • The lock is held only across the dangerous startup window: socket preparation, SQLite initialization, and socket bind. It is not held for the app-server lifetime.
  • Listener detection stays in prepare_control_socket_path(...), so the preexisting live-listener and stale-socket behavior remains the single source of truth.

Testing

Tests: targeted Unix-socket transport tests on the branch checkout, full codex-cli build on efrazer-db10, and an SSH-style smoke on efrazer-db10 covering concurrent app-server starts, explicit duplicate-start errors, and absence of SQLite startup-error matches in launch logs.

@efrazer-oai efrazer-oai force-pushed the fix/app-server-unix-startup-lock branch from 5aef156 to 081fa3f Compare May 19, 2026 20:13
@efrazer-oai efrazer-oai marked this pull request as ready for review May 19, 2026 20:29
@efrazer-oai efrazer-oai force-pushed the fix/app-server-unix-startup-lock branch 2 times, most recently from 359fbac to 296ccb1 Compare May 19, 2026 20:57
@efrazer-oai efrazer-oai force-pushed the fix/app-server-unix-startup-lock branch from 296ccb1 to 45a3c25 Compare May 19, 2026 21:22
@efrazer-oai
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45a3c2576c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server/src/lib.rs
@efrazer-oai efrazer-oai merged commit c2141c7 into main May 19, 2026
31 checks passed
@efrazer-oai efrazer-oai deleted the fix/app-server-unix-startup-lock branch May 19, 2026 21:57
@github-actions github-actions Bot locked and limited conversation to collaborators May 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants