From: Pavan Deolasee Date: Fri, 3 Aug 2018 08:39:12 +0000 (+0530) Subject: Use correct path for tablspaces while creating a basebackup X-Git-Tag: XL_10_R1BETA1~41 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=ddf310a76e04c1bd37c6a44a71d8df402d90639c;p=postgres-xl.git Use correct path for tablspaces while creating a basebackup In XL, we embed the nodename in the tablespace subdir name to ensure that non-conflicting paths are created when multiple coordinators/datanodes are running on the same server. The code to handle tablespace mapping in basebackup was missing this support. Per report and patch by Wanglin. --- diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index 4a98eb9bdc..4194ab3c66 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -908,14 +908,17 @@ sendTablespace(char *path, bool sizeonly) { int64 size; char pathbuf[MAXPGPATH]; + char subdirbuf[MAXPGPATH]; struct stat statbuf; /* * 'path' points to the tablespace location, but we only want to include * the version directory in it that belongs to us. */ - snprintf(pathbuf, sizeof(pathbuf), "%s/%s", path, - TABLESPACE_VERSION_DIRECTORY); + snprintf(subdirbuf, sizeof(subdirbuf), "%s_%s", + TABLESPACE_VERSION_DIRECTORY, PGXCNodeName); + snprintf(pathbuf, sizeof(pathbuf), "%s/%s_%s", path, + TABLESPACE_VERSION_DIRECTORY, PGXCNodeName); /* * Store a directory entry in the tar file so we get the permissions @@ -933,8 +936,7 @@ sendTablespace(char *path, bool sizeonly) return 0; } - size = _tarWriteHeader(TABLESPACE_VERSION_DIRECTORY, NULL, &statbuf, - sizeonly); + size = _tarWriteHeader(subdirbuf, NULL, &statbuf, sizeonly); /* Send all the files in the tablespace version directory */ size += sendDir(pathbuf, strlen(path), sizeonly, NIL, true);