Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 00a7c90

Browse files
committed
In pg_upgrade, don't copy visibility map files from clusters that did not
have crash-safe visibility maps to clusters that expect crash-safety. Request from Robert Haas.
1 parent ffaf9ec commit 00a7c90

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

contrib/pg_upgrade/pg_upgrade.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
#define TABLE_SPACE_SUBDIRS_CAT_VER 201001111
6565
/* postmaster/postgres -b (binary_upgrade) flag added during PG 9.1 development */
6666
#define BINARY_UPGRADE_SERVER_FLAG_CAT_VER 201104251
67+
/*
68+
* Visibility map changed with this 9.2 commit,
69+
* 8f9fe6edce358f7904e0db119416b4d1080a83aa; pick later catalog version.
70+
*/
71+
#define VISIBILITY_MAP_CRASHSAFE_CAT_VER 201107031
72+
6773

6874
/*
6975
* Each relation is represented by a relinfo structure.

contrib/pg_upgrade/relfilenode.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,15 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
120120
int numFiles = 0;
121121
int mapnum;
122122
int fileno;
123-
123+
bool vm_crashsafe_change = false;
124+
124125
old_dir[0] = '\0';
125126

127+
/* Do not copy non-crashsafe vm files for binaries that assume crashsafety */
128+
if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_CRASHSAFE_CAT_VER &&
129+
new_cluster.controldata.cat_ver >= VISIBILITY_MAP_CRASHSAFE_CAT_VER)
130+
vm_crashsafe_change = true;
131+
126132
for (mapnum = 0; mapnum < size; mapnum++)
127133
{
128134
char old_file[MAXPGPATH];
@@ -168,8 +174,16 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
168174

169175
for (fileno = 0; fileno < numFiles; fileno++)
170176
{
177+
char *vm_offset = strstr(namelist[fileno]->d_name, "_vm");
178+
bool is_vm_file = false;
179+
180+
/* Is a visibility map file? (name ends with _vm) */
181+
if (vm_offset && strlen(vm_offset) == strlen("_vm"))
182+
is_vm_file = true;
183+
171184
if (strncmp(namelist[fileno]->d_name, scandir_file_pattern,
172-
strlen(scandir_file_pattern)) == 0)
185+
strlen(scandir_file_pattern)) == 0 &&
186+
(!is_vm_file || !vm_crashsafe_change))
173187
{
174188
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
175189
namelist[fileno]->d_name);

0 commit comments

Comments
 (0)