logstash-plugins / logstash-output-tcp

Apache License 2.0
9 stars 31 forks source link

Do not silently discard undelivered messages #34

Open jsmucr opened 6 years ago

jsmucr commented 6 years ago

The plugin no longer discards messages which it fails to send if the server disconnects and sends some content prior to the disconnection.

Example situation before the fix:

  1. A connection is established between a server and the plugin.
  2. The plugin delivers some messages to the server. 2.1) It may or may not read something that it received from the server. 2.2) It sends the payload to the server.
  3. The server sends some content back and disconnects.
  4. The plugin tries to deliver some other messages to the server. 4.1) It tries to read (if r.any?) and expects to get an EOFError in case the server just died. 4.2) No error is thrown as some content just arrived from the server. It is discarded. 4.3) The first payload is written to the socket, no error being thrown. 4.4) The next payload finally fails with EOFError upon reading from the socket and an retry follows.

This commit fixes the 4.1 and 4.2 phases. The reading is now performed repeatedly while there's still something to read left so that we don't miss the EOFError exception.

yuri1969 commented 4 years ago

@jsvd, @ph, @danhermann is it possible to get an update on this? The v6.0.0 still silently drops the first message after a reconnect.

cla-checker-service[bot] commented 4 years ago

💚 CLA has been signed