Skip to content

FIX: don't drop requests that arrive before v8_roundtrip is re-entered - #440

Open
davidtaylorhq wants to merge 1 commit into
mainfrom
fix-roundtrip-request-drop
Open

FIX: don't drop requests that arrive before v8_roundtrip is re-entered#440
davidtaylorhq wants to merge 1 commit into
mainfrom
fix-roundtrip-request-drop

Conversation

@davidtaylorhq

Copy link
Copy Markdown
Collaborator

When an attached Ruby callback makes its own request on the same context (perform_microtask_checkpoint, a nested call, etc), the Ruby thread can enqueue its next request in the gap between the nested dispatch finishing and the V8 thread re-entering v8_roundtrip. The buf_reset(&c->req) on entry then destroyed that request, leaving both threads waiting on each other forever.

The reset is a leftover from before 478c763, when v8_roundtrip returned a pointer into the live request buffer and had to clear it on the next entry. Requests are now handed off with buf_move, so the buffer is already empty on re-entry unless it holds a new, unread message.

Writing a deterministic test here is very difficult. I was only able to reproduce by looping thousands of times.

When an attached Ruby callback makes its own request on the same context (perform_microtask_checkpoint, a nested call, etc), the Ruby thread can enqueue its next request in the gap between the nested dispatch finishing and the V8 thread re-entering v8_roundtrip. The buf_reset(&c->req) on entry then destroyed that request, leaving both threads waiting on each other forever.

The reset is a leftover from before 478c763, when v8_roundtrip returned a pointer into the live request buffer and had to clear it on the next entry. Requests are now handed off with buf_move, so the buffer is already empty on re-entry unless it holds a new, unread message.
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.

1 participant