Skip to content

Run dstack server on the asyncio event loop - #4363

Open
peterschmidt85 wants to merge 1 commit into
masterfrom
issue_4362_server_asyncio_loop
Open

peterschmidt85 wants to merge 1 commit into
masterfrom
issue_4362_server_asyncio_loop

Conversation

@peterschmidt85

Copy link
Copy Markdown
Contributor

Fixes #4362.

With a Nebius backend and OpenTelemetry enabled, the server could freeze for up to 5 minutes while starting ssh for a service probe. Behind a load balancer health check, the frozen server was killed, and Nebius instances it was creating at that moment kept running untracked.

  • dstack server now runs uvicorn on the asyncio event loop instead of uvloop. asyncio starts subprocesses with vfork(), so gRPC and OpenTelemetry fork handlers no longer run in the ssh child, which could crash there before exec while the server waited on it.

If you start the server with the uvicorn CLI rather than dstack server, pass --loop asyncio.

Gateways keep uvloop; they don't load gRPC or OpenTelemetry.

Verified with the #4362 steps on ECS (Amazon Linux 2023, systemd-coredump, OpenTelemetry on): 0.22.3 froze twice within 4 minutes; with this change, 0 crashes and 0 freezes in 58 minutes.

🤖 Generated with Claude Code

uvloop spawns subprocesses with fork(). With gRPC and OpenTelemetry
loaded, the forked ssh child could crash before exec and hang the
server for up to 5 minutes (#4362).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Server freezes for 5 minutes when a forked ssh crashes in gRPC, killing the server and leaking Nebius instances

1 participant