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

Fixing race condition when watching symlinks that change frequently #25

Merged
merged 1 commit into from
Jan 15, 2016

Conversation

juliettepaul
Copy link
Collaborator

When watching symlinks that change frequently this code would be unable to lstat the symlink even though the stat succeeded. I tightened this lookup to happen faster after stat and I also used the symlink? check on the return from stat instead of another File call to reduce the frequency of this race condition.

Reproduction:
Watch a symlink in tmp created like this:

touch /tmp/test_target ; ln -sf /tmp/test_target /tmp/test_link

Run this command to replace the symlink constantly and watch your tailer throw an exception while trying to grab the inode:

while true; do rm -f /tmp/test_link; touch /tmp/test_target; ln -sf /tmp/test_target /tmp/test_link; done

You will get an exception similar to this:

/usr/etsy/deployinator/vendor/bundle/ruby/1.9.1/gems/eventmachine-tail-0.6.4/lib/em/filetail.rb:388:in `handle_fstat': undefined method `ino' for nil:NilClass (NoMethodError)

@jordansissel
Copy link
Owner

I no longer maintain this project (I haven't used EventMachine in many years). The code change looks OK to me.

jordansissel added a commit that referenced this pull request Jan 15, 2016
Fixing race condition when watching symlinks that change frequently
@jordansissel jordansissel merged commit e556f05 into jordansissel:master Jan 15, 2016
@juliettepaul
Copy link
Collaborator Author

@jordansissel Does anyone maintain it? Would like to get a release up on rubygems for people experiencing this issue. I could upload the gem if you no longer want to maintain it just would need to get access on rubygems.org

@jordansissel
Copy link
Owner

@jayson I'm happy to add you as a contributor to this repo and give you ownership on rubygems to publish gems - let me know what you want :)

For rubygems, I only need your rubygems email and I can give you ownership.

@juliettepaul
Copy link
Collaborator Author

@jordansissel Sounds perfect. I can take over maintaining it.

My email is jaysonpaul@gmail.com

@jordansissel
Copy link
Owner

% gem owner eventmachine-tail -a ...
Owner added successfully.

Done! :)

@juliettepaul
Copy link
Collaborator Author

Thanks!

@juliettepaul
Copy link
Collaborator Author

@jordansissel Did you add me as a contributor for this repo as well so I can push here? Thanks!

@juliettepaul
Copy link
Collaborator Author

Looks like I got it thanks again

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.

2 participants