Re: BUG #15460: Error while creating index or constraint
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Geoghegan <pg@bowt.ie>
Cc: paul.vanderlinden@mapcreator.eu,
PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>,
Heikki Linnakangas <hlinnaka@iki.fi>
Date: 2018-10-29T15:25:48Z
Lists: pgsql-bugs
Peter Geoghegan <pg@bowt.ie> writes: > On Fri, Oct 26, 2018 at 10:32 AM PG Bug reporting form > <noreply@postgresql.org> 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
Commits
-
Have BufFileSize() ereport() on FileSize() failure.
- 1a990b207b86 12.0 landed
- 95c45718126f 11.2 landed
-
Use 64 bit type for BufFileSize().
- fa2ceaca4358 11.2 landed
- aa5518304213 12.0 landed
-
Adjust trace_sort log messages.
- cb6f8a9a7243 12.0 landed
- 886319d71bd5 11.1 landed
-
Fix some sloppiness in the new BufFileSize() and BufFileAppend() functions.
- 445e31bdc749 11.0 cited