1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-12-04 10:44:46 +02:00

Merge branch 'master' into stable. Fixes for portability v2.0.24

This commit is contained in:
Anastasia 2018-11-13 13:28:44 +03:00
commit 63be064c9f
8 changed files with 31 additions and 9 deletions

View File

@ -22,6 +22,7 @@
#include <unistd.h>
#include "utils/thread.h"
#include <time.h>
#define PG_STOP_BACKUP_TIMEOUT 300
@ -474,6 +475,7 @@ do_backup_instance(void)
pgBackup *prev_backup = NULL;
parray *prev_backup_filelist = NULL;
parray *backup_list = 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_DELTA)
{
parray *backup_list;
char prev_backup_filelist_path[MAXPGPATH];
/* get list of backups already taken */
@ -525,7 +526,6 @@ do_backup_instance(void)
if (prev_backup == NULL)
elog(ERROR, "Valid backup on current timeline is not found. "
"Create new FULL backup before an incremental one.");
parray_free(backup_list);
pgBackupGetPath(prev_backup, prev_backup_filelist_path,
lengthof(prev_backup_filelist_path), DATABASE_FILE_LIST);
@ -832,6 +832,13 @@ do_backup_instance(void)
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_free(backup_files_list);
backup_files_list = NULL;

View File

@ -22,6 +22,7 @@
#endif
#include "utils/thread.h"
#include <time.h>
/*
* RmgrNames is an array of resource manager names, to make error messages

View File

@ -16,6 +16,7 @@
#include <sys/stat.h>
#include "utils/thread.h"
#include <time.h>
const char *PROGRAM_VERSION = "2.0.24";
const char *PROGRAM_URL = "https://github.com/postgrespro/pg_probackup";

View File

@ -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_recovery_target(const pgBackup *backup,
const pgRecoveryTarget *rt);
extern parray * readTimeLineHistory_probackup(TimeLineID targetTLI);
extern pgRecoveryTarget *parseRecoveryTargetOptions(
const char *target_time, const char *target_xid,
const char *target_inclusive, TimeLineID target_tli, const char* target_lsn,

View File

@ -33,6 +33,7 @@ static void restore_backup(pgBackup *backup);
static void create_recovery_conf(time_t backup_id,
pgRecoveryTarget *rt,
pgBackup *backup);
static parray *read_timeline_history(TimeLineID targetTLI);
static void *restore_files(void *arg);
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);
/* 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))
{
@ -149,6 +150,9 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
/* Try to find another backup that satisfies target timeline */
continue;
}
parray_walk(timelines, pfree);
parray_free(timelines);
}
if (!satisfy_recovery_target(current_backup, rt))
@ -731,7 +735,7 @@ create_recovery_conf(time_t backup_id,
* based on readTimeLineHistory() in timeline.c
*/
parray *
readTimeLineHistory_probackup(TimeLineID targetTLI)
read_timeline_history(TimeLineID targetTLI)
{
parray *result;
char path[MAXPGPATH];
@ -820,8 +824,7 @@ readTimeLineHistory_probackup(TimeLineID targetTLI)
entry = pgut_new(TimeLineHistoryEntry);
entry->tli = targetTLI;
/* LSN in target timeline is valid */
/* TODO ensure that -1UL --> -1L fix is correct */
entry->end = (uint32) (-1L << 32) | -1L;
entry->end = InvalidXLogRecPtr;
parray_insert(result, 0, entry);
return result;
@ -853,7 +856,8 @@ satisfy_timeline(const parray *timelines, const pgBackup *backup)
timeline = (TimeLineHistoryEntry *) parray_get(timelines, i);
if (backup->tli == timeline->tli &&
backup->stop_lsn < timeline->end)
(XLogRecPtrIsInvalid(timeline->end) ||
backup->stop_lsn < timeline->end))
return true;
}
return false;

View File

@ -14,6 +14,7 @@
#include "logger.h"
#include "pgut.h"
#include "thread.h"
#include <time.h>
/* Logger parameters */

View File

@ -9,8 +9,11 @@
#include "thread.h"
#ifdef WIN32
DWORD main_tid = 0;
#else
pthread_t main_tid = 0;
#endif
#ifdef WIN32
#include <errno.h>

View File

@ -28,7 +28,13 @@ extern int pthread_join(pthread_t th, void **thread_return);
#include <pthread.h>
#endif
#ifdef WIN32
extern DWORD main_tid;
#else
extern pthread_t main_tid;
#endif
extern int pthread_lock(pthread_mutex_t *mp);