Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TNfh7-0002Xx-Ga for pgsql-bugs@postgresql.org; Mon, 15 Oct 2012 08:06:37 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TNfh1-00061i-Oj for pgsql-bugs@postgresql.org; Mon, 15 Oct 2012 08:06:37 +0000 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 9EF322896A; Mon, 15 Oct 2012 01:06:28 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 985D5187A1; Mon, 15 Oct 2012 01:06:28 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 33A9612199D; Mon, 15 Oct 2012 01:05:34 -0700 (PDT) X-Virus-Scanned: amavisd-new at zcs-prod-ext-mta-1.vmware.com Received: from zcs-prod-ext-mta-1.vmware.com ([127.0.0.1]) by localhost (zcs-prod-ext-mta-1.vmware.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id b5MI3hKha19q; Mon, 15 Oct 2012 01:05:33 -0700 (PDT) Received: from [192.168.1.101] (unknown [10.113.62.14]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA id 0A3C6121568; Mon, 15 Oct 2012 01:05:32 -0700 (PDT) Message-ID: <507BC402.40807@vmware.com> Date: Mon, 15 Oct 2012 11:06:26 +0300 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.7) Gecko/20120922 Icedove/10.0.7 MIME-Version: 1.0 To: Tom Lane CC: Pg Bugs , Dave Vitek Subject: Re: Fwd: race in pg_ctl start -w References: <5076F626.2090404@grammatech.com> <5076FF23.6020704@iki.fi> <22107.1349976592@sss.pgh.pa.us> <50771713.8000908@vmware.com> <25454.1349984162@sss.pgh.pa.us> In-Reply-To: <25454.1349984162@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.3 (-------) X-Archive-Number: 201210/131 X-Sequence-Number: 34431 On 11.10.2012 22:36, Tom Lane wrote: > Heikki Linnakangas writes: >> Hmm, starting with 9.3, postmaster can not only create and append to the >> end of file, it can also inject a line in the middle, shifting the >> following lines forwards. In theory, if a new line is injected into the >> middle of the file between fgets() calls, readfile() could read part of >> the same line twice. Not sure what consequences that could have; pg_ctl >> might try to connect to wrong address or socket directory. > > Hm. IIRC, the postmaster is careful to write the whole thing in a > single write() call, which in principle is atomic. Perhaps you're > right that we'd better have pg_ctl read it in a single read() to > ensure that it sees a consistent file state. Otherwise we're making > assumptions about what sort of buffering underlies the stdio functions. Ok, changed it to slurp the whole file to memory with one read() call. Dave, did this silence the static analysis tool you used? - Heikki