-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
in_udp: add test of message_length_limit #4117
in_udp: add test of message_length_limit #4117
Conversation
The new test is failing on Windows. I'm looking into it in detail.
|
At least on non-Windows, the data over https://pubs.opengroup.org/onlinepubs/009695399/functions/recvfrom.html
And there is no error |
On Windows, it seems that WSAEMSGSIZE error happens. https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recvfrom |
On Windows, sending data over $ bundle exec fluentd -c .\fluent\fluent.conf -v
2023-03-29 23:14:07 +0900 [info]: fluent/log.rb:360:info: init supervisor logger path=nil rotate_age=nil rotate_size=nil
2023-03-29 23:14:07 +0900 [info]: fluent/log.rb:360:info: parsing config file is succeeded path=".\\fluent\\fluent.conf"
2023-03-29 23:14:07 +0900 [info]: fluent/log.rb:360:info: gem 'fluentd' version '1.16.0'
2023-03-29 23:14:07 +0900 [debug]: fluent/log.rb:339:debug: No fluent logger for internal event
2023-03-29 23:14:07 +0900 [info]: fluent/log.rb:360:info: using configuration file: <ROOT>
<source>
@type udp
bind "192.168.10.8"
tag "test"
message_length_limit 32
<parse>
@type "none"
</parse>
</source>
<match test.**>
@type stdout
</match>
</ROOT>
2023-03-29 23:14:07 +0900 [info]: fluent/log.rb:360:info: starting fluentd-1.16.0 pid=4576 ruby="3.2.0"
2023-03-29 23:14:07 +0900 [info]: fluent/log.rb:360:info: spawn command to main: cmdline=["C:/Ruby32-x64/bin/ruby.exe", "-rC:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/bundler-2.4.8/lib/bundler/setup", "-Eutf-8", "C:/Ruby32-x64/lib/ruby/gems/3.2.0/bin/fluentd", "-c", ".\\fluent\\fluent.conf", "-v", "--under-supervisor"]
2023-03-29 23:14:10 +0900 [info]: #0 fluent/log.rb:360:info: init worker0 logger path=nil rotate_age=nil rotate_size=nil
2023-03-29 23:14:10 +0900 [info]: fluent/log.rb:360:info: adding match pattern="test.**" type="stdout"
2023-03-29 23:14:10 +0900 [info]: fluent/log.rb:360:info: adding source type="udp"
2023-03-29 23:14:10 +0900 [debug]: #0 fluent/log.rb:339:debug: No fluent logger for internal event
2023-03-29 23:14:10 +0900 [info]: #0 fluent/log.rb:360:info: starting fluentd worker pid=15020 ppid=4576 worker=0
2023-03-29 23:14:10 +0900 [info]: #0 fluent/log.rb:360:info: listening udp socket bind="192.168.10.8" port=5160
2023-03-29 23:14:10 +0900 [info]: #0 fluent/log.rb:360:info: fluentd worker is now running worker=0
2023-03-29 23:15:19.367809800 +0900 test: {"message":"hoge"}
2023-03-29 23:15:39 +0900 [error]: #0 fluent/log.rb:402:error: unexpected error in processing UDP data error_class=Errno::EMSGSIZE error="A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself. - recvfrom(2)"
2023-03-29 23:15:39 +0900 [error]: #0 cool.io/loop.rb:88:run_once: C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/plugin_helper/server.rb:558:in `recvfrom'
2023-03-29 23:15:39 +0900 [error]: #0 cool.io/loop.rb:88:run_once: C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/plugin_helper/server.rb:558:in `on_readable_with_sock'
2023-03-29 23:15:39 +0900 [error]: #0 cool.io/loop.rb:88:run_once: C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/cool.io-1.7.1/lib/cool.io/io.rb:186:in `on_readable'
2023-03-29 23:15:39 +0900 [error]: #0 cool.io/loop.rb:88:run_once: C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/cool.io-1.7.1/lib/cool.io/loop.rb:88:in `run_once'
2023-03-29 23:15:39 +0900 [error]: #0 cool.io/loop.rb:88:run_once: C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/cool.io-1.7.1/lib/cool.io/loop.rb:88:in `run'
2023-03-29 23:15:39 +0900 [error]: #0 cool.io/loop.rb:88:run_once: C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/plugin_helper/event_loop.rb:93:in `block in start'
2023-03-29 23:15:39 +0900 [error]: #0 cool.io/loop.rb:88:run_once: C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/plugin_helper/thread.rb:78:in `block in thread_create' |
On Ubuntu focal, the data over message_length_limit` are discarded without any error. $ bundle exec fluentd -c ../work/fluent.conf -v
2023-03-29 23:26:20 +0900 [info]: fluent/log.rb:360:info: init supervisor logger path=nil rotate_age=nil rotate_size=nil
2023-03-29 23:26:20 +0900 [info]: fluent/log.rb:360:info: parsing config file is succeeded path="../work/fluent.conf"
2023-03-29 23:26:20 +0900 [info]: fluent/log.rb:360:info: gem 'fluentd' version '1.16.0'
2023-03-29 23:26:20 +0900 [debug]: fluent/log.rb:339:debug: No fluent logger for internal event
2023-03-29 23:26:20 +0900 [info]: fluent/log.rb:360:info: using configuration file: <ROOT>
<system>
</system>
<source>
@type udp
tag "test"
bind "192.168.10.5"
message_length_limit 32
<parse>
@type "none"
</parse>
</source>
<match test.**>
@type stdout
</match>
<source>
@type monitor_agent
</source>
</ROOT>
2023-03-29 23:26:20 +0900 [info]: fluent/log.rb:360:info: starting fluentd-1.16.0 pid=982411 ruby="3.2.0"
2023-03-29 23:26:20 +0900 [info]: fluent/log.rb:360:info: spawn command to main: cmdline=["/home/daipom/.rbenv/versions/3.2.0/bin/ruby", "-r/home/daipom/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/bundler/setup", "-Eascii-8bit:ascii-8bit", "/home/daipom/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/bin/fluentd", "-c", "../work/fluent.conf", "-v", "--under-supervisor"]
2023-03-29 23:26:20 +0900 [info]: #0 fluent/log.rb:360:info: init worker0 logger path=nil rotate_age=nil rotate_size=nil
2023-03-29 23:26:20 +0900 [info]: fluent/log.rb:360:info: adding match pattern="test.**" type="stdout"
2023-03-29 23:26:20 +0900 [info]: fluent/log.rb:360:info: adding source type="udp"
2023-03-29 23:26:20 +0900 [info]: fluent/log.rb:360:info: adding source type="monitor_agent"
2023-03-29 23:26:20 +0900 [debug]: #0 fluent/log.rb:339:debug: No fluent logger for internal event
2023-03-29 23:26:20 +0900 [info]: #0 fluent/log.rb:360:info: starting fluentd worker pid=982431 ppid=982411 worker=0
2023-03-29 23:26:20 +0900 [debug]: #0 fluent/log.rb:339:debug: listening monitoring http server on http://0.0.0.0:24220/api/plugins for worker0
2023-03-29 23:26:20 +0900 [debug]: #0 fluent/log.rb:339:debug: Start async HTTP server listening http://0.0.0.0:24220
2023-03-29 23:26:20 +0900 [debug]: #0 fluent/log.rb:339:debug: 0.0s: Async::IO::Socket
| Binding to #<Addrinfo: 0.0.0.0:24220 TCP>
2023-03-29 23:26:20 +0900 [info]: #0 fluent/log.rb:360:info: listening udp socket bind="192.168.10.5" port=5160
2023-03-29 23:26:20 +0900 [info]: #0 fluent/log.rb:360:info: fluentd worker is now running worker=0
2023-03-29 23:26:47.859800904 +0900 test: {"message":"hoge"}
2023-03-29 23:26:52.054402922 +0900 test: {"message":"jfiaojeofpiajodkfjwoeeifojwiejok"} $ netcat -u 192.168.10.5 5160
hoge
jfiaojeofpiajodkfjwoeeifojwiejokdjfoewioweifj |
If we rescue fluentd/lib/fluent/plugin_helper/server.rb Lines 556 to 568 in 206b46b
|
We need to figure out what is the right specification. |
Could you try with an undocumented parameter fluentd/lib/fluent/plugin/in_udp.rb Line 46 in 206b46b
https://learn.microsoft.com/en-us/windows-hardware/drivers/network/so-rcvbuf I'm not sure whether it works as expected or not but it can tune the buffer size of a socket's receive buffer. |
Oh, thanks, I was not aware of that parameter. Now I have confirmed that it doesn't work as expected. (On Windows)
|
I think what we need to do is the following 2 things:
This behavior on Windows looks like not being considered so far. This can happen in
For |
Refs: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
Ruby's implementation:
WinSock might return truncated data but discarded by Ruby. |
It looks good, please go a head 👍 |
User might want to know which kind of data is lost, there is a similar feature request: #3739 |
Oh, I see! I will change the target of this PR to fixing |
Oh, now I understand. It is impossible because of
|
I made another PR to fix the helper. When that PR is merged, this PR's tests will succeed on Windows too. |
c874fc1
to
4aa4342
Compare
Signed-off-by: Daijiro Fukuda <[email protected]>
4aa4342
to
ea38c8f
Compare
Thanks! |
Thanks for your review! |
Which issue(s) this PR fixes:
None.
What this PR does / why we need it:
Add test of
message_length_limit
forin_udp
because there was no test for this option.Docs Changes:
Not needed.
Release Note:
Not needed.