Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stuck isolation #1147

Merged
merged 2 commits into from
Dec 8, 2020
Merged

Fix stuck isolation #1147

merged 2 commits into from
Dec 8, 2020

Conversation

mbj
Copy link
Owner

@mbj mbj commented Dec 8, 2020

This was both an MRI and a mutant problem, and its likely that the
underlying MRI problem can still manifest itself. Its now simpy just
significantly more unlikely.

A bit of context:

  • Mutant is and was waiting for an FD to become readable via IO.select.
  • Mutant did NOT "finish" reading the FD per IO.select return, instead
    it would only read upto 4096 bytes, even if the FD could provide more
    input. Mutant would loop around to call another IO.select on the FD.
  • MRI does internally maintain a buffer before calling read() on the
    underlying file descriptor. Mutant often would per IO.select only hit
    that buffer, not the underlying FD.
  • MRI can "forget" the Ruby side IO#read_nonblocking should not block,
    so when the buffer is exhausted it may call read() in blocking mode.
  • Mutant triggered this (potentially buggy MRI mechanism) very often.

@mbj mbj force-pushed the fix/stuck-isolation branch 2 times, most recently from dadf620 to 7dbd8b5 Compare December 8, 2020 23:35
This was both an MRI and a mutant problem, and its likely that the
underlying MRI problem can still manifest itself. Its now simpy just
significantly more unlikely.

A bit of context:

* Mutant is and was waiting for an FD to become readable via IO.select.
* Mutant did NOT "finish" reading the FD per IO.select return, instead
  it would only read upto 4096 bytes, even if the FD could provide more
  input. Mutant would loop around to call another IO.select on the FD.
* MRI does internally maintain a buffer before calling `read()` on the
  underlying file descriptor. Mutant often would per IO.select only hit
  that buffer, not the underlying FD.
* MRI can "forget" the Ruby side IO#read_nonblocking should not block,
  so when the buffer is exhausted it may call `read()` in blocking mode.
* Mutant triggered this (potentially buggy MRI mechanism) very often.
@mbj mbj self-assigned this Dec 8, 2020
@mbj mbj added the bug label Dec 8, 2020
@mbj mbj merged commit b740498 into master Dec 8, 2020
@mbj mbj deleted the fix/stuck-isolation branch December 8, 2020 23:47
mostlyobvious added a commit to RailsEventStore/rails_event_store that referenced this pull request Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant