Return-Path: X-Original-To: apmail-incubator-kafka-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-kafka-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D81A279C0 for ; Fri, 22 Jul 2011 17:06:11 +0000 (UTC) Received: (qmail 81175 invoked by uid 500); 22 Jul 2011 17:06:11 -0000 Delivered-To: apmail-incubator-kafka-dev-archive@incubator.apache.org Received: (qmail 81136 invoked by uid 500); 22 Jul 2011 17:06:11 -0000 Mailing-List: contact kafka-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: kafka-dev@incubator.apache.org Delivered-To: mailing list kafka-dev@incubator.apache.org Received: (qmail 81128 invoked by uid 99); 22 Jul 2011 17:06:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Jul 2011 17:06:10 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_FRT_STOCK2,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of junrao@gmail.com designates 74.125.82.175 as permitted sender) Received: from [74.125.82.175] (HELO mail-wy0-f175.google.com) (74.125.82.175) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Jul 2011 17:06:04 +0000 Received: by wyg30 with SMTP id 30so1824637wyg.6 for ; Fri, 22 Jul 2011 10:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=oKnJbji8jYHy378zvrSx6HNCcPrMCZZ3J+4jH4UgnS8=; b=b9jv3nWRlr9aNGD+B8qO2YhSDQW/T7I/+3yXLrqqudApL0LqyP23Y4uGCwWqmNQifN baMQ9fTMhOc1dYQ0VvnTr+L2JK+pPvO6uNeol5mxA9RjCYA056t2LRf0rmo+jH2UUtMI XiK2ZpCWDuLQC+c0HUYFFuM2OjDuZ/fmKjTQI= MIME-Version: 1.0 Received: by 10.216.62.204 with SMTP id y54mr1378512wec.73.1311354344544; Fri, 22 Jul 2011 10:05:44 -0700 (PDT) Received: by 10.216.93.139 with HTTP; Fri, 22 Jul 2011 10:05:44 -0700 (PDT) Date: Fri, 22 Jul 2011 10:05:44 -0700 Message-ID: Subject: so_linger in socket From: Jun Rao To: kafka-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=000e0ce0b836e19ac504a8ab79ed X-Virus-Checked: Checked by ClamAV on apache.org --000e0ce0b836e19ac504a8ab79ed Content-Type: text/plain; charset=ISO-8859-1 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*() if data is present. This option controls the action taken when unsent messages queue on a socket and *close*() is performed. If SO_LINGER is set, the system shall block the calling thread during *close*() until it can transmit the data or until the time expires. If SO_LINGER is not specified, and *close*() 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 ** 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 --000e0ce0b836e19ac504a8ab79ed--