mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-24 18:55:04 +08:00
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.
This commit is contained in:
parent
ffaf9eca4c
commit
00a7c9014a
@ -64,6 +64,12 @@
|
|||||||
#define TABLE_SPACE_SUBDIRS_CAT_VER 201001111
|
#define TABLE_SPACE_SUBDIRS_CAT_VER 201001111
|
||||||
/* postmaster/postgres -b (binary_upgrade) flag added during PG 9.1 development */
|
/* postmaster/postgres -b (binary_upgrade) flag added during PG 9.1 development */
|
||||||
#define BINARY_UPGRADE_SERVER_FLAG_CAT_VER 201104251
|
#define BINARY_UPGRADE_SERVER_FLAG_CAT_VER 201104251
|
||||||
|
/*
|
||||||
|
* Visibility map changed with this 9.2 commit,
|
||||||
|
* 8f9fe6edce358f7904e0db119416b4d1080a83aa; pick later catalog version.
|
||||||
|
*/
|
||||||
|
#define VISIBILITY_MAP_CRASHSAFE_CAT_VER 201107031
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Each relation is represented by a relinfo structure.
|
* Each relation is represented by a relinfo structure.
|
||||||
|
@ -120,9 +120,15 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
|
|||||||
int numFiles = 0;
|
int numFiles = 0;
|
||||||
int mapnum;
|
int mapnum;
|
||||||
int fileno;
|
int fileno;
|
||||||
|
bool vm_crashsafe_change = false;
|
||||||
|
|
||||||
old_dir[0] = '\0';
|
old_dir[0] = '\0';
|
||||||
|
|
||||||
|
/* Do not copy non-crashsafe vm files for binaries that assume crashsafety */
|
||||||
|
if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_CRASHSAFE_CAT_VER &&
|
||||||
|
new_cluster.controldata.cat_ver >= VISIBILITY_MAP_CRASHSAFE_CAT_VER)
|
||||||
|
vm_crashsafe_change = true;
|
||||||
|
|
||||||
for (mapnum = 0; mapnum < size; mapnum++)
|
for (mapnum = 0; mapnum < size; mapnum++)
|
||||||
{
|
{
|
||||||
char old_file[MAXPGPATH];
|
char old_file[MAXPGPATH];
|
||||||
@ -168,8 +174,16 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
|
|||||||
|
|
||||||
for (fileno = 0; fileno < numFiles; fileno++)
|
for (fileno = 0; fileno < numFiles; fileno++)
|
||||||
{
|
{
|
||||||
|
char *vm_offset = strstr(namelist[fileno]->d_name, "_vm");
|
||||||
|
bool is_vm_file = false;
|
||||||
|
|
||||||
|
/* Is a visibility map file? (name ends with _vm) */
|
||||||
|
if (vm_offset && strlen(vm_offset) == strlen("_vm"))
|
||||||
|
is_vm_file = true;
|
||||||
|
|
||||||
if (strncmp(namelist[fileno]->d_name, scandir_file_pattern,
|
if (strncmp(namelist[fileno]->d_name, scandir_file_pattern,
|
||||||
strlen(scandir_file_pattern)) == 0)
|
strlen(scandir_file_pattern)) == 0 &&
|
||||||
|
(!is_vm_file || !vm_crashsafe_change))
|
||||||
{
|
{
|
||||||
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
|
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
|
||||||
namelist[fileno]->d_name);
|
namelist[fileno]->d_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user