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 a race condition in EventedFileUpdateCheckerTest #47748
Fix a race condition in EventedFileUpdateCheckerTest #47748
Conversation
Fix: rails#47746 We need to wait for the listener threads to exit.
This does seem to fix
I wonder it's because they're sharing the same files? (ref) Also was looking at #45061 to see if it was related. Not at all familiar with these tests, so appreciate any feedback and thank you for taking the time to look into this! |
Ok, I literally commented out every single other test in that file. When I just run the single test it passes:
But when running the whole file, I get that failure:
🤯 |
Interesting. I'll have a look tomorrow (unless you find the issue first). |
Ok, the other 19 runs come from the shared test file, but I realized that just re-running the single test a bunch of times reproduces it about every 3rd or 4th try -- without having to comment out the other tests.
So it seems this test is just flakey and there isn't any sort of race condition or leak afaict. |
I can see the same result. Starting to dig into that one as well. But I'm thinking let's merge this one fix, as it's already a win, and I'll open another PR if I find a fix for that other one. If I can't find a fix, we can open an issue, or just consider deleting the test. |
Ok, so I have figured why When you fork, the Both the parent and the child will read in the same queue, so the event can be seen by either process but not both. I'm unfamiliar with this code, I'm not sure what the intent of this forking test was, so I'll have to dig a bit in the history to understand. But the fix is likely to re-open these descriptors after fork. |
It's interesting that this fixes the failure. Since #40133, the listener threads should not hold a reference to the The only thing I can think of is that maybe the finalizer registry is holding on to the |
@jonathanhefner it's not |
The fork tracker should not be holding a reference to the Additionally, when rails/activesupport/lib/active_support/evented_file_update_checker.rb Lines 100 to 105 in 3d9edd4
So the 🤷♂️ |
Hum, that's weird. If you really want to know, the way to be sure what's going on would be to dump the heap to find what's keeping a ref on it. github.com/csfrancis/harb is great for that. |
…nted-file-update-checker Fix a race condition in EventedFileUpdateCheckerTest
Fix: #47746
We need to wait for the listener threads to exit.
@zzak I believe this is the real root cause.