Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ge1Ni-0007Vi-Vj for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Dec 2018 17:29:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ge1Ng-0007Gs-NR for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Dec 2018 17:29:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ge1Ng-0007Gl-Ct for pgsql-hackers@lists.postgresql.org; Mon, 31 Dec 2018 17:29:36 +0000 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ge1Nd-0004YW-6m for pgsql-hackers@postgresql.org; Mon, 31 Dec 2018 17:29:35 +0000 Received: by mail-io1-xd2d.google.com with SMTP id p7so10808754iog.12 for ; Mon, 31 Dec 2018 09:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=CdxmHPD4hCt2PE4RqxWAfvtc7IKJohHrVgCzGBOgU/s=; b=HWfgwg0yycNGO2XYoNpL7JvtvLe2KYcjhtHjeYMQGMe9DxWYKmzxcb2pnKr7BZdssW jZGF+DY6nY2ndL51e1Ot0BOtAaMcmPzUeCUASE1Y11AIWlxBV5QpfJskYoL/Goth8vow zAA7oFxiZoy0BncIsKL3TKAXhGvjUk9nBnAGg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=CdxmHPD4hCt2PE4RqxWAfvtc7IKJohHrVgCzGBOgU/s=; b=lDQu/S66Zs0A+pc8RYUQrBH7nZYRZ5jXMLl+jdQDfJuzUOZXj12mHjcncDVuQdMeFB g9upntNP+6fVVH6JzwbSpUfJj6adQcWyZFkb3Meg051WrLz1e7wlIE0KRN9MJ/DfmCnI Lk00h9omZ91tnMxIDAgw0x2xDnNYtbC19p1Wx81u+29N7zYh40EIqchq2r7xTsclTE+0 IESVOlwSeMG9q4EeL9zKTAsv0j83fad5c9bQ1O3ayzjXjnLMQx+CK2QIzwLMeK9M4jT5 +/GwvkhMCVrg4+8EovMv4ptxkfQw35OoYYg859zudW7t/vXBDrSE07ca9GMh1ty5DcbT hylw== X-Gm-Message-State: AJcUukesDOcFX7wSQvmnllLPbu2XBV9O93LVJ+yZDoeArhzfjJV/Qukv Vw41DhETPaoMQYlRfhteaAr7UF2+Z6s= X-Google-Smtp-Source: ALg8bN5WptXqc8etXTIV+03OZGy9eYmG5Ug4TbLReZo8Rtj4n/4ouSDnq+rs3jLeugAdZo5M6WbAYA== X-Received: by 2002:a6b:be42:: with SMTP id o63mr29205351iof.147.1546277372083; Mon, 31 Dec 2018 09:29:32 -0800 (PST) Received: from gust.leadboat.com ([172.243.182.239]) by smtp.gmail.com with ESMTPSA id j8sm17848612itb.30.2018.12.31.09.29.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 09:29:31 -0800 (PST) Date: Mon, 31 Dec 2018 12:29:22 -0500 From: Noah Misch To: pgsql-hackers@postgresql.org Subject: pg_regress: promptly detect failed postmaster startup Message-ID: <20181231172922.GA199150@gust.leadboat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J/dobhs11T7y2rNN" Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --J/dobhs11T7y2rNN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline When "make check TEMP_CONFIG=<(echo break_me=on)" spawns a postmaster that fails startup, we detect that with "pg_regress: postmaster did not respond within 60 seconds". pg_regress has a kill(postmaster_pid, 0) intended to detect this case faster. Since kill(ZOMBIE-PID, 0) succeeds[1], that test is ineffective. The fix, attached, is to instead test waitpid(), like pg_ctl's wait_for_postmaster() does. [1] Search for "zombie" in http://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html --J/dobhs11T7y2rNN Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pg_regress-dead-postmaster-v1.patch" diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 63fe689..2c46941 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -2414,7 +2414,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc * Fail immediately if postmaster has exited */ #ifndef WIN32 - if (kill(postmaster_pid, 0) != 0) + if (waitpid(postmaster_pid, NULL, WNOHANG) == postmaster_pid) #else if (WaitForSingleObject(postmaster_pid, 0) == WAIT_OBJECT_0) #endif --J/dobhs11T7y2rNN--