From fd1efa9d41c2ea47a8b50fe88f10d1285f92ceaf Mon Sep 17 00:00:00 2001 From: zhaobingyu <1783692558@qq.com> Date: Wed, 18 Jan 2023 19:01:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9issue:=20pg=5Fresetxlog?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=A4=B1=E8=B4=A5=E6=8A=A5=E9=94=99=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=90=88=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/pg_resetxlog/pg_resetxlog.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_resetxlog/pg_resetxlog.cpp b/src/bin/pg_resetxlog/pg_resetxlog.cpp index 1d6e46628..005424237 100644 --- a/src/bin/pg_resetxlog/pg_resetxlog.cpp +++ b/src/bin/pg_resetxlog/pg_resetxlog.cpp @@ -66,7 +66,7 @@ static XLogSegNo newXlogSegNo; /* XLogSegNo of new XLOG segment */ static bool guessed = false; /* T if we had to guess at any values */ static const char* progname; -static void DssInit(void); +static void DssParaInit(void); static void SetGlobalDssParam(void); static int ReadNonDssControlFile(int *fd, char * buffer); static int ReadDssControlFile(int *fd, char *buffer); @@ -123,7 +123,7 @@ int main(int argc, char* argv[]) {NULL, 0, NULL, 0}}; /* init DSS parameters */ - DssInit(); + DssParaInit(); set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_resetxlog")); @@ -302,16 +302,16 @@ int main(int argc, char* argv[]) exit(1); } - /* set DSS connect parameters */ - if (dss.enable_dss) - SetGlobalDssParam(); - /* register for dssapi */ if (dss_device_init(dss.socketpath, dss.enable_dss) != DSS_SUCCESS) { fprintf(stderr, _("%s: fail to init dss device\n"), progname); exit(1); } + /* set DSS connect parameters */ + if (dss.enable_dss) + SetGlobalDssParam(); + initDataPathStruct(dss.enable_dss); /* @@ -456,7 +456,7 @@ int main(int argc, char* argv[]) return 0; } -static void DssInit(void) +static void DssParaInit(void) { dss.enable_dss = false; dss.socketpath = NULL; @@ -469,6 +469,13 @@ static void SetGlobalDssParam(void) errno_t rc = strcpy_s(g_datadir.dss_data, strlen(dss.vgname) + 1, dss.vgname); securec_check_c(rc, "\0", "\0"); XLogSegmentSize = DSS_XLOG_SEG_SIZE; + /* Check dss connect */ + if (!dss_exist_dir(g_datadir.dss_data)) { + fprintf(stderr, _("Could not connect dssserver, vgname: \"%s\", socketpath: \"%s\", \n" + "please check that whether the dssserver is manually started and retry later.\n"), + dss.vgname, dss.socketpath); + exit(1); + } } /* @@ -585,8 +592,8 @@ static bool ReadControlFile(void) if (!dss.enable_dss && errno == ENOENT) fprintf(stderr, _("If you are sure the data directory path is correct, execute\n" - " touch %s\n" - "and try again.\n"), + " touch %s\n" + "and try again.\n"), T_XLOG_CONTROL_FILE); exit(1); }