@ -988,7 +988,9 @@ static bool ReceiveAndUnpackTarFile(PGconn* conn, PGresult* res, int rownum)
|
||||
*/
|
||||
filename[strlen(filename) - 1] = '\0'; /* Remove trailing slash */
|
||||
if (is_dss_file(filename)) {
|
||||
continue;
|
||||
if (strstr(filename, "pg_replication") != NULL || strstr(filename, "pg_xlog") != NULL) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (symlink(©buf[bufOffset + 1], filename) != 0) {
|
||||
if (!streamwal || strcmp(filename + strlen(filename) - len, "/pg_xlog") != 0) {
|
||||
@ -1004,13 +1006,13 @@ static bool ReceiveAndUnpackTarFile(PGconn* conn, PGresult* res, int rownum)
|
||||
* Symbolic link for relative tablespace. please refer to function _tarWriteHeader
|
||||
*/
|
||||
filename[strlen(filename) - 1] = '\0'; /* Remove trailing slash */
|
||||
|
||||
nRet = snprintf_s(absolut_path,
|
||||
sizeof(absolut_path),
|
||||
sizeof(absolut_path) - 1,
|
||||
"%s/%s",
|
||||
basedir,
|
||||
©buf[bufOffset + 1]);
|
||||
if (is_dss_file(absolut_path)) {
|
||||
nRet = snprintf_s(absolut_path, sizeof(absolut_path), sizeof(absolut_path) - 1, "%s",
|
||||
©buf[bufOffset + 1]);
|
||||
} else {
|
||||
nRet = snprintf_s(absolut_path, sizeof(absolut_path), sizeof(absolut_path) - 1, "%s/%s",
|
||||
basedir, ©buf[bufOffset + 1]);
|
||||
}
|
||||
securec_check_ss_c(nRet, "\0", "\0");
|
||||
|
||||
if (symlink(absolut_path, filename) != 0) {
|
||||
@ -1547,8 +1549,13 @@ static bool BaseBackup(const char* dirname, uint32 term)
|
||||
char* relative = PQgetvalue(res, i, 3);
|
||||
char prefix[MAXPGPATH] = {'\0'};
|
||||
if (*relative == '1') {
|
||||
nRet = snprintf_s(prefix, MAXPGPATH, strlen(basedir) + 1, "%s/", basedir);
|
||||
securec_check_ss_c(nRet, "\0", "\0");
|
||||
if (ss_instance_config.dss.enable_dss) {
|
||||
nRet = snprintf_s(prefix, MAXPGPATH, strlen(dssdir) + 1, "%s/", dssdir);
|
||||
securec_check_ss_c(nRet, "\0", "\0");
|
||||
} else {
|
||||
nRet = snprintf_s(prefix, MAXPGPATH, strlen(basedir) + 1, "%s/", basedir);
|
||||
securec_check_ss_c(nRet, "\0", "\0");
|
||||
}
|
||||
}
|
||||
nRet = snprintf_s(nodetablespaceparentpath,
|
||||
MAXPGPATH,
|
||||
@ -1557,13 +1564,15 @@ static bool BaseBackup(const char* dirname, uint32 term)
|
||||
prefix,
|
||||
tablespacepath);
|
||||
securec_check_ss_c(nRet, "\0", "\0");
|
||||
nRet = snprintf_s(nodetablespacepath,
|
||||
MAXPGPATH,
|
||||
sizeof(nodetablespacepath) - 1,
|
||||
"%s/%s_%s",
|
||||
nodetablespaceparentpath,
|
||||
TABLESPACE_VERSION_DIRECTORY,
|
||||
pgxcnodename);
|
||||
|
||||
if (ss_instance_config.dss.enable_dss) {
|
||||
nRet = snprintf_s(nodetablespacepath, MAXPGPATH, MAXPGPATH - 1, "%s/%s",
|
||||
nodetablespaceparentpath, TABLESPACE_VERSION_DIRECTORY);
|
||||
} else {
|
||||
nRet = snprintf_s(nodetablespacepath, MAXPGPATH, MAXPGPATH - 1, "%s/%s_%s",
|
||||
nodetablespaceparentpath, TABLESPACE_VERSION_DIRECTORY,
|
||||
pgxcnodename);
|
||||
}
|
||||
securec_check_ss_c(nRet, "\0", "\0");
|
||||
|
||||
bool varifySuccess = verify_dir_is_empty_or_create(nodetablespacepath);
|
||||
|
||||
@ -1427,14 +1427,13 @@ void delete_datadir(const char* dirname)
|
||||
|
||||
/* */
|
||||
if (stat(linkpath, &st) == 0 && S_ISDIR(st.st_mode)) {
|
||||
|
||||
nRet = snprintf_s(nodepath,
|
||||
MAXPGPATH,
|
||||
sizeof(nodepath) - 1,
|
||||
"%s/%s_%s",
|
||||
linkpath,
|
||||
TABLESPACE_VERSION_DIRECTORY,
|
||||
pgxcnodename);
|
||||
if (ss_instance_config.dss.enable_dss) {
|
||||
nRet = snprintf_s(nodepath, MAXPGPATH, MAXPGPATH - 1, "%s/%s",
|
||||
linkpath, TABLESPACE_VERSION_DIRECTORY);
|
||||
} else {
|
||||
nRet = snprintf_s(nodepath, MAXPGPATH, MAXPGPATH - 1, "%s/%s_%s",
|
||||
linkpath, TABLESPACE_VERSION_DIRECTORY, pgxcnodename);
|
||||
}
|
||||
securec_check_ss_c(nRet, "", "");
|
||||
|
||||
if (!rmtree(nodepath, true, true)) {
|
||||
|
||||
@ -1174,8 +1174,13 @@ int64 sendTablespace(const char *path, bool sizeonly)
|
||||
/* If the tablespace went away while scanning, it's no error. */
|
||||
return 0;
|
||||
}
|
||||
if (!sizeonly)
|
||||
_tarWriteHeader(relativedirname, NULL, &statbuf);
|
||||
if (!sizeonly) {
|
||||
if (ENABLE_DSS) {
|
||||
_tarWriteHeader(pathbuf, NULL, &statbuf);
|
||||
} else {
|
||||
_tarWriteHeader(relativedirname, NULL, &statbuf);
|
||||
}
|
||||
}
|
||||
size = BUILD_PATH_LEN; /* Size of the header just added */
|
||||
|
||||
/* Send all the files in the tablespace version directory */
|
||||
@ -1297,10 +1302,15 @@ bool IsSkipPath(const char * pathName)
|
||||
|
||||
if (t_thrd.walsender_cxt.is_obsmode == true && strcmp(pathName, "./pg_replslot") == 0)
|
||||
return true;
|
||||
|
||||
/* skip pg_control in dss */
|
||||
if (ENABLE_DSS && strcmp(pathName, "+data/pg_control") == 0) {
|
||||
return true;
|
||||
if (ENABLE_DSS) {
|
||||
char full_path[MAXPGPATH];
|
||||
int rc = snprintf_s(full_path, sizeof(full_path), sizeof(full_path) - 1, "%s/pg_control",
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_data_vg_name);
|
||||
securec_check_ss(rc, "\0", "\0");
|
||||
if (strcmp(pathName, full_path) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1397,7 +1407,7 @@ static int64 sendDir(const char *path, int basepathlen, bool sizeonly, List *tab
|
||||
struct stat statbuf;
|
||||
int64 size = 0;
|
||||
int rc = 0;
|
||||
|
||||
char *dssdir = g_instance.attr.attr_storage.dss_attr.ss_dss_data_vg_name;
|
||||
DIR *dir = AllocateDir(path);
|
||||
while ((de = ReadDir(dir, path)) != NULL) {
|
||||
/* Skip special stuff */
|
||||
@ -1533,9 +1543,11 @@ static int64 sendDir(const char *path, int basepathlen, bool sizeonly, List *tab
|
||||
*/
|
||||
|
||||
/* when ss dorado replication enabled, "+data/pg_replication/" also need to copy when backup */
|
||||
int pathNameLen = strlen("+data/pg_xlog");
|
||||
if (strcmp(pathbuf, "./pg_xlog") == 0 || strncmp(pathbuf, "+data/pg_xlog", pathNameLen) == 0 ||
|
||||
strcmp(pathbuf, "+data/pg_replication") == 0 || strcmp(pathbuf, "+data/pg_tblspc") == 0) {
|
||||
if (strcmp(pathbuf, "./pg_xlog") == 0 ||
|
||||
(ENABLE_DSS && strncmp(pathbuf, dssdir, strlen(dssdir)) == 0 &&
|
||||
strstr(pathbuf + strlen(dssdir), "/pg_xlog") != NULL) ||
|
||||
(ENABLE_DSS && strcmp(pathbuf, dssdir) == 0 &&
|
||||
strstr(pathbuf + strlen(dssdir), "/pg_replication") != NULL)) {
|
||||
if (!sizeonly) {
|
||||
/* If pg_xlog is a symlink, write it as a directory anyway */
|
||||
#ifndef WIN32
|
||||
@ -1635,7 +1647,9 @@ static int64 sendDir(const char *path, int basepathlen, bool sizeonly, List *tab
|
||||
}
|
||||
|
||||
/* Allow symbolic links in pg_tblspc only */
|
||||
if (strcmp(path, "./pg_tblspc") == 0 &&
|
||||
if ((strcmp(path, "./pg_tblspc") == 0 ||
|
||||
(ENABLE_DSS && strncmp(pathbuf, dssdir, strlen(dssdir)) == 0 &&
|
||||
strstr(pathbuf + strlen(dssdir), "/pg_tblspc") != NULL)) &&
|
||||
#ifndef WIN32
|
||||
S_ISLNK(statbuf.st_mode)
|
||||
#else
|
||||
@ -1652,8 +1666,8 @@ static int64 sendDir(const char *path, int basepathlen, bool sizeonly, List *tab
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NAME_TOO_LONG), errmsg("symbolic link \"%s\" target is too long", pathbuf)));
|
||||
linkpath[rllen] = '\0';
|
||||
if (!sizeonly){
|
||||
if (ENABLE_DSS && is_dss_file(pathbuf)) {
|
||||
if (!sizeonly || ENABLE_DSS){
|
||||
if (is_dss_file(pathbuf)) {
|
||||
_tarWriteHeader(pathbuf, linkpath, &statbuf);
|
||||
} else {
|
||||
_tarWriteHeader(pathbuf + basepathlen + 1, linkpath, &statbuf);
|
||||
@ -1710,8 +1724,12 @@ static int64 sendDir(const char *path, int basepathlen, bool sizeonly, List *tab
|
||||
/*
|
||||
* skip sending directories inside pg_tblspc, if not required.
|
||||
*/
|
||||
if (strcmp(pathbuf, "./pg_tblspc") == 0 && !sendtblspclinks)
|
||||
if (strcmp(pathbuf, "./pg_tblspc") == 0 ||
|
||||
(ENABLE_DSS && strcmp(pathbuf, dssdir) == 0 &&
|
||||
strstr(pathbuf + strlen(dssdir), "/pg_tblspc") != NULL &&
|
||||
!sendtblspclinks)) {
|
||||
skip_this_dir = true;
|
||||
}
|
||||
if (!skip_this_dir)
|
||||
size += sendDir(pathbuf, basepathlen, sizeonly, tablespaces, sendtblspclinks);
|
||||
} else if (S_ISREG(statbuf.st_mode)) {
|
||||
|
||||
Reference in New Issue
Block a user