Обсуждение: db size difference on primary and standby

Поиск
Список
Период
Сортировка

db size difference on primary and standby

От
Eric Wong
Дата:
Hi postgres guru out there:

We discovered a disk usage difference between our primary and standby node.

After much investigation, the disk usage difference is caused by some
extra files within the database directory 16432.  The extra files are
only found on the standby node, not present on the primary.

In the data directory ("15/data/base/16432"), the extra files do not
seem to belong to any table. Normally, the files correspond to the
column "relfilenode" in the "pg_class" system table; however, when we
compare the entries in that column with the file names, around 600 of
the files do not have a corresponding entry in the "pg_class" table.
The same applies to the files in the "san" tablespace
("pg_tblspc/san/PG_15_202209061/16432").

Has anyone seen this behavior before?  Also, we also want to know if
it is safe to remove all those extra files that do not have an entry
in the "pg_class" table?

Thanks in advance
Eric



Re: db size difference on primary and standby

От
Laurenz Albe
Дата:
On Thu, 2023-11-16 at 14:49 +0800, Eric Wong wrote:
> We discovered a disk usage difference between our primary and standby node.
>
> After much investigation, the disk usage difference is caused by some
> extra files within the database directory 16432.  The extra files are
> only found on the standby node, not present on the primary.
>
> In the data directory ("15/data/base/16432"), the extra files do not
> seem to belong to any table. Normally, the files correspond to the
> column "relfilenode" in the "pg_class" system table; however, when we
> compare the entries in that column with the file names, around 600 of
> the files do not have a corresponding entry in the "pg_class" table.
> The same applies to the files in the "san" tablespace
> ("pg_tblspc/san/PG_15_202209061/16432").
>
> Has anyone seen this behavior before?  Also, we also want to know if
> it is safe to remove all those extra files that do not have an entry
> in the "pg_class" table?

If the files only exist on the standby, you can safely remove them.
Be careful, however: if you make a mistake, you'll corrupt your database.

Orphaned files like that can be left behind after a database crash.
Did you experience crashes on the standby?

Yours,
Laurenz Albe