Re: pg_resetwal: Fix wrong directory in log output - Mailing list pgsql-hackers

From Chao Li
Subject Re: pg_resetwal: Fix wrong directory in log output
Date
Msg-id 1BEA161A-B1DC-494C-B235-A47FEE1D7B68@gmail.com
Whole thread Raw
In response to pg_resetwal: Fix wrong directory in log output  ("zhang_tian_chen@163.com" <zhang_tian_chen@163.com>)
Responses Re: pg_resetwal: Fix wrong directory in log output
Re:Re: pg_resetwal: Fix wrong directory in log output
List pgsql-hackers

> On Feb 3, 2026, at 09:58, zhang_tian_chen@163.com wrote:
>
> Hi hackers,
>
> There is a misuse of macro when we output directory information in KillExistingWALSummaries(), pg_resetwal.c. Which
shouldbe WALSUMMARYDIR instead of ARCHSTATDIR. 
>
> Best regards,
> Tianchen Zhang<v1-0001-Fix-incorrect-directory-macro-in-KillExistingWALS.patch>

Indeed a bug. Looking at the code:

```
/*
 * Remove existing WAL summary files
 */
static void
KillExistingWALSummaries(void)
{
    DIR           *xldir;

    xldir = opendir(WALSUMMARYDIR);
    if (xldir == NULL)
        pg_fatal("could not open directory \"%s\": %m", WALSUMMARYDIR);
        ...

    if (errno)
        pg_fatal("could not read directory \"%s\": %m", WALSUMMARYDIR);

    if (closedir(xldir))
        pg_fatal("could not close directory \"%s\": %m", ARCHSTATDIR); <<=== It should really be WALSUMMARYDIR
}
```

I guess closedir() is hard to fail, that’s why the problem has not been noticed earlier.

The patch is straightforward and looks correct.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pg_resetwal: Fix wrong directory in log output
Next
From: jian he
Date:
Subject: Re: pg_dumpall --roles-only interact with other options