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 1ii8D4-0007zr-8V for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Dec 2019 02:40:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ii8D2-000587-Vh for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Dec 2019 02:40:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ii8D2-00056F-Kt for pgsql-bugs@lists.postgresql.org; Fri, 20 Dec 2019 02:40:08 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ii8Cz-0003i8-AA for pgsql-bugs@lists.postgresql.org; Fri, 20 Dec 2019 02:40:07 +0000 Received: by mail-lj1-x242.google.com with SMTP id u71so8383365lje.11 for ; Thu, 19 Dec 2019 18:40:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=ax/cY1gbgpkmpRHP3gPo+Fx1uOC6tFmlALPH9gOWE44=; b=T2Cl2YW/Am/ERTeor5xavbUw3s5M9LGYSYt7QsCyEmyJJsZ4OOz6FxsPKY+WpsJkIY s6mcpFDJjzmzxHcPQmfvLwUwmrE3NMSDndk5fVRXznjsF1WbWxK6eB9ame2Wwfbcspvd nus/46f6JU+5O5NA1P4EvUXqvzOKVhp72da/QrMeGQsgTLC60piGHzghth3IGkDX6/II oqfFePE5HhWjaPM0VXOIadBlUAwJwIhWDMVITWMrZBGbDjjzxPwNbo8aYcv44Fu0yOZj tLQyl72iUy4fkHOKcynJvIUJTRp6ABtHcKbz3NXgj9D9Cy9QGfhsCWAZGI0EPZLLvVgL ciwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=ax/cY1gbgpkmpRHP3gPo+Fx1uOC6tFmlALPH9gOWE44=; b=GXAXVkM583p17HP3K7eL+cKjk1fs+0aUf55kYeykUiBoE3c1M+Vn6zirhPiIRyqCce Ky5Af1M0H+GZW1tFAZob9sPS8fW1hsclmczbisqCU8cQJ0cQ/vxw4cwpYOlsvejcEuu2 BCzkeQnsj3QopnbdYR7q83tYv0ilAVtqgw1ncun7az3iGdsmnU8EL+RpQgk8BQdh5kmP 5wVUvwcc0csPc6Af648KKcUCewrrHPJyTEvBD20iuT+sfQ/y34Bsm0XJ+A79op4MjqRL DCXCQN9rxYx5Qyt8Fwv9L0uIVeRw26BpEXicMGU88683NEeV1/4r2+XPNQ6tjjFHVwaO MH0g== X-Gm-Message-State: APjAAAUPAgJS+o5C+tBW0eAnVpohJkRLF4ilfhsvDmkArKf1Nu7SJP99 h3ZomsQ/2GexYfTNVgUG/uoGOwoF X-Google-Smtp-Source: APXvYqwPzbxHYLXKD8/UMK26WIxaN7Hak4dOCogblY3R0t2T0Ms3hCZDu09nDfV09p5R7J43P3mu8A== X-Received: by 2002:a2e:8152:: with SMTP id t18mr8262893ljg.255.1576809602261; Thu, 19 Dec 2019 18:40:02 -0800 (PST) Received: from [1.0.0.7] ([178.155.4.214]) by smtp.gmail.com with ESMTPSA id i13sm3523836ljg.89.2019.12.19.18.40.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2019 18:40:01 -0800 (PST) Subject: Re: BUG #16161: pg_ctl stop fails sometimes (on Windows) To: Tom Lane Cc: Kyotaro Horiguchi , pgsql-bugs@lists.postgresql.org References: <4741.1576684991@sss.pgh.pa.us> <26441.1576706955@sss.pgh.pa.us> <20191219.103948.2182167132387989763.horikyota.ntt@gmail.com> <32374.1576770248@sss.pgh.pa.us> <5c7eaa87-8670-2008-3a15-337c133c12c2@gmail.com> <12599.1576786185@sss.pgh.pa.us> From: Alexander Lakhin Message-ID: Date: Fri, 20 Dec 2019 05:40:00 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <12599.1576786185@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 19.12.2019 23:09, Tom Lane wrote: > Alexander Lakhin writes: >> Maybe we should change the condition to 'if (stat(fileName, &st) != 0 && >> (err = GetLastError()) == ERROR_ACCESS_DENIED)' to avoid unnecessary >> sleep with a loop iteration... > Well, we have to loop back on file-not-found too ... I think, if the file is not found on stat() we can safely return the updated err (set errno with _dosmapper(err), to be exact). If we'll loop back, we'll get the same err = GetLastError() after next CreateFile(). >> It seems that the check for ERROR_DELETE_PENDING was added to >> pgwin32_safestat() blindly, the issue wasn't reproduced at that time: >> https://www.postgresql.org/message-id/CAB7nPqRJV6trFta-Qzgi6j2feuYR2ZC%2BKHvWdHnbpDG2scTrxw%40mail.gmail.com > Hmm, makes one wonder whether that's actually live code. I'll try to research this matter meantime. Best regards, Alexander