-
Notifications
You must be signed in to change notification settings - Fork 1.4k
server plugin helper: ensure to close all connections at shutdown #5026
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thanks! |
daipom
reviewed
Jul 16, 2025
e75a9b1
to
eb4f482
Compare
daipom
previously approved these changes
Jul 16, 2025
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.
Thanks!
Basically, looks good to me!
I have commented on some minor points about the test code.
Signed-off-by: Shizuo Fujita <[email protected]>
Thanks! |
daipom
approved these changes
Jul 16, 2025
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.
LGTM
daipom
pushed a commit
to daipom/fluentd
that referenced
this pull request
Sep 10, 2025
…uent#5026) **Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: TCP server with `server` helper does not close all connections at shutdown process. When receiving data from multiple clients, the server receive the data continuously because the connection is not closed. The server will shut down properly by this PR ### Reproduce 1. Launch Fluentd with following config file. 2. Send syslog data from two or more clients using following client script 3. Terminate Fluentd 4. Relaunch Fluentd, then it shows the `2025-07-16 14:12:26 +0900 [warn]: #0 restoring buffer file: path = xxxxxxxxx` in logs. * config ``` <source> @type syslog tag system <transport tcp> </transport> bind 0.0.0.0 port 5140 </source> <match **> @type file path "#{File.expand_path('~/tmp/fluentd/maillog')}" <buffer> @type file path "#{File.expand_path('~/tmp/fluentd/buffer/buffer_syslog_maillog')}" flush_at_shutdown true </buffer> </match> ``` * client script ```ruby require 'bundler/inline' gemfile do source 'https://rubygems.org' gem 'remote_syslog_sender' end def create_client Thread.new do sender = RemoteSyslogSender.new('127.0.0.1', 5140, protocol: :tcp) loop do sender.transmit("message body") sleep 0.5 end end end clients = [] 3.times do clients << create_client end clients.each(&:join) ``` Example code. ``` @ary = [1,2,3] # It would like 1, 2, and 3 to be processed. # However, following code handles 1 and 3. @ary.each do |i| puts i @ary.delete(i) end ``` **Docs Changes**: Not needed. **Release Note**: Same as the title. Signed-off-by: Shizuo Fujita <[email protected]> Signed-off-by: Daijiro Fukuda <[email protected]>
daipom
pushed a commit
to daipom/fluentd
that referenced
this pull request
Sep 11, 2025
…uent#5026) **Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: TCP server with `server` helper does not close all connections at shutdown process. When receiving data from multiple clients, the server receive the data continuously because the connection is not closed. The server will shut down properly by this PR ### Reproduce 1. Launch Fluentd with following config file. 2. Send syslog data from two or more clients using following client script 3. Terminate Fluentd 4. Relaunch Fluentd, then it shows the `2025-07-16 14:12:26 +0900 [warn]: #0 restoring buffer file: path = xxxxxxxxx` in logs. * config ``` <source> @type syslog tag system <transport tcp> </transport> bind 0.0.0.0 port 5140 </source> <match **> @type file path "#{File.expand_path('~/tmp/fluentd/maillog')}" <buffer> @type file path "#{File.expand_path('~/tmp/fluentd/buffer/buffer_syslog_maillog')}" flush_at_shutdown true </buffer> </match> ``` * client script ```ruby require 'bundler/inline' gemfile do source 'https://rubygems.org' gem 'remote_syslog_sender' end def create_client Thread.new do sender = RemoteSyslogSender.new('127.0.0.1', 5140, protocol: :tcp) loop do sender.transmit("message body") sleep 0.5 end end end clients = [] 3.times do clients << create_client end clients.each(&:join) ``` Example code. ``` @ary = [1,2,3] # It would like 1, 2, and 3 to be processed. # However, following code handles 1 and 3. @ary.each do |i| puts i @ary.delete(i) end ``` **Docs Changes**: Not needed. **Release Note**: Same as the title. Signed-off-by: Shizuo Fujita <[email protected]> Signed-off-by: Daijiro Fukuda <[email protected]>
daipom
pushed a commit
to daipom/fluentd
that referenced
this pull request
Sep 11, 2025
…uent#5026) **Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: TCP server with `server` helper does not close all connections at shutdown process. When receiving data from multiple clients, the server receive the data continuously because the connection is not closed. The server will shut down properly by this PR ### Reproduce 1. Launch Fluentd with following config file. 2. Send syslog data from two or more clients using following client script 3. Terminate Fluentd 4. Relaunch Fluentd, then it shows the `2025-07-16 14:12:26 +0900 [warn]: #0 restoring buffer file: path = xxxxxxxxx` in logs. * config ``` <source> @type syslog tag system <transport tcp> </transport> bind 0.0.0.0 port 5140 </source> <match **> @type file path "#{File.expand_path('~/tmp/fluentd/maillog')}" <buffer> @type file path "#{File.expand_path('~/tmp/fluentd/buffer/buffer_syslog_maillog')}" flush_at_shutdown true </buffer> </match> ``` * client script ```ruby require 'bundler/inline' gemfile do source 'https://rubygems.org' gem 'remote_syslog_sender' end def create_client Thread.new do sender = RemoteSyslogSender.new('127.0.0.1', 5140, protocol: :tcp) loop do sender.transmit("message body") sleep 0.5 end end end clients = [] 3.times do clients << create_client end clients.each(&:join) ``` Example code. ``` @ary = [1,2,3] # It would like 1, 2, and 3 to be processed. # However, following code handles 1 and 3. @ary.each do |i| puts i @ary.delete(i) end ``` **Docs Changes**: Not needed. **Release Note**: Same as the title. Signed-off-by: Shizuo Fujita <[email protected]> Signed-off-by: Daijiro Fukuda <[email protected]>
daipom
added a commit
that referenced
this pull request
Sep 11, 2025
…s at shutdown (#5026) (#5088) **Which issue(s) this PR fixes**: * Backport #5026 **What this PR does / why we need it**: TCP server with `server` helper does not close all connections at shutdown process. When receiving data from multiple clients, the server receive the data continuously because the connection is not closed. The server will shut down properly by this PR ### Reproduce 1. Launch Fluentd with following config file. 2. Send syslog data from two or more clients using following client script 3. Terminate Fluentd 4. Relaunch Fluentd, then it shows the `2025-07-16 14:12:26 +0900 [warn]: #0 restoring buffer file: path = xxxxxxxxx` in logs. * config ``` <source> @type syslog tag system <transport tcp> </transport> bind 0.0.0.0 port 5140 </source> <match **> @type file path "#{File.expand_path('~/tmp/fluentd/maillog')}" <buffer> @type file path "#{File.expand_path('~/tmp/fluentd/buffer/buffer_syslog_maillog')}" flush_at_shutdown true </buffer> </match> ``` * client script ```ruby require 'bundler/inline' gemfile do source 'https://rubygems.org' gem 'remote_syslog_sender' end def create_client Thread.new do sender = RemoteSyslogSender.new('127.0.0.1', 5140, protocol: :tcp) loop do sender.transmit("message body") sleep 0.5 end end end clients = [] 3.times do clients << create_client end clients.each(&:join) ``` Example code. ``` @ary = [1,2,3] # It would like 1, 2, and 3 to be processed. # However, following code handles 1 and 3. @ary.each do |i| puts i @ary.delete(i) end ``` **Docs Changes**: Not needed. **Release Note**: Same as the title. Signed-off-by: Shizuo Fujita <[email protected]> Signed-off-by: Daijiro Fukuda <[email protected]> Co-authored-by: Shizuo Fujita <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue(s) this PR fixes:
Fixes #
What this PR does / why we need it:
TCP server with
server
helper does not close all connections at shutdown process.When receiving data from multiple clients, the server receive the data continuously because the connection is not closed.
The server will shut down properly by this PR
Reproduce
2025-07-16 14:12:26 +0900 [warn]: #0 restoring buffer file: path = xxxxxxxxx
in logs.Example code.
Docs Changes:
Not needed.
Release Note:
Same as the title.