in_tcp: a parser error drops the other lines in the same read and closes the connection
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 64/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- ruby
- Área
- backend, networking
Línea de trabajo
Start in lib/fluent/plugin/in_tcp.rb at the parser calls around lines 144 and 195, then read how warn_pattern_not_matched handles invalid lines. Reproduce with the three-line TCP write from the issue and the supplied JSON parser configuration. Done means a bad line is warned about and dropped while valid lines before and after it are emitted and the connection stays open.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
in_tcp does not rescue errors from @parser.parse(msg) for each line. When the parser raises, the error goes up to the server helper. The helper logs unexpected error on reading data and closes the connection.
- With batch emit (the default), the lines already parsed in the same read are not emitted. The lines after the bad line are lost too.
- With single emit (
<extract>withtag_key), the lines before the bad line are emitted. The lines after it are lost.
A parser can raise on a normal input. For example, the json parser with time_format raises ParserError when the time field does not match the format. So one bad line from a client can drop its valid lines.
https://github.com/fluent/fluentd/blob/e7d3c3e4/lib/fluent/plugin/in_tcp.rb#L144
https://github.com/fluent/fluentd/blob/e7d3c3e4/lib/fluent/plugin/in_tcp.rb#L195
To Reproduce
Run Fluentd with the configuration below. Then send these three lines in one write:
{"k":"1"}
{"time":"bad","k":"2"}
{"k":"3"}
ruby -rsocket -e 'TCPSocket.open("127.0.0.1", 5170) { |s| s.write(%Q({"k":"1"}\n{"time":"bad","k":"2"}\n{"k":"3"}\n)); sleep 1 }'
Results on master (e7d3c3e4):
- Batch emit: no event is emitted.
{"k":"1"}and{"k":"3"}are lost. The server closes the connection. - Single emit (add
<extract>withtag_key tag):{"k":"1"}is emitted.{"k":"3"}is lost. The server closes the connection.
Expected behavior
Only the bad line is dropped, with a warning. This is how in_tcp handles a line that does not match the pattern (pattern not matched). The other lines are emitted, and the connection stays open.
Your Environment
- Fluentd version: master (e7d3c3e4). v1.20.1 and v1.19.4 have the same code (not run).
- Package version: -
- Operating system: Linux
- Kernel version: -
Your Configuration
<source>
@type tcp
port 5170
bind 127.0.0.1
tag test
<parse>
@type json
time_key time
time_format %Y-%m-%dT%H:%M:%S
</parse>
</source>
<match test>
@type stdout
</match>
Your Error Log
[error]: unexpected error on reading data host="127.0.0.1" port=39444 error_class=Fluent::Plugin::Parser::ParserError error="invalid time format: value = bad, error_class = ArgumentError, error = string doesn't match"
[error]: lib/fluent/plugin/parser.rb:195:in 'Fluent::Plugin::Parser#parse_time'
[error]: lib/fluent/plugin/parser_json.rb:70:in 'Fluent::Plugin::JSONParser#parse'
[error]: lib/fluent/plugin/in_tcp.rb:195:in 'block in Fluent::Plugin::TcpInput#start'
[error]: lib/fluent/plugin_helper/server.rb:661:in 'on_read_with_connection'
No test: {...} line is printed with batch emit.
Additional context
A possible fix is to rescue the error for each line. Then log a warning in the same way as warn_pattern_not_matched (truncated as in #5592), and go on to the next line.
- Lenguaje dominante
- Ruby
- Estrellas
- 13.6k
- Forks
- 1.4k
- Merge medio
- 17 h 28 min
- PR fusionados (30 d)
- 66
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de fluent/fluentd
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
parser_syslog: message_format auto parses RFC 3164 messages with an RFC 3339 timestamp as RFC 5424Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
Los mantenedores suelen responder en 1 día
-
out_forward: unacknowledged chunks are resent forever with heartbeat_type none, ignoring retry limits and secondaryPosiblemente ocupada @SahinurDEV la tomó hace 1 día. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 74/100
fluent/fluentd#5619 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
A label looked up at runtime during a graceful reload can keep dropping the events of a tagPosiblemente ocupada @sarankumar1325 la tomó hoy. Abiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
Los mantenedores suelen responder en 1 día
Todos los issues de fluent/fluentd
Issues similares
-
Websockify heartbeat for vnc_containerPosiblemente ocupada @robinkar la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
needs verification
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 7 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
akitaonrails/ai-book-2026#13 ·
-
Mend: dependency security vulnerability
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
Los mantenedores suelen responder en 1 día
-
Prism::Translation::Parser raises NoMethodError for a method with a &nil parameter and a bodyPosiblemente ocupada @bbatsov la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día