pg_database_size issue an error (ERROR: could not stat file "base/16384/20041": Permission denied) - Mailing list pgsql-hackers

From Christophe GUILLOT
Subject pg_database_size issue an error (ERROR: could not stat file "base/16384/20041": Permission denied)
Date
Msg-id CAJHRyAEJhwvHE25nk+-GBKZnMPWy8O9UhR3XgTw9SJc+7oZmZA@mail.gmail.com
Whole thread Raw
List pgsql-hackers
Hi all,
The usage of the pg_database_size function generate a lot of "permission denied" log errors. 
Typical message is: ERROR:  could not stat file "base/16384/20041": Permission denied.

As a short description:
- PostgreSQL 9.2.1/64 bits
- our system is running on windows platform (W7, W2008) 
- frequent alter/create/drop of tables
- call to pg_database_size, sometimes.

When logging file system activity (using procmon, W7), the query made on the file printed in the log message return a “DELETE PENDING” state and i only find a handle to this file owned by a postgres executable.

After code exploration, it looks like the functions from "dbsize.c" should use the same trick as found in "md.c" (i mean the FILE_POSSIBLY_DELETED macro) for testing each "stat()" returned error code.

So, is it a good idea to patch dbsize.c with the same macro, which on windows platform include the EACCES error code as a possibly deleted file, or not. Or is it the wrong way ? I didn't try to patch yet.

Thanks for your help,

Christophe

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Shuffling xlog header files
Next
From: Robert Haas
Date:
Subject: Re: MySQL search query is not executing in Postgres DB