From e6a0569000ad86a35c77570d6308d31c1a7750d7 Mon Sep 17 00:00:00 2001 From: chenzhikai <895543892@qq.com> Date: Tue, 4 Jul 2023 16:08:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3ss=E5=8F=8C=E9=9B=86=E7=BE=A4?= =?UTF-8?q?build=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/pg_ctl/backup.cpp | 62 ++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/src/bin/pg_ctl/backup.cpp b/src/bin/pg_ctl/backup.cpp index 6563a8d960..b4c65ff5c7 100755 --- a/src/bin/pg_ctl/backup.cpp +++ b/src/bin/pg_ctl/backup.cpp @@ -143,7 +143,7 @@ void get_xlog_location(char (&xlog_location)[MAXPGPATH]); static bool UpdatePaxosIndexFile(unsigned long long paxosIndex); static bool DeleteAlreadyDropedFile(const char* path, bool is_table_space); static int DeleteUnusedFile(const char* path, unsigned int SegNo, unsigned int fileNode); - +static void BeginGetXlogbyStream(char* xlogstart, uint32 timeline, char* sysidentifier, char* xlog_location, uint term, PGresult* res); /* * tblspaceDirectory is used for saving the table space directory created by * full-build. tblspaceNum is the count of table space. The table space directory @@ -1529,31 +1529,14 @@ static bool BaseBackup(const char* dirname, uint32 term) return false; } - show_full_build_process("begin get xlog by xlogstream"); - /* - * If we're streaming WAL, start the streaming session before we start - * receiving the actual data chunks. - */ - if (streamwal) { - if (verbose) { - pg_log(PG_WARNING, _("starting background WAL receiver\n")); - } - show_full_build_process("starting walreceiver"); - bool startSuccess = StartLogStreamer(xlogstart, timeline, sysidentifier, (const char*)xlog_location, term); - if (!startSuccess) { - pg_log(PG_WARNING, _("start log streamer failed \n")); - pg_free(sysidentifier); - sysidentifier = NULL; - DisconnectConnection(); - PQclear(res); - return false; - } + * in order to avoid sharing the same dssserver session, + * we will not start logstreaming here + */ + if (!instance_config.dss.enable_dss) { + BeginGetXlogbyStream(xlogstart, timeline, sysidentifier, xlog_location, term, res); } - /* free sysidentifier after use */ - pg_free(sysidentifier); - sysidentifier = NULL; show_full_build_process("begin receive tar files"); /* @@ -1674,6 +1657,10 @@ static bool BaseBackup(const char* dirname, uint32 term) } #endif + if (instance_config.dss.enable_dss) { + BeginGetXlogbyStream(xlogstart, timeline, sysidentifier, xlog_location, term, res); + } + if (bgchild > 0) { #ifndef WIN32 int status; @@ -2781,3 +2768,32 @@ bool RenameTblspcDir(char *dataDir) return true; } + +static void BeginGetXlogbyStream(char* xlogstart, uint32 timeline, char* sysidentifier, char* xlog_location, uint term, PGresult* res) +{ + show_full_build_process("begin get xlog by xlogstream"); + /* + * If we're streaming WAL, start the streaming session before we start + * receiving the actual data chunks. + */ + if (streamwal) { + if (verbose) { + pg_log(PG_WARNING, _("starting background WAL receiver\n")); + } + show_full_build_process("starting walreceiver"); + bool startSuccess = StartLogStreamer(xlogstart, timeline, sysidentifier, (const char*)xlog_location, term); + if (!startSuccess) { + pg_log(PG_WARNING, _("start log streamer failed \n")); + pg_free(sysidentifier); + sysidentifier = NULL; + DisconnectConnection(); + PQclear(res); + pg_log(PG_WARNING, _("build failed \n")); + exit(1); + } + } + + /* free sysidentifier after use */ + pg_free(sysidentifier); + sysidentifier = NULL; +} \ No newline at end of file -- Gitee