Обсуждение: "strange" pg_rewind error
Here is my pg_rewind command. Trying to make a former primary follow the newly-promoted standby...
/usr/pgsql-12/bin/pg_rewind -D '/apps/opt/postgres/pg12/data' --source-server='host=mypromotedstandby user=repmgr dbname=repmgr port=5432 password=mypassword connect_timeout=2'
Now I don't know if this matters but that log directory is actually a symlink pointing to a location that has log files in both the source and target.
Here is the error I get:
pg_rewind: servers diverged at WAL location 1/2F0000A0 on timeline 6
pg_rewind: rewinding from last common checkpoint at 1/2F000028 on timeline 6
pg_rewind: fatal: "/apps/opt/postgres/pg12/data/log" is not a directory
Here is the reference from the PostgreSQL source code where it is noted as "strange"
https://github.com/postgres/postgres/blob/master/src/bin/pg_rewind/filemap.c
process_source_file(const char *path, file_type_t type, size_t newsize,
const char *link_target)
{
...
...
...
switch (type)
{
case FILE_TYPE_DIRECTORY:
if (exists && !S_ISDIR(statbuf.st_mode) && strcmp(path, "pg_wal") != 0)
{
/* it's a directory in source, but not in target. Strange.. */
pg_fatal("\"%s\" is not a directory", localpath);
}
if (!exists)
action = FILE_ACTION_CREATE;
else
action = FILE_ACTION_NONE;
oldsize = 0;
break;
case FILE_TYPE_SYMLINK:
if (exists &&
Regards,
Michael Vitale
/usr/pgsql-12/bin/pg_rewind -D '/apps/opt/postgres/pg12/data' --source-server='host=mypromotedstandby user=repmgr dbname=repmgr port=5432 password=mypassword connect_timeout=2'
Now I don't know if this matters but that log directory is actually a symlink pointing to a location that has log files in both the source and target.
Here is the error I get:
pg_rewind: servers diverged at WAL location 1/2F0000A0 on timeline 6
pg_rewind: rewinding from last common checkpoint at 1/2F000028 on timeline 6
pg_rewind: fatal: "/apps/opt/postgres/pg12/data/log" is not a directory
Here is the reference from the PostgreSQL source code where it is noted as "strange"
https://github.com/postgres/postgres/blob/master/src/bin/pg_rewind/filemap.c
process_source_file(const char *path, file_type_t type, size_t newsize,
const char *link_target)
{
...
...
...
switch (type)
{
case FILE_TYPE_DIRECTORY:
if (exists && !S_ISDIR(statbuf.st_mode) && strcmp(path, "pg_wal") != 0)
{
/* it's a directory in source, but not in target. Strange.. */
pg_fatal("\"%s\" is not a directory", localpath);
}
if (!exists)
action = FILE_ACTION_CREATE;
else
action = FILE_ACTION_NONE;
oldsize = 0;
break;
case FILE_TYPE_SYMLINK:
if (exists &&
Regards,
Michael Vitale