!305 Avoid using new connection for fetch MOT ckpt during backup
Merge pull request !305 from Vinoth Veeraraghavan/master
This commit is contained in:
@ -1133,6 +1133,8 @@ static void BaseBackup(void)
|
||||
/* Error message already written in GetConnection() */
|
||||
exit(1);
|
||||
|
||||
ClearAndFreePasswd();
|
||||
|
||||
/*
|
||||
* Run IDENTIFY_SYSTEM so we can get the timeline
|
||||
*/
|
||||
@ -1430,18 +1432,28 @@ static void BaseBackup(void)
|
||||
* End of copy data. Final result is already checked inside the loop.
|
||||
*/
|
||||
PQclear(res);
|
||||
PQfinish(conn);
|
||||
|
||||
res = PQgetResult(conn);
|
||||
if (res != NULL) {
|
||||
/*
|
||||
* We expect the result to be NULL, otherwise we received some unexpected result.
|
||||
* We just expect a 'Z' message and PQgetResult should set conn->asyncStatus to PGASYNC_IDLE,
|
||||
* otherwise we have problem! Report error and disconnect.
|
||||
*/
|
||||
fprintf(stderr,
|
||||
_("%s: unexpected result received after final result, status: %u\n"),
|
||||
progname,
|
||||
PQresultStatus(res));
|
||||
free(sysidentifier);
|
||||
disconnect_and_exit(1);
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "%s: fetch mot checkpoint\n", progname);
|
||||
fprintf(stderr, "%s: fetching MOT checkpoint\n", progname);
|
||||
}
|
||||
conn = GetConnection();
|
||||
if (conn == NULL) {
|
||||
/* Error message already written in GetConnection() */
|
||||
exit(1);
|
||||
}
|
||||
ClearAndFreePasswd();
|
||||
|
||||
FetchMotCheckpoint(basedir, conn, progname, (bool)verbose, format, compresslevel);
|
||||
|
||||
PQfinish(conn);
|
||||
conn = NULL;
|
||||
|
||||
|
@ -1013,7 +1013,7 @@ static void BaseBackup(const char* dirname, uint32 term)
|
||||
int nRet = 0;
|
||||
struct stat st;
|
||||
char pgconfPath[1024] = {0};
|
||||
char* motIniPath = NULL;
|
||||
char* motConfPath = NULL;
|
||||
char* motChkptDir = NULL;
|
||||
|
||||
pqsignal(SIGCHLD, BuildReaper); /* handle child termination */
|
||||
@ -1384,27 +1384,42 @@ static void BaseBackup(const char* dirname, uint32 term)
|
||||
|
||||
TABLESPACE_LIST_RELEASE();
|
||||
|
||||
show_full_build_process("fetching MOT checkpoint");
|
||||
/* see if we have an mot ini file configured */
|
||||
nRet = sprintf_s(pgconfPath, sizeof(pgconfPath), "%s/%s", dirname, "postgresql.conf");
|
||||
securec_check_ss_c(nRet, "\0", "\0");
|
||||
motIniPath = GetOptionValueFromFile(pgconfPath, "mot_config_file");
|
||||
if (motIniPath != NULL) {
|
||||
/* parse checkpoint_dir if exists */
|
||||
motChkptDir = GetOptionValueFromFile(motIniPath, "checkpoint_dir");
|
||||
}
|
||||
|
||||
PQreset(streamConn);
|
||||
FetchMotCheckpoint(motChkptDir ? (const char*)motChkptDir : dirname, streamConn, progname, (bool)verbose);
|
||||
if (motChkptDir)
|
||||
free(motChkptDir);
|
||||
if (motIniPath)
|
||||
free(motIniPath);
|
||||
|
||||
/*
|
||||
* End of copy data. Final result is already checked inside the loop.
|
||||
*/
|
||||
PQclear(res);
|
||||
|
||||
res = PQgetResult(streamConn);
|
||||
if (res != NULL) {
|
||||
/*
|
||||
* We expect the result to be NULL, otherwise we received some unexpected result.
|
||||
* We just expect a 'Z' message and PQgetResult should set conn->asyncStatus to PGASYNC_IDLE,
|
||||
* otherwise we have problem! Report error and disconnect.
|
||||
*/
|
||||
pg_log(PG_WARNING, _("unexpected result received after final result, status: %u\n"), PQresultStatus(res));
|
||||
disconnect_and_exit(1);
|
||||
}
|
||||
|
||||
show_full_build_process("fetching MOT checkpoint");
|
||||
|
||||
/* see if we have an mot conf file configured */
|
||||
nRet = sprintf_s(pgconfPath, sizeof(pgconfPath), "%s/%s", dirname, "postgresql.conf");
|
||||
securec_check_ss_c(nRet, "\0", "\0");
|
||||
motConfPath = GetOptionValueFromFile(pgconfPath, "mot_config_file");
|
||||
if (motConfPath != NULL) {
|
||||
/* parse checkpoint_dir if exists */
|
||||
motChkptDir = GetOptionValueFromFile(motConfPath, "checkpoint_dir");
|
||||
}
|
||||
|
||||
FetchMotCheckpoint(motChkptDir ? (const char*)motChkptDir : dirname, streamConn, progname, (bool)verbose);
|
||||
|
||||
if (motChkptDir) {
|
||||
free(motChkptDir);
|
||||
}
|
||||
if (motConfPath) {
|
||||
free(motConfPath);
|
||||
}
|
||||
|
||||
PQfinish(streamConn);
|
||||
streamConn = NULL;
|
||||
|
||||
@ -1417,6 +1432,7 @@ static void BaseBackup(const char* dirname, uint32 term)
|
||||
|
||||
show_full_build_process("rename build status file success");
|
||||
}
|
||||
|
||||
/*
|
||||
* @@GaussDB@@
|
||||
* Brief : the entry of full build
|
||||
|
@ -3839,7 +3839,7 @@ static void do_incremental_build(uint32 term)
|
||||
set_build_pid(getpid());
|
||||
char connstrSource[1024];
|
||||
char pgconfPath[1024] = {0};
|
||||
char* motIniPath = NULL;
|
||||
char* motConfPath = NULL;
|
||||
char* motChkptDir = NULL;
|
||||
|
||||
/* 1. load repl_conninfo into conninfo_global.
|
||||
@ -3868,8 +3868,9 @@ static void do_incremental_build(uint32 term)
|
||||
/* deallocate the connections, we used it in step 4. */
|
||||
progname = "gs_rewind";
|
||||
status = gs_increment_build(pg_data, connstrSource, term);
|
||||
/* try and fetch the mot checkpoint */
|
||||
|
||||
if (status == BUILD_SUCCESS) {
|
||||
/* try and fetch the mot checkpoint */
|
||||
if (streamConn == NULL) {
|
||||
streamConn = check_and_conn(standby_connect_timeout, standby_recv_timeout, term);
|
||||
if (streamConn == NULL) {
|
||||
@ -3877,22 +3878,28 @@ static void do_incremental_build(uint32 term)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
pg_log(PG_PROGRESS, "fetch MOT checkpoint\n");
|
||||
|
||||
pg_log(PG_PROGRESS, "fetching MOT checkpoint\n");
|
||||
|
||||
/* see if we have an mot conf file configured */
|
||||
tnRet = sprintf_s(pgconfPath, sizeof(pgconfPath), "%s/%s", pg_data, "postgresql.conf");
|
||||
securec_check_ss_c(tnRet, "\0", "\0");
|
||||
motIniPath = GetOptionValueFromFile(pgconfPath, "mot_config_file");
|
||||
if (motIniPath != NULL) {
|
||||
motConfPath = GetOptionValueFromFile(pgconfPath, "mot_config_file");
|
||||
if (motConfPath != NULL) {
|
||||
/* parse checkpoint_dir if exists */
|
||||
motChkptDir = GetOptionValueFromFile(motIniPath, "checkpoint_dir");
|
||||
motChkptDir = GetOptionValueFromFile(motConfPath, "checkpoint_dir");
|
||||
}
|
||||
|
||||
FetchMotCheckpoint(motChkptDir ? (const char*)motChkptDir : (const char*)pg_data, streamConn, progname, true);
|
||||
if (motChkptDir)
|
||||
|
||||
if (motChkptDir) {
|
||||
free(motChkptDir);
|
||||
if (motIniPath)
|
||||
free(motIniPath);
|
||||
}
|
||||
if (motConfPath) {
|
||||
free(motConfPath);
|
||||
}
|
||||
}
|
||||
|
||||
progname = "gs_ctl";
|
||||
if (streamConn != NULL) {
|
||||
PQfinish(streamConn);
|
||||
|
@ -143,7 +143,7 @@ int CheckpointWorkerPool::Checkpoint(Buffer* buffer, Sentinel* sentinel, int fd,
|
||||
stableRow = sentinel->GetStable();
|
||||
if (mainRow->IsRowDeleted()) {
|
||||
if (stableRow) {
|
||||
// Truely deleted and was not removed by txn manager
|
||||
// Truly deleted and was not removed by txn manager
|
||||
isDeleted = true;
|
||||
} else {
|
||||
MOT_LOG_DEBUG("Detected Deleted row without Stable Row!");
|
||||
|
@ -114,7 +114,7 @@ private:
|
||||
* @param sentinel The sentinel that holds to row.
|
||||
* @param fd The file descriptor to write to.
|
||||
* @param tid The thread id.
|
||||
* @param isDeleted The row delete status
|
||||
* @param isDeleted The row delete status.
|
||||
* @return Int equal to -1 on error, 0 if nothing was written and 1 if the row was written.
|
||||
*/
|
||||
int Checkpoint(Buffer* buffer, Sentinel* sentinel, int fd, int tid, bool& isDeleted);
|
||||
|
@ -641,14 +641,14 @@ static const Table_Entry txnStateMachine[TSM_SIZE][TSM_SIZE] = {
|
||||
{DEL, NS_ACTIONS::NOCHANGE},
|
||||
{DEL, NS_ACTIONS::NS_ERROR},
|
||||
{DEL, NS_ACTIONS::NS_ERROR},
|
||||
{INS, NS_ACTIONS::NOCHANGE}}, // DEL states
|
||||
{INS, NS_ACTIONS::NOCHANGE}},
|
||||
/* INSERT STATE */
|
||||
{{INS, NS_ACTIONS::NS_ERROR},
|
||||
{INS, NS_ACTIONS::NOCHANGE},
|
||||
{INS, NS_ACTIONS::NOCHANGE},
|
||||
{INS, NS_ACTIONS::NOCHANGE},
|
||||
{DEL, NS_ACTIONS::FILTER_DELETES},
|
||||
{INS, NS_ACTIONS::NS_ERROR}}, // INS states
|
||||
{INS, NS_ACTIONS::NS_ERROR}},
|
||||
};
|
||||
|
||||
// Currently supporting RD/WR transitions
|
||||
|
Reference in New Issue
Block a user