I'm occasionally seeing calls to pg_database_size() fail with

ERROR:  could not stat file "/var/lib/pgsql/data/base/16404/1738343": No such 
file or directory

So far I haven't noticed any other problems that might be related
to this error.  This database frequently uses temporary tables so
I'm wondering if the error might be due to a race condition in
db_dir_size(), which does the following:

    while ((direntry = ReadDir(dirdesc, path)) != NULL)
        struct stat fst;

        if (strcmp(direntry->d_name, ".") == 0 ||
            strcmp(direntry->d_name, "..") == 0)

        snprintf(filename, MAXPGPATH, "%s/%s", path, direntry->d_name);

        if (stat(filename, &fst) < 0)
                     errmsg("could not stat file \"%s\": %m", filename)));

        dirsize += fst.st_size;

I'm wondering if the code should check for ENOENT if stat() fails
and either skip this entry silently under the assumption that the
file had been deleted since the call to ReadDir(), or issue a warning
without failing.

Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to