Return-Path: X-Original-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6AE1618B73 for ; Tue, 13 Oct 2015 20:07:06 +0000 (UTC) Received: (qmail 61292 invoked by uid 500); 13 Oct 2015 20:07:06 -0000 Delivered-To: apmail-hadoop-common-issues-archive@hadoop.apache.org Received: (qmail 61247 invoked by uid 500); 13 Oct 2015 20:07:06 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-issues@hadoop.apache.org Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 61234 invoked by uid 99); 13 Oct 2015 20:07:06 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Oct 2015 20:07:06 +0000 Date: Tue, 13 Oct 2015 20:07:06 +0000 (UTC) From: "Haohui Mai (JIRA)" To: common-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HADOOP-12474) Fix data race when allocating server port in MiniKMS MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HADOOP-12474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14955544#comment-14955544 ] Haohui Mai commented on HADOOP-12474: ------------------------------------- +1. I'll commit it shortly. > Fix data race when allocating server port in MiniKMS > ----------------------------------------------------- > > Key: HADOOP-12474 > URL: https://issues.apache.org/jira/browse/HADOOP-12474 > Project: Hadoop Common > Issue Type: Bug > Reporter: Mingliang Liu > Assignee: Mingliang Liu > Attachments: HADOOP-12474.000.patch, HADOOP-12474.001.patch > > > In {{MiniKMS}}, there is potential data race when create jetty server in {{createJettyServer}}. It looks like the code searches for a free port and then starts jetty, but maybe there's enough of a race condition between port location and jetty.start to cause intermittent failures. > {code} > ServerSocket ss = new ServerSocket((inPort < 0) ? 0 : inPort, 50, localhost); > int port = ss.getLocalPort(); > Server server = new Server(0); > if (!ssl) { > server.getConnectors()[0].setHost(host); > server.getConnectors()[0].setPort(port); > } else { > ... > c.setPort(port); > {code} > We've seen test failures saying {{java.net.BindException: Address already in use}}, e.g. [https://builds.apache.org/job/PreCommit-HDFS-Build/12942/testReport/] > As in [HADOOP-12417], we should always bind port 0 which gives us an ephemeral port, instead of searching a free port before starting jetty. -- This message was sent by Atlassian JIRA (v6.3.4#6332)