-
Notifications
You must be signed in to change notification settings - Fork 55
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
on EOF, write to sincedb #24
Conversation
@buckelij any change you could rebase this PR, please ? |
38ae12f
to
bf3cf7a
Compare
bf3cf7a
to
27c421f
Compare
@wiibaa I've rebased. |
@buckelij in fact your issue report could be simplified to tail should always write sincedb when quiting,no ? Why would you make it dependant of sincedb_interval ? If you look to logstash-input-file plugin, you can see that sincedb_write is called before calling quit in teardown logic https://github.com/wiibaa/logstash-input-file/blob/master/lib/logstash/inputs/file.rb#L146 @jsvd this a design decision, either tail#quit should itself call sincedb_write or it should be clearly documented that it is the responsbility of the lib user, what do you think? |
I guess that's true, and should be good enough in most cases. That being
On Sunday, February 22, 2015, Philippe Weber notifications@github.com
|
(I realize that's maybe a logstash docs issue) On Sunday, February 22, 2015, Elijah Buck elijah@github.com wrote:
|
@buckelij your point is then that sincedb_write_interval should happen regularly to flush the sincedb , even when no changes was made to watched files, This would only improve the non-clean exit. |
sincedb_write should definitely be called during quit, I don't see a situation where that is a bad thing. As for calling it on EOF, I'm more skeptical, as that'll be very aggressive (every line read will trigger an EOF, if I'm not mistaken). My suggestion would be to either change this PR to @wiibaa's suggestion or close this one and open one for sincedb_write on tail#quit. |
That's correct.
No, only when
That's fine; this is for the corner case where there have been changes within the last sincedb_write_interval (and then no changes after sincedb_write_interval passes) and then the process is killed. |
What I meant by |
sincedb will not always be written when exiting the loop. It depends on if the sincedb_write_interval has elapsed or not. |
@buckelij corrected my comment, but it does not change the fact that in your initial test-logic _sincedb_write_if_due would be called twice in your patch because changed=true as you come from the when :modify in subscribe |
@wiibaa ah, that is true that _sincedb_write_if_due would be called twice. I guess I can set changed=false as part of the rescue. Should I make that change, or is there still a question of whether this PR brings any value? |
Oh, no. Hmm, this doesn't seem right. I would have to call _sincedb_write directly from the EOF rescue, otherwise this doesn't help at all. |
I've updated the PR to always write when EOF is encountered. @jsvd if you're concerned that writing on EOF is too aggressive, we can just close this. Regardless of the state of this PR, I think the following should be considered.
Thanks! |
Guys, I have a version of this that I submitted a long time back that took care of the EOF issue but it never made it in. Not writing at EOF was a big problem for me and I have to assume is incorrect behavior. It really needs to be flushed.
I have a version of this working for me that we use and it works great. I think if you make this simple modification, it would be great. Thanks On February 25, 2015 at 5:18:08 PM, Elijah Buck (notifications@github.com) wrote: I've updated the PR to always write when EOF is encountered. @jsvd if you're concerned that writing on EOF is too aggressive, we can just close this. Regardless of the state of this PR, I think the following should be considered. sincedb_write_interval should happen regularly to flush the sincedb , even when no changes was made to watched files tail should always write sincedb when quiting Thanks! — |
@bdanziger thanks for joining the discussion. In fact your PR #29 is next on my radar, I expected this one to be an easy warm-up. Let's try to conclude and move forward with following actions:
|
Agreed! regarding "1." I opened an issue on logstash-input-file to remove the explicit sincedb_write call once we merge this and release a new filewatch gem. Also needed if we end up doing 8. (which I'm all for it). Also +1 on refactoring #29 according to #32 (comment) ❤️ to @buckelij @wiibaa @bdanziger |
Not to slow anyone down…just curious about the public sincedb_write removal. I recall when I enhanced this (it’s been a while) that logstash called the sincedb_write in it’s cleanup (If I am remembering correctly). Which is why I passed in a flag to determine if you HAD to flush, or you could just set the pending flag to write. The thought was that if the called wants to flush sincedb Are we saying we do not need that because it will always be flushed when the tail finishes? I seemed to have missed some discussion on this and was confused. If you don’t have time to answer…that’s fine. Was just curious what I missed. On February 26, 2015 at 8:03:02 AM, João Duarte (notifications@github.com) wrote: Agreed! regarding "1." I opened an issue on logstash-input-file to remove the explicit sincedb_write call once we merge this and release a new filewatch gem. Also needed if we end up doing 8. (which I'm all for it). Also +1 on refactoring #29 according to #32 (comment) to @buckelij @wiibaa @bdanziger — |
@bdanziger Indeed this issue is initially not related to logstash and you need to dig in the history.
|
Ok, thanks for the info. I would agree that this should be handled internally. On February 26, 2015 at 9:22:18 AM, Philippe Weber (notifications@github.com) wrote: @bdanziger Indeed this issue is initially not related to logstash and you need to dig in the history. 2011 #quit method did not exist, so to flush sincedb at exit you needed a way, thus the public sincedb_write as used in https://github.com/jordansissel/ruby-filewatch/blob/master/bin/globtail#L50 |
It is not a good idea to write the sincedb on every EOF. |
I was expecting that if :sincedb_write_interval had passed before the tail was shut down, the sincedb would be up-to-date. In fact, up to :sincedb_write_interval worth of writes will be re-read on restart:
This patch checks if :sincedb_write_interval has passed if at EOF.