forked from huawei/openGauss-server
fix probackup core
Offering: openGaussDev More detail: fix probackup core Match-id-8791b0f194f0ddfef801aa77f9edabb0bc589d30
This commit is contained in:
parent
c0e4b1b7b8
commit
704eed3368
|
|
@ -395,6 +395,7 @@ static bool CheckForStandbyTrigger(void);
|
|||
static void xlog_outrec(StringInfo buf, XLogReaderState *record);
|
||||
#endif
|
||||
static void pg_start_backup_callback(int code, Datum arg);
|
||||
static void DoAbortBackupCallback(int code, Datum arg);
|
||||
static void AbortExcluseBackupCallback(int code, Datum arg);
|
||||
static bool read_tablespace_map(List **tablespaces);
|
||||
static bool read_backup_label(XLogRecPtr *checkPointLoc, bool *backupEndRequired, bool *backupFromStandby,
|
||||
|
|
@ -14688,7 +14689,26 @@ void do_pg_abort_backup(void)
|
|||
u_sess->proc_cxt.sessionBackupState = SESSION_BACKUP_NONE;
|
||||
|
||||
StopSuspendWalInsert(lastlrc);
|
||||
u_sess->proc_cxt.sessionBackupState = SESSION_BACKUP_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Error cleanup callback for do_pg_abort_backup
|
||||
*/
|
||||
static void DoAbortBackupCallback(int code, Datum arg)
|
||||
{
|
||||
do_pg_abort_backup();
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a handler that will warn about unterminated backups at the end of
|
||||
* session, unless this has already been done.
|
||||
*/
|
||||
void RegisterPersistentAbortBackupHandler(void)
|
||||
{
|
||||
if (u_sess->proc_cxt.registerAbortBackupHandlerdone)
|
||||
return;
|
||||
on_shmem_exit(DoAbortBackupCallback, BoolGetDatum(true));
|
||||
u_sess->proc_cxt.registerAbortBackupHandlerdone = true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -170,13 +170,7 @@ Datum pg_start_backup_v2(PG_FUNCTION_ARGS)
|
|||
DIR *dir;
|
||||
char startxlogstr[MAXFNAMELEN];
|
||||
errno_t errorno = EOK;
|
||||
MemoryContext oldContext;
|
||||
|
||||
u_sess->probackup_context = AllocSetContextCreate(u_sess->top_mem_cxt, "probackup context",
|
||||
ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE,
|
||||
ALLOCSET_DEFAULT_MAXSIZE);
|
||||
oldContext = MemoryContextSwitchTo(u_sess->probackup_context);
|
||||
|
||||
SessionBackupState status = u_sess->proc_cxt.sessionBackupState;
|
||||
|
||||
if (status == SESSION_BACKUP_NON_EXCLUSIVE)
|
||||
|
|
@ -196,7 +190,15 @@ Datum pg_start_backup_v2(PG_FUNCTION_ARGS)
|
|||
ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("a backup is already in progress in this session")));
|
||||
|
||||
RegisterPersistentAbortBackupHandler();
|
||||
|
||||
startpoint = do_pg_start_backup(backupidstr, fast, &labelfile,dir, &tblspcmapfile, NULL,false,true);
|
||||
|
||||
if (u_sess->probackup_context == NULL) {
|
||||
u_sess->probackup_context = AllocSetContextCreate(u_sess->top_mem_cxt, "probackup context",
|
||||
ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE,
|
||||
ALLOCSET_DEFAULT_MAXSIZE);
|
||||
}
|
||||
u_sess->proc_cxt.LabelFile = MemoryContextStrdup(u_sess->probackup_context, labelfile);
|
||||
if (tblspcmapfile != NULL) {
|
||||
u_sess->proc_cxt.TblspcMapFile = MemoryContextStrdup(u_sess->probackup_context, tblspcmapfile);
|
||||
|
|
@ -210,8 +212,6 @@ Datum pg_start_backup_v2(PG_FUNCTION_ARGS)
|
|||
securec_check_ss(errorno, "", "");
|
||||
|
||||
PG_RETURN_TEXT_P(cstring_to_text(startxlogstr));
|
||||
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -223,7 +223,7 @@ Datum pg_stop_backup_v2(PG_FUNCTION_ARGS)
|
|||
ReturnSetInfo *rsinfo = (ReturnSetInfo *)fcinfo->resultinfo;
|
||||
TupleDesc tupdesc;
|
||||
Tuplestorestate *tupstore;
|
||||
MemoryContext perqueryctx, oldcontext, oldcontext2;
|
||||
MemoryContext perqueryctx, oldcontext;
|
||||
Datum values[3];
|
||||
bool nulls[3];
|
||||
XLogRecPtr stoppoint;
|
||||
|
|
@ -247,8 +247,6 @@ Datum pg_stop_backup_v2(PG_FUNCTION_ARGS)
|
|||
errmsg("non-exclusive backup is not in progress")));
|
||||
}
|
||||
|
||||
oldcontext2 = MemoryContextSwitchTo(u_sess->probackup_context);
|
||||
|
||||
/* check to see if caller supports us returning a tuplestore */
|
||||
if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
|
||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
|
|
@ -305,8 +303,6 @@ Datum pg_stop_backup_v2(PG_FUNCTION_ARGS)
|
|||
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
|
||||
tuplestore_donestoring(tupstore);
|
||||
|
||||
MemoryContextSwitchTo(oldcontext2);
|
||||
|
||||
return (Datum) 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -768,6 +768,7 @@ extern XLogRecPtr GetDDLDelayStartPtr(void);
|
|||
extern XLogRecPtr do_pg_stop_backup(char *labelfile, bool waitforarchive, unsigned long long* consensusPaxosIdx = NULL);
|
||||
extern XLogRecPtr StandbyDoStopBackup(char *labelfile);
|
||||
extern void do_pg_abort_backup(void);
|
||||
extern void RegisterPersistentAbortBackupHandler(void);
|
||||
extern void RegisterAbortExclusiveBackup();
|
||||
extern void enable_delay_xlog_recycle(bool isRedo = false);
|
||||
extern void disable_delay_xlog_recycle(bool isRedo = false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue