-
Notifications
You must be signed in to change notification settings - Fork 410
registry rotation on Windows fails #272
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
Conversation
Looks good to me (though I've not tested) It's about the same as what I did except I kept errors from remove old and printed it out if the rename failed along with the rename error. (I don't like to ever hide any errors from users.) +1 |
I've been seeing this problem as well. I'm new to using github. How could I help test this fix? |
you can simply go to my fork by the link above, clone it and tun 'go build' from that folder. |
Here are the results of my test of justmara's fix: First Run - I manually deleted .logstash-forwarder* files. It read in my log file from the start, created .logstash-forwarder. Then picked up new lines, rolled .logstash-forwarder to .logstash-forwarder.old, and updated .logstash-forwarder file. Repeated this for several new events. Looks good. [PASS]
Second run - CTRL-C, then ran again. .logstash-forwarder and .logstash-forwarder.old were in the directory when I started it. Then .logstash-forwarder.old was deleted, .logstash-forwarder.new was created and the registry rotate log warning message came up again. [FAIL]
|
Must be logstash-forwarder.go:153 I think it around there. When the state is opened initially to resume it never closed until shutdown - Registrar() doesn't return. Need to fix that by moving into a function so the defer Close() calls earlier or simply use Close() directly on all execution paths. |
@ktodyruik looks like you've merged something wrong. i have it running for more than a week already on our production machines. here is restart log:
|
Hi @justmara Reading the code it really does look like .logstash-forwarder is kept open, even after startup: Not tried to reproduce though so can't explain why it works for you and not @ktodyruik ! |
@driskell hmm, now re-pulled from git, rebuilt and have this error too. looks like I've fixed it, built and published to our servers, but forgot to push something back to git. because my compiled version does not have this error =) so looks like my pull is missing something I've really lost already.. my bad |
ohh, found the version I've compiled from and here is the code I've lost when translated to git pull request:
so yes, this is it. this last line is the one missing 8( is there any way to attach another commit to this pull request? |
@justmara No problem! |
here it goes then 8) |
@justmara Looks good to me! Though I'm currently able to test. 👍 @ktodyruik Could you test and provide feedback, perhaps? |
Thanks for fixing this. :) I Did several tests:
Everything looks good! |
Works for me as well. |
ouch, cla checks. signed now, sry 8) |
I have this issue on windows as well. I'm assuming it affects all windows users. |
We were forced to build from source and merge pull-request manually. I there any reasons not to merge? |
I agree .logstash-forwarder needs to be explicitly closed. What's the point of renaming .logstash-forwarder to .logstash-forwarder.old before renaming .logstash-forwarder.new to .logstash-forwarder ? The registrar_other.go doesn't do this. |
@sebaa Windows won't allow you to "move" a file if the destination already exists. POSIX systems will simply overwrite the destination. Thus for Windows the destination file needs removing. This would mean removing ".logstash-forwarder" - if a crash happens between doing this and putting the new file in place, there's going to be a problem. This I think is why the author renames to .old. Admittedly though they don't check for .old during startup and probably should, to detect the crash event. |
@driskell Well, I guess it depends on which API GO uses for the Rename operation. MoveFileEx() will overwrite if you ask it to :) But your reasoning that doing a rename instead of a delete of ".logstash-forwarder" makes good sense if something explodes before (or during) the renaming of ".logstash-forwarder.new" to ".logstash-forwarder". (except that the .old is never deleted, but I guess that 's part of the original ticket). |
Does anyone have an idea of how long it is going to take before the fix is being released? AFAIC this is concerning all users that have Windows servers. |
When is that going to be merged to master? |
Been running this in production for a few weeks now without a hitch, would be nice if it could be merged to master |
@justmara could you rebase the PR please, it started raising merge conflicts |
@mkuzmin tried making rebase - now it looks strange - like if all the other commits added to this PR. looks like id I did something wrong =) |
I think you rebased master onto your branch, rather than your branch onto master or something :) Might want to reset back to your last commit. The way I would do it: Setup a remote for "upstream" pointing to elastic/logstash-forwarder repository. Then checkout your master with your commits. Then hit |
@driskell yey! thanks, much better now 8) |
…d error) added remove old file before rename windows registrar (get rid of FileAlreadyExists error) changed to explicit file close in writeRegistry() because 'defer' wont be exected before rotation methods called and it blocks file added loadState function to load the state from files and correctly close it
it is working. please accept pull request |
Is there any plan to merge this? |
1 similar comment
Is there any plan to merge this? |
I still see the problem, after i pull the latest for this? is it merged? |
Has this project died? This issue is a year old and people have been asking On Thu, Sep 17, 2015 at 10:36 AM, Aditya [email protected] wrote:
|
It's a shame for project, but we opt out to not use logstash-forwarder at all. Using logstash to forward all logs. |
This fix will go directly into filebeat, the future replacement of logstash-forwarder. https://github.com/elastic/filebeat |
@justmara Do you prefer to open a pull request with the change on filebeat (https://github.com/elastic/filebeat) or should we copy over fix? |
@ruflin seriously? you've made new repo with copy of this master branch (not even the fork!)? so logbeat is simply 'rename and history whipe'? |
@justmara The logstash-forwarder repository was split up in two parts. Parts of the code went into filebeat, parts into libbeat to structure it as a beat. In both cases the code was heavily restructured. |
This should be fixed in filebeat (next version of logstash-forwarder) with https://github.com/elastic/filebeat/pull/43 and https://github.com/elastic/filebeat/pull/45 |
As the next release of logstash-forwarder will be filebeat, I will close this issue based on the comment above. In case the issue still exists in filebeat, please reopen or open a new issue directly in the filebeat repo. |
this is fix for #270