-
Notifications
You must be signed in to change notification settings - Fork 122
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
#270 Support periodic manual commits #275
base: main
Are you sure you want to change the base?
Conversation
Do we want to upgrade the travis build for Logstash 5.6? since it is failing due to:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I performed some manual tests and found some issues that must be addressed before we can merge this.
The wrong boolean makes it so that commits are never done, and the two scenarios that aren't address cause logstash to not commit during idle or shutdown, leading to unnecessary replays and duplicates.
|
||
def has_to_commit?(last_commit_time) | ||
# If auto_commit is enable we just leave the commit to the client library on poll and close actions | ||
return false if @enable_auto_commit == "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be return false if @enable_auto_commit == "true"
(we don't want to commit manually if auto commit is on)
@@ -266,8 +268,9 @@ def thread_runner(logstash_queue, consumer) | |||
end | |||
end | |||
# Manual offset commit | |||
if @enable_auto_commit == "false" | |||
if has_to_commit?(last_commit_time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by not committing anymore on all poll
operations we now have two issues that must be addressed:
- if you receive and process some events before
has_to_commit?
returns true and then no other events arrive, we'll never commit the offset because we have a guard at the start of the loop to skip if no records are returned from poll. - If events are processed but logstash is asked to terminate gracefully we don't commit the offset since the
stop
operation doesn't do it explicitly. Currently it relies on either commit per poll or auto commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I only took in account my case in which I have a pretty stable flow.
return false if @enable_auto_commit == "false" | ||
|
||
# If auto_commit is disable, we need to commit, we will do it depending on the manual_commit_interval option | ||
@manual_commit_interval_ms <= 0 || (last_commit_time + @manual_commit_interval_ms) < timestamp_ms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for clarity, we can change the big conditional into two operations:
def has_to_commit?(last_commit_time)
# auto_commit is enabled so we just leave the commit to the client library on poll and close actions
return false if @enable_auto_commit == "true"
# auto_commit is disabled but interval committing is disabled as well, so commit on every poll
return true if @manual_commit_interval_ms <= 0
# auto_commit is disabled and an interval is set, so let's check if enough time passed since last commit
(last_commit_time + @manual_commit_interval_ms) < current_timestamp_ms
end
Btw, a rebase against master should solve the test failures we're seeing here. |
I know we have talked about sanity checks, but in the worst scenario this would commit after each poll, doing the same thing that a manual commit with interval = 0 would do. So I think it is ok to do it like this. But let me know what you think!