Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit576027b

Browse files
committed
Fix a race condition that caused pg_database_size() and pg_tablespace_size()
to fail if an object was removed between calls to ReadDir() and stat().Per discussion in pgsql-hackers.http://archives.postgresql.org/pgsql-hackers/2007-03/msg00671.phpBug report and patch by Michael Fuhr.
1 parent5acde74 commit576027b

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

‎src/backend/utils/adt/dbsize.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Copyright (c) 2002-2007, PostgreSQL Global Development Group
66
*
77
* IDENTIFICATION
8-
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.11 2007/02/27 23:48:07 tgl Exp $
8+
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.12 2007/03/11 05:22:00 alvherre Exp $
99
*
1010
*/
1111

@@ -52,10 +52,14 @@ db_dir_size(const char *path)
5252
snprintf(filename,MAXPGPATH,"%s/%s",path,direntry->d_name);
5353

5454
if (stat(filename,&fst)<0)
55-
ereport(ERROR,
56-
(errcode_for_file_access(),
57-
errmsg("could not stat file \"%s\": %m",filename)));
58-
55+
{
56+
if (errno==ENOENT)
57+
continue;
58+
else
59+
ereport(ERROR,
60+
(errcode_for_file_access(),
61+
errmsg("could not stat file \"%s\": %m",filename)));
62+
}
5963
dirsize+=fst.st_size;
6064
}
6165

@@ -174,9 +178,14 @@ calculate_tablespace_size(Oid tblspcOid)
174178
snprintf(pathname,MAXPGPATH,"%s/%s",tblspcPath,direntry->d_name);
175179

176180
if (stat(pathname,&fst)<0)
177-
ereport(ERROR,
178-
(errcode_for_file_access(),
179-
errmsg("could not stat file \"%s\": %m",pathname)));
181+
{
182+
if (errno==ENOENT)
183+
continue;
184+
else
185+
ereport(ERROR,
186+
(errcode_for_file_access(),
187+
errmsg("could not stat file \"%s\": %m",pathname)));
188+
}
180189

181190
if (fst.st_mode&S_IFDIR)
182191
totalsize+=db_dir_size(pathname);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp