Skip to content

Commit 3ad3a6d

Browse files
committed
Merge commit '63be064c9fd10689afee9531f4fa8e3b3b5b382e' into PGPRO11_DEV
2 parents cd6734f + 63be064 commit 3ad3a6d

File tree

8 files changed

+31
-9
lines changed

8 files changed

+31
-9
lines changed

src/backup.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <unistd.h>
2323

2424
#include "utils/thread.h"
25+
#include <time.h>
2526

2627
#define PG_STOP_BACKUP_TIMEOUT 300
2728

@@ -474,6 +475,7 @@ do_backup_instance(void)
474475

475476
pgBackup *prev_backup = NULL;
476477
parray *prev_backup_filelist = NULL;
478+
parray *backup_list = NULL;
477479

478480
pgFile *pg_control = NULL;
479481

@@ -515,7 +517,6 @@ do_backup_instance(void)
515517
current.backup_mode == BACKUP_MODE_DIFF_PTRACK ||
516518
current.backup_mode == BACKUP_MODE_DIFF_DELTA)
517519
{
518-
parray *backup_list;
519520
char prev_backup_filelist_path[MAXPGPATH];
520521

521522
/* get list of backups already taken */
@@ -525,7 +526,6 @@ do_backup_instance(void)
525526
if (prev_backup == NULL)
526527
elog(ERROR, "Valid backup on current timeline is not found. "
527528
"Create new FULL backup before an incremental one.");
528-
parray_free(backup_list);
529529

530530
pgBackupGetPath(prev_backup, prev_backup_filelist_path,
531531
lengthof(prev_backup_filelist_path), DATABASE_FILE_LIST);
@@ -832,6 +832,13 @@ do_backup_instance(void)
832832
current.data_bytes += file->write_size;
833833
}
834834

835+
/* Cleanup */
836+
if (backup_list)
837+
{
838+
parray_walk(backup_list, pgBackupFree);
839+
parray_free(backup_list);
840+
}
841+
835842
parray_walk(backup_files_list, pgFileFree);
836843
parray_free(backup_files_list);
837844
backup_files_list = NULL;

src/parsexlog.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#endif
2323

2424
#include "utils/thread.h"
25+
#include <time.h>
2526

2627
/*
2728
* RmgrNames is an array of resource manager names, to make error messages

src/pg_probackup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <sys/stat.h>
1717

1818
#include "utils/thread.h"
19+
#include <time.h>
1920

2021
const char *PROGRAM_VERSION = "2.0.24";
2122
const char *PROGRAM_URL = "https://github.com/postgrespro/pg_probackup";

src/pg_probackup.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ extern int do_restore_or_validate(time_t target_backup_id,
418418
extern bool satisfy_timeline(const parray *timelines, const pgBackup *backup);
419419
extern bool satisfy_recovery_target(const pgBackup *backup,
420420
const pgRecoveryTarget *rt);
421-
extern parray * readTimeLineHistory_probackup(TimeLineID targetTLI);
422421
extern pgRecoveryTarget *parseRecoveryTargetOptions(
423422
const char *target_time, const char *target_xid,
424423
const char *target_inclusive, TimeLineID target_tli, const char* target_lsn,

src/restore.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static void restore_backup(pgBackup *backup);
3333
static void create_recovery_conf(time_t backup_id,
3434
pgRecoveryTarget *rt,
3535
pgBackup *backup);
36+
static parray *read_timeline_history(TimeLineID targetTLI);
3637
static void *restore_files(void *arg);
3738
static void remove_deleted_files(pgBackup *backup);
3839

@@ -138,7 +139,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
138139

139140
elog(LOG, "target timeline ID = %u", rt->recovery_target_tli);
140141
/* Read timeline history files from archives */
141-
timelines = readTimeLineHistory_probackup(rt->recovery_target_tli);
142+
timelines = read_timeline_history(rt->recovery_target_tli);
142143

143144
if (!satisfy_timeline(timelines, current_backup))
144145
{
@@ -149,6 +150,9 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
149150
/* Try to find another backup that satisfies target timeline */
150151
continue;
151152
}
153+
154+
parray_walk(timelines, pfree);
155+
parray_free(timelines);
152156
}
153157

154158
if (!satisfy_recovery_target(current_backup, rt))
@@ -731,7 +735,7 @@ create_recovery_conf(time_t backup_id,
731735
* based on readTimeLineHistory() in timeline.c
732736
*/
733737
parray *
734-
readTimeLineHistory_probackup(TimeLineID targetTLI)
738+
read_timeline_history(TimeLineID targetTLI)
735739
{
736740
parray *result;
737741
char path[MAXPGPATH];
@@ -820,8 +824,7 @@ readTimeLineHistory_probackup(TimeLineID targetTLI)
820824
entry = pgut_new(TimeLineHistoryEntry);
821825
entry->tli = targetTLI;
822826
/* LSN in target timeline is valid */
823-
/* TODO ensure that -1UL --> -1L fix is correct */
824-
entry->end = (uint32) (-1L << 32) | -1L;
827+
entry->end = InvalidXLogRecPtr;
825828
parray_insert(result, 0, entry);
826829

827830
return result;
@@ -853,7 +856,8 @@ satisfy_timeline(const parray *timelines, const pgBackup *backup)
853856

854857
timeline = (TimeLineHistoryEntry *) parray_get(timelines, i);
855858
if (backup->tli == timeline->tli &&
856-
backup->stop_lsn < timeline->end)
859+
(XLogRecPtrIsInvalid(timeline->end) ||
860+
backup->stop_lsn < timeline->end))
857861
return true;
858862
}
859863
return false;

src/utils/logger.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "logger.h"
1515
#include "pgut.h"
1616
#include "thread.h"
17+
#include <time.h>
1718

1819
/* Logger parameters */
1920

src/utils/thread.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
#include "thread.h"
1111

12+
#ifdef WIN32
13+
DWORD main_tid = 0;
14+
#else
1215
pthread_t main_tid = 0;
13-
16+
#endif
1417
#ifdef WIN32
1518
#include <errno.h>
1619

src/utils/thread.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ extern int pthread_join(pthread_t th, void **thread_return);
2828
#include <pthread.h>
2929
#endif
3030

31+
#ifdef WIN32
32+
extern DWORD main_tid;
33+
#else
3134
extern pthread_t main_tid;
35+
#endif
36+
37+
3238

3339
extern int pthread_lock(pthread_mutex_t *mp);
3440

0 commit comments

Comments
 (0)