mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-03-29 22:55:18 +02:00
Merge branch 'master' into stable. Fixes for portability v2.0.24
This commit is contained in:
commit
63be064c9f
11
src/backup.c
11
src/backup.c
@ -22,6 +22,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "utils/thread.h"
|
#include "utils/thread.h"
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#define PG_STOP_BACKUP_TIMEOUT 300
|
#define PG_STOP_BACKUP_TIMEOUT 300
|
||||||
|
|
||||||
@ -474,6 +475,7 @@ do_backup_instance(void)
|
|||||||
|
|
||||||
pgBackup *prev_backup = NULL;
|
pgBackup *prev_backup = NULL;
|
||||||
parray *prev_backup_filelist = NULL;
|
parray *prev_backup_filelist = NULL;
|
||||||
|
parray *backup_list = NULL;
|
||||||
|
|
||||||
pgFile *pg_control = NULL;
|
pgFile *pg_control = NULL;
|
||||||
|
|
||||||
@ -515,7 +517,6 @@ do_backup_instance(void)
|
|||||||
current.backup_mode == BACKUP_MODE_DIFF_PTRACK ||
|
current.backup_mode == BACKUP_MODE_DIFF_PTRACK ||
|
||||||
current.backup_mode == BACKUP_MODE_DIFF_DELTA)
|
current.backup_mode == BACKUP_MODE_DIFF_DELTA)
|
||||||
{
|
{
|
||||||
parray *backup_list;
|
|
||||||
char prev_backup_filelist_path[MAXPGPATH];
|
char prev_backup_filelist_path[MAXPGPATH];
|
||||||
|
|
||||||
/* get list of backups already taken */
|
/* get list of backups already taken */
|
||||||
@ -525,7 +526,6 @@ do_backup_instance(void)
|
|||||||
if (prev_backup == NULL)
|
if (prev_backup == NULL)
|
||||||
elog(ERROR, "Valid backup on current timeline is not found. "
|
elog(ERROR, "Valid backup on current timeline is not found. "
|
||||||
"Create new FULL backup before an incremental one.");
|
"Create new FULL backup before an incremental one.");
|
||||||
parray_free(backup_list);
|
|
||||||
|
|
||||||
pgBackupGetPath(prev_backup, prev_backup_filelist_path,
|
pgBackupGetPath(prev_backup, prev_backup_filelist_path,
|
||||||
lengthof(prev_backup_filelist_path), DATABASE_FILE_LIST);
|
lengthof(prev_backup_filelist_path), DATABASE_FILE_LIST);
|
||||||
@ -832,6 +832,13 @@ do_backup_instance(void)
|
|||||||
current.data_bytes += file->write_size;
|
current.data_bytes += file->write_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Cleanup */
|
||||||
|
if (backup_list)
|
||||||
|
{
|
||||||
|
parray_walk(backup_list, pgBackupFree);
|
||||||
|
parray_free(backup_list);
|
||||||
|
}
|
||||||
|
|
||||||
parray_walk(backup_files_list, pgFileFree);
|
parray_walk(backup_files_list, pgFileFree);
|
||||||
parray_free(backup_files_list);
|
parray_free(backup_files_list);
|
||||||
backup_files_list = NULL;
|
backup_files_list = NULL;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "utils/thread.h"
|
#include "utils/thread.h"
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RmgrNames is an array of resource manager names, to make error messages
|
* RmgrNames is an array of resource manager names, to make error messages
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "utils/thread.h"
|
#include "utils/thread.h"
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
const char *PROGRAM_VERSION = "2.0.24";
|
const char *PROGRAM_VERSION = "2.0.24";
|
||||||
const char *PROGRAM_URL = "https://github.com/postgrespro/pg_probackup";
|
const char *PROGRAM_URL = "https://github.com/postgrespro/pg_probackup";
|
||||||
|
@ -418,7 +418,6 @@ extern int do_restore_or_validate(time_t target_backup_id,
|
|||||||
extern bool satisfy_timeline(const parray *timelines, const pgBackup *backup);
|
extern bool satisfy_timeline(const parray *timelines, const pgBackup *backup);
|
||||||
extern bool satisfy_recovery_target(const pgBackup *backup,
|
extern bool satisfy_recovery_target(const pgBackup *backup,
|
||||||
const pgRecoveryTarget *rt);
|
const pgRecoveryTarget *rt);
|
||||||
extern parray * readTimeLineHistory_probackup(TimeLineID targetTLI);
|
|
||||||
extern pgRecoveryTarget *parseRecoveryTargetOptions(
|
extern pgRecoveryTarget *parseRecoveryTargetOptions(
|
||||||
const char *target_time, const char *target_xid,
|
const char *target_time, const char *target_xid,
|
||||||
const char *target_inclusive, TimeLineID target_tli, const char* target_lsn,
|
const char *target_inclusive, TimeLineID target_tli, const char* target_lsn,
|
||||||
|
@ -33,6 +33,7 @@ static void restore_backup(pgBackup *backup);
|
|||||||
static void create_recovery_conf(time_t backup_id,
|
static void create_recovery_conf(time_t backup_id,
|
||||||
pgRecoveryTarget *rt,
|
pgRecoveryTarget *rt,
|
||||||
pgBackup *backup);
|
pgBackup *backup);
|
||||||
|
static parray *read_timeline_history(TimeLineID targetTLI);
|
||||||
static void *restore_files(void *arg);
|
static void *restore_files(void *arg);
|
||||||
static void remove_deleted_files(pgBackup *backup);
|
static void remove_deleted_files(pgBackup *backup);
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
|
|||||||
|
|
||||||
elog(LOG, "target timeline ID = %u", rt->recovery_target_tli);
|
elog(LOG, "target timeline ID = %u", rt->recovery_target_tli);
|
||||||
/* Read timeline history files from archives */
|
/* Read timeline history files from archives */
|
||||||
timelines = readTimeLineHistory_probackup(rt->recovery_target_tli);
|
timelines = read_timeline_history(rt->recovery_target_tli);
|
||||||
|
|
||||||
if (!satisfy_timeline(timelines, current_backup))
|
if (!satisfy_timeline(timelines, current_backup))
|
||||||
{
|
{
|
||||||
@ -149,6 +150,9 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
|
|||||||
/* Try to find another backup that satisfies target timeline */
|
/* Try to find another backup that satisfies target timeline */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parray_walk(timelines, pfree);
|
||||||
|
parray_free(timelines);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!satisfy_recovery_target(current_backup, rt))
|
if (!satisfy_recovery_target(current_backup, rt))
|
||||||
@ -731,7 +735,7 @@ create_recovery_conf(time_t backup_id,
|
|||||||
* based on readTimeLineHistory() in timeline.c
|
* based on readTimeLineHistory() in timeline.c
|
||||||
*/
|
*/
|
||||||
parray *
|
parray *
|
||||||
readTimeLineHistory_probackup(TimeLineID targetTLI)
|
read_timeline_history(TimeLineID targetTLI)
|
||||||
{
|
{
|
||||||
parray *result;
|
parray *result;
|
||||||
char path[MAXPGPATH];
|
char path[MAXPGPATH];
|
||||||
@ -820,8 +824,7 @@ readTimeLineHistory_probackup(TimeLineID targetTLI)
|
|||||||
entry = pgut_new(TimeLineHistoryEntry);
|
entry = pgut_new(TimeLineHistoryEntry);
|
||||||
entry->tli = targetTLI;
|
entry->tli = targetTLI;
|
||||||
/* LSN in target timeline is valid */
|
/* LSN in target timeline is valid */
|
||||||
/* TODO ensure that -1UL --> -1L fix is correct */
|
entry->end = InvalidXLogRecPtr;
|
||||||
entry->end = (uint32) (-1L << 32) | -1L;
|
|
||||||
parray_insert(result, 0, entry);
|
parray_insert(result, 0, entry);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -853,7 +856,8 @@ satisfy_timeline(const parray *timelines, const pgBackup *backup)
|
|||||||
|
|
||||||
timeline = (TimeLineHistoryEntry *) parray_get(timelines, i);
|
timeline = (TimeLineHistoryEntry *) parray_get(timelines, i);
|
||||||
if (backup->tli == timeline->tli &&
|
if (backup->tli == timeline->tli &&
|
||||||
backup->stop_lsn < timeline->end)
|
(XLogRecPtrIsInvalid(timeline->end) ||
|
||||||
|
backup->stop_lsn < timeline->end))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "pgut.h"
|
#include "pgut.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
/* Logger parameters */
|
/* Logger parameters */
|
||||||
|
|
||||||
|
@ -9,8 +9,11 @@
|
|||||||
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
DWORD main_tid = 0;
|
||||||
|
#else
|
||||||
pthread_t main_tid = 0;
|
pthread_t main_tid = 0;
|
||||||
|
#endif
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
@ -28,7 +28,13 @@ extern int pthread_join(pthread_t th, void **thread_return);
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
extern DWORD main_tid;
|
||||||
|
#else
|
||||||
extern pthread_t main_tid;
|
extern pthread_t main_tid;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern int pthread_lock(pthread_mutex_t *mp);
|
extern int pthread_lock(pthread_mutex_t *mp);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user