Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gH9Qd-0001AU-Ew for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Oct 2018 15:26:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gH9Qb-000830-A3 for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Oct 2018 15:26:05 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1gH9Qb-00082t-4A for pgsql-bugs@lists.postgresql.org; Mon, 29 Oct 2018 15:26:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gH9QY-0000t7-Hs for pgsql-bugs@lists.postgresql.org; Mon, 29 Oct 2018 15:26:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w9TFPmYS026975; Mon, 29 Oct 2018 11:25:48 -0400 From: Tom Lane To: Peter Geoghegan cc: paul.vanderlinden@mapcreator.eu, PostgreSQL mailing lists , Heikki Linnakangas Subject: Re: BUG #15460: Error while creating index or constraint In-reply-to: References: <15460-b6db80de822fa0ad@postgresql.org> Comments: In-reply-to Peter Geoghegan message dated "Mon, 29 Oct 2018 11:41:19 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26973.1540826748.1@sss.pgh.pa.us> Date: Mon, 29 Oct 2018 11:25:48 -0400 Message-ID: <26974.1540826748@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Geoghegan writes: > On Fri, Oct 26, 2018 at 10:32 AM PG Bug reporting form > wrote: >> pg_restore: [archiver (db)] could not execute query: ERROR: could not >> determine size of temporary file "0" >> Command was: CREATE INDEX nx_tablename ON tablename USING btree (col1); > I'm not sure what the exact problem might be, because I can't see why > the BufFileSize() thing would fail, even on Windows. So there are a couple of things to complain about here with respect to the error message, regardless of the underlying bug: * "0" is not a file name. Reporting it is just about useless, and identifying it as a "file" is a lie. Why aren't we reporting the actual name of the underlying file? (I realize that we might not have easy access to that right here. But now that this has been shown to be reachable in the field, it seems worth doing some extra work to make the error message useful.) * We aren't reporting the errno (no %m in the message). By luck, the errcode_for_file_access() call is enough to let us infer that it was ENOENT in this case, but in other cases that might not be enough. > I think that > using lseek() + SEEK_END to get the size of a file may only work on > POSIX, and yet I can see the same pattern in much older code (e.g., > _mdnblocks()). Yeah, that works fine on Windows AFAIK. I also note that ENOENT isn't an error code that lseek() can deliver, anyway, since it works on an already-open FD. The failure here must be coming from opening the file. I'm a little inclined to suspect that the true cause here is workers not correctly computing the name of this temp file, which is what led me to complain about the error message. Although a weak spot in this theory is that it's not clear why they'd not fail later anyway, unless maybe this particular file never got touched by workers before. > I have a strong suspicion that going back to passing the size through > shared memory (i.e. partially reverting 445e31bdc74) would make the > problem go away, but I won't do that until I actually understand > what's going on. Sounds like papering over the bug ... regards, tom lane