Race condition in pg_database_size()

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Race condition in pg_database_size()
Дата
Msg-id 20070310163100.GA91660@winnie.fuhr.org
обсуждение исходный текст
Ответы Re: Race condition in pg_database_size()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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)           continue;
       snprintf(filename, MAXPGPATH, "%s/%s", path, direntry->d_name);
       if (stat(filename, &fst) < 0)           ereport(ERROR,                   (errcode_for_file_access(),
      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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Simon Riggs"
Дата:
Сообщение: Re: [PATCHES] scan_recycle_buffers
Следующее
От: "Pavel Stehule"
Дата:
Сообщение: what can be wrong? backport plpgpsm to 8.1