-
Notifications
You must be signed in to change notification settings - Fork 22
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
plugin wont run if empty seq file present #27
Comments
Thanks for the report, and the suggestion. It think it makes more sense to check for a value before returning an empty value than to write something to the file. If you're interested in submitting a PR for this, though, I'd be happy to review the changes. |
I tracked down the source of the problem. If you have a bad seq number, couchdb throws the error, and the plugin does't handle it. Error 400
|
my seq look like:
|
That shouldn't be the case, if I recall correctly. Sequence id (identified as http://docs.couchdb.org/en/1.6.1/api/database/changes.html
|
maybe I should mention I am on cloudant. Here's a sample of _changes:
|
That shouldn't matter. The couchdb_changes format is defined the same. Try it yourself, and see if the API returns the expected JSON. |
I'm not sure if this is the right way to test: but doing: /_changes?since=9 gives me a error: "bad_request", |
Hmmm. What version is cloudant using? This is not what showed up in any API research I did when writing the plugin. Did they customize CouchDB somehow? The plugin may still work with these unusual |
It could be that in those two code locations, you have to check for a non- |
The plugin works fine, the seq structure was not a problem. I added a check for default value, and also a bad response reset. Also changed the write method to write from 0, because the file was empty during truncating was causing problems. |
https://github.com/teebu/logstash-input-couchdb_changes/blob/v1.0.0-def-seq/lib/logstash/inputs/couchdb_changes.rb#L191 is not a fix I could merge as-is, though I appreciate the fix for your case. You get an error, but in the present configuration, it should still retry in 10 seconds. If you want to overwrite I couldn't accept https://github.com/teebu/logstash-input-couchdb_changes/blob/v1.0.0-def-seq/lib/logstash/inputs/couchdb_changes.rb#L147 as that's an unfortunate mask for the problem. It has a bad code smell. Better to test and account for the error properly than to employ a hackish way to try to prevent it from happening. The fix at https://github.com/teebu/logstash-input-couchdb_changes/blob/v1.0.0-def-seq/lib/logstash/inputs/couchdb_changes.rb#L117-L119 is more tenable. But I'd put a debug or info level log above those lines that shows what was actually read. This will help establish whether it was |
I dont know why the seq writing + (truncating) too frequently, while I ctrl+c (exiting) logstash leaves the file empty. I would guess it doesn't have a clean way to exit. My solution goes around the truncating problem. |
You're welcome to continue to use your fork/adapted code. I just can't merge it as-is. |
I understand. |
this issue references the question you had about seq being an integer |
I think there is also no bad authentication checking. It just crashes the plugin. |
I didn't want to open a new ticket, but, this is related to the sequence number. In the case of cloudant, this should be a string.
|
ES 1.7, LS 1.5, plugin version 1.0
Simple test: create empty seq file, set seq file in config, get error.
What caused the empty file?
Doing testing, hitting ctrl+c, ends up with empty sequence file most of the time (I must be stopping it the same time it truncates the file). If I set the default starting sequence, it always starts from 0, but no errors.
file is now empty.
this code:
Checks for seq file, but doesn't check the contents.
Possible solution:
My idea is to write to beginning of file with padding, instead of truncating. This way the file is never empty.
The text was updated successfully, but these errors were encountered: