Robert Haas wrote:
> > I am happy to have pg_upgrade skip upgrading visibility map files --- it
> > already has code to conditionally process them because they only exist
> > in >= 8.4:
> >
> > ? ? ? ?/* fsm/vm files added in PG 8.4 */
> > ? ? ? ?if (GET_MAJOR_VERSION(old_cluster.major_version) >= 804)
> > ? ? ? ?{
> > ? ? ? ? ? ?/*
> > ? ? ? ? ? ? * Copy/link any fsm and vm files, if they exist
> > ? ? ? ? ? ? */
> >
> > Just give the word and it will be done.
>
> I hereby give the word. :-)
>
> Specifically, we need to skip copying vm files (only) if coming from a
> version prior to this commit:
>
> http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=e16954f3d27fa8e16c379ff6623ae18d6250a39c
Done with the attached, applied patch. There was no cat-version bump
from that commit (because the format didn't change, just the
crash-safeness) so I picked the first cat-version change after this
commit. This is only a pg_upgrade 9.2+ issue.
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
new file mode 100644
index 6def748..a19b3df
*** a/contrib/pg_upgrade/pg_upgrade.h
--- b/contrib/pg_upgrade/pg_upgrade.h
***************
*** 64,69 ****
--- 64,75 ----
#define TABLE_SPACE_SUBDIRS_CAT_VER 201001111
/* postmaster/postgres -b (binary_upgrade) flag added during PG 9.1 development */
#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.
diff --git a/contrib/pg_upgrade/relfilenode.c b/contrib/pg_upgrade/relfilenode.c
new file mode 100644
index d4a420f..df752c5
*** a/contrib/pg_upgrade/relfilenode.c
--- b/contrib/pg_upgrade/relfilenode.c
*************** transfer_single_new_db(pageCnvCtx *pageC
*** 120,128 ****
int numFiles = 0;
int mapnum;
int fileno;
!
old_dir[0] = '\0';
for (mapnum = 0; mapnum < size; mapnum++)
{
char old_file[MAXPGPATH];
--- 120,134 ----
int numFiles = 0;
int mapnum;
int fileno;
! bool vm_crashsafe_change = false;
!
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++)
{
char old_file[MAXPGPATH];
*************** transfer_single_new_db(pageCnvCtx *pageC
*** 168,175 ****
for (fileno = 0; fileno < numFiles; fileno++)
{
if (strncmp(namelist[fileno]->d_name, scandir_file_pattern,
! strlen(scandir_file_pattern)) == 0)
{
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
namelist[fileno]->d_name);
--- 174,189 ----
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,
! strlen(scandir_file_pattern)) == 0 &&
! (!is_vm_file || !vm_crashsafe_change))
{
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
namelist[fileno]->d_name);
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers