Skip to content

fix: wake concurrent durable future waiters after shared receive - #323

Open
shafiktanbir wants to merge 1 commit into
restatedev:mainfrom
shafiktanbir:fix/concurrent-durable-future-wakeup
Open

shafiktanbir wants to merge 1 commit into
restatedev:mainfrom
shafiktanbir:fix/concurrent-durable-future-wakeup

Conversation

@shafiktanbir

Copy link
Copy Markdown

Fixes #315.

When multiple asyncio tasks concurrently awaited separate durable futures (for example via asyncio.gather over ctx.run_typed tasks), each task entered create_poll_or_cancel_coroutine and queued an independent await self.receive() reader on the shared ReceiveChannel. An incoming restate.run_completed event or HTTP body chunk woke only the head reader; if that chunk completed a peer task's handle instead of the head reader's handle, the head reader looped back into self.receive() without waking the peer waiter, stalling the handler until inactivity_timeout.

This serializes self.receive() through _wait_for_external_progress() so one reader consumes the next channel event while concurrent waiters await a shared asyncio.Event and re-run self.vm.do_progress(...) after each event (and propagate DisconnectedException to all waiters on http.disconnect).

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.

Awaiting ctx.run results from several asyncio tasks loses wakeups: the handler stalls until inactivity_timeout

1 participant