pgpool2.git / summary / log / commit / refs

commit    ba6a9e4664f1ed738ea0355c75d8a4facfc2a7c0
Author:   Toshihiro Kitagawa <kitagawa at sraoss.co.jp>
Date:     Mon Aug 23 04:42:31 2010 +0000

    Fix pgpool_switch_xlog so that it checks the size of archived log file.


sql/pgpool-recovery/pgpool-recovery.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sql/pgpool-recovery/pgpool-recovery.c b/sql/pgpool-recovery/pgpool-recovery.c index 598f1b994..8408e3fc7 100644 --- a/sql/pgpool-recovery/pgpool-recovery.c +++ b/sql/pgpool-recovery/pgpool-recovery.c @@ -126,7 +126,7 @@ pgpool_remote_start(PG_FUNCTION_ARGS) Datum pgpool_switch_xlog(PG_FUNCTION_ARGS) { - char *basedir; + char *archive_dir; char *filename; char path[MAXPGPATH]; struct stat fst; @@ -136,16 +136,16 @@ pgpool_switch_xlog(PG_FUNCTION_ARGS) Oid switch_xlog_oid; Oid xlogfile_name_oid; - basedir = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(PG_GETARG_TEXT_P(0)))); + archive_dir = DatumGetCString(DirectFunctionCall1(textout, + PointerGetDatum(PG_GETARG_TEXT_P(0)))); - if (stat(basedir, &fst) < 0) + if (stat(archive_dir, &fst) < 0) #ifdef ERRCODE_INSUFFICIENT_PRIVILEGE ereport(ERROR, (errcode_for_file_access(), - errmsg("could not stat file \"%s\": %m", basedir))); + errmsg("could not stat file \"%s\": %m", archive_dir))); #else - elog(ERROR, "could not stat file \"%s\"", basedir); + elog(ERROR, "could not stat file \"%s\"", archive_dir); #endif switch_xlog_oid = get_function_oid("pg_switch_xlog", NULL, "pg_catalog"); @@ -159,10 +159,11 @@ pgpool_switch_xlog(PG_FUNCTION_ARGS) filename = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(filename_t))); - snprintf(path, MAXPGPATH, "%s/%s", basedir, filename); + snprintf(path, MAXPGPATH, "%s/%s", archive_dir, filename); elog(LOG, "pgpool_switch_xlog: waiting for \"%s\"", path); - while(stat(path, &fst) < 0) + while(stat(path, &fst) != 0 || fst.st_size == 0 || + fst.st_size % (1024 * 1024) != 0) { CHECK_FOR_INTERRUPTS(); sleep(1); [parent: 511e6be6b840]