kafka-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jun Rao <jun...@gmail.com>
Subject so_linger in socket
Date Fri, 22 Jul 2011 17:05:44 GMT
Hi,

We noticed that when we close the producer (and therefore the underlying
socket), the last batch of messages sometimes are not delivered to the
broker. We are not completely sure what's causing this, but suspect that may
have to do with the so_linger flag in socket. The following is a link and an
excerpt about the flag.

http://pubs.opengroup.org/onlinepubs/009695399/functions/setsockopt.html

SO_LINGER
Lingers on a *close*()<https://email.corp.linkedin.com/owa/redir.aspx?C=881a0d1e0e574952ac705b9d4e935272&URL=http%3a%2f%2fpubs.opengroup.org%2fonlinepubs%2f009695399%2ffunctions%2fclose.html>
if
data is present. This option controls the action taken when unsent messages
queue on a socket and
*close*()<https://email.corp.linkedin.com/owa/redir.aspx?C=881a0d1e0e574952ac705b9d4e935272&URL=http%3a%2f%2fpubs.opengroup.org%2fonlinepubs%2f009695399%2ffunctions%2fclose.html>
is
performed. If SO_LINGER is set, the system shall block the calling thread
during *close*()<https://email.corp.linkedin.com/owa/redir.aspx?C=881a0d1e0e574952ac705b9d4e935272&URL=http%3a%2f%2fpubs.opengroup.org%2fonlinepubs%2f009695399%2ffunctions%2fclose.html>
until
it can transmit the data or until the time expires. If SO_LINGER is not
specified, and *close*()<https://email.corp.linkedin.com/owa/redir.aspx?C=881a0d1e0e574952ac705b9d4e935272&URL=http%3a%2f%2fpubs.opengroup.org%2fonlinepubs%2f009695399%2ffunctions%2fclose.html>
is
issued, the system handles the call in a way that allows the calling thread
to continue as quickly as possible. This option takes a*linger* structure,
as defined in the
*<sys/socket.h>*<https://email.corp.linkedin.com/owa/redir.aspx?C=881a0d1e0e574952ac705b9d4e935272&URL=http%3a%2f%2fpubs.opengroup.org%2fonlinepubs%2f009695399%2fbasedefs%2fsys%2fsocket.h.html>
header,
to specify the state of the option and linger interval.

Anybody knows more about the socket stuff? Should so_linger be set to make
sure that the last unsent messages are delivered before close? Any downside
to enable so_linger?

Thanks,

Jun

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message