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

Appearance settings

Commit 2f3e234

Browse filesBrowse files
committed
Fix pg_rewind to handle relation data files in tablespaces properly.
pg_rewind checks whether each file is a relation data file, from its path. Previously this check logic had the bug which made pg_rewind fail to recognize any relation data files in tablespaces. Which also caused an assertion failure in pg_rewind. Back-patch to 9.5 where pg_rewind was added. Author: Takayuki Tsunakawa Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/0A3221C70F24FB45833433255569204D1F8D6C7A@G01JPEXMBYT05
1 parent 09230e5 commit 2f3e234
Copy full SHA for 2f3e234

File tree

Expand file treeCollapse file tree

1 file changed

+8
-10
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-10
lines changed

‎src/bin/pg_rewind/filemap.c

Copy file name to clipboardExpand all lines: src/bin/pg_rewind/filemap.c
+8-10Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "pg_rewind.h"
2020

2121
#include "common/string.h"
22+
#include "catalog/catalog.h"
2223
#include "catalog/pg_tablespace.h"
2324
#include "storage/fd.h"
2425

@@ -554,7 +555,6 @@ print_filemap(void)
554555
static bool
555556
isRelDataFile(const char *path)
556557
{
557-
char buf[20 + 1];
558558
RelFileNode rnode;
559559
unsigned int segNo;
560560
int nmatch;
@@ -569,7 +569,7 @@ isRelDataFile(const char *path)
569569
* base/<db oid>/
570570
* regular relations, default tablespace
571571
*
572-
* pg_tblspc/<tblspc oid>/PG_9.4_201403261/
572+
* pg_tblspc/<tblspc oid>/<tblspc version>/
573573
* within a non-default tablespace (the name of the directory
574574
* depends on version)
575575
*
@@ -603,21 +603,19 @@ isRelDataFile(const char *path)
603603
}
604604
else
605605
{
606-
nmatch = sscanf(path, "pg_tblspc/%u/PG_%20s/%u/%u.%u",
607-
&rnode.spcNode, buf, &rnode.dbNode, &rnode.relNode,
606+
nmatch = sscanf(path, "pg_tblspc/%u/" TABLESPACE_VERSION_DIRECTORY "/%u/%u.%u",
607+
&rnode.spcNode, &rnode.dbNode, &rnode.relNode,
608608
&segNo);
609-
if (nmatch == 4 || nmatch == 5)
609+
if (nmatch == 3 || nmatch == 4)
610610
matched = true;
611611
}
612612
}
613613

614614
/*
615615
* The sscanf tests above can match files that have extra characters at
616-
* the end, and the last check can also match a path belonging to a
617-
* different version (different TABLESPACE_VERSION_DIRECTORY). To make
618-
* eliminate such cases, cross-check that GetRelationPath creates the
619-
* exact same filename, when passed the RelFileNode information we
620-
* extracted from the filename.
616+
* the end. To eliminate such cases, cross-check that GetRelationPath
617+
* creates the exact same filename, when passed the RelFileNode information
618+
* we extracted from the filename.
621619
*/
622620
if (matched)
623621
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.