Skip to content

Fix build warnings #652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,12 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
/* copy pg_control at very end */
if (backup_isok)
{
char from_fullpath[MAXPGPATH];
char to_fullpath[MAXPGPATH];

elog(progress ? INFO : LOG, "Progress: Backup file \"%s\"",
src_pg_control_file->rel_path);

char from_fullpath[MAXPGPATH];
char to_fullpath[MAXPGPATH];
join_path_components(from_fullpath, instance_config.pgdata, src_pg_control_file->rel_path);
join_path_components(to_fullpath, current.database_dir, src_pg_control_file->rel_path);

Expand Down
102 changes: 51 additions & 51 deletions src/catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1755,27 +1755,27 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)

for (i = 0; i < parray_num(timelineinfos); i++)
{
timelineInfo *tlinfo = parray_get(timelineinfos, i);
timelineInfo *tlInfo = parray_get(timelineinfos, i);
for (j = 0; j < parray_num(backups); j++)
{
pgBackup *backup = parray_get(backups, j);
if (tlinfo->tli == backup->tli)
if (tlInfo->tli == backup->tli)
{
if (tlinfo->backups == NULL)
tlinfo->backups = parray_new();
if (tlInfo->backups == NULL)
tlInfo->backups = parray_new();

parray_append(tlinfo->backups, backup);
parray_append(tlInfo->backups, backup);
}
}
}

/* determine oldest backup and closest backup for every timeline */
for (i = 0; i < parray_num(timelineinfos); i++)
{
timelineInfo *tlinfo = parray_get(timelineinfos, i);
timelineInfo *tlInfo = parray_get(timelineinfos, i);

tlinfo->oldest_backup = get_oldest_backup(tlinfo);
tlinfo->closest_backup = get_closest_backup(tlinfo);
tlInfo->oldest_backup = get_oldest_backup(tlInfo);
tlInfo->closest_backup = get_closest_backup(tlInfo);
}

/* determine which WAL segments must be kept because of wal retention */
Expand Down Expand Up @@ -1845,18 +1845,18 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
for (i = 0; i < parray_num(timelineinfos); i++)
{
int count = 0;
timelineInfo *tlinfo = parray_get(timelineinfos, i);
timelineInfo *tlInfo = parray_get(timelineinfos, i);

/*
* Iterate backward on backups belonging to this timeline to find
* anchor_backup. NOTE Here we rely on the fact that backups list
* is ordered by start_lsn DESC.
*/
if (tlinfo->backups)
if (tlInfo->backups)
{
for (j = 0; j < parray_num(tlinfo->backups); j++)
for (j = 0; j < parray_num(tlInfo->backups); j++)
{
pgBackup *backup = parray_get(tlinfo->backups, j);
pgBackup *backup = parray_get(tlInfo->backups, j);

/* sanity */
if (XLogRecPtrIsInvalid(backup->start_lsn) ||
Expand Down Expand Up @@ -1886,12 +1886,12 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
if (count == instance->wal_depth)
{
elog(LOG, "On timeline %i WAL is protected from purge at %X/%X",
tlinfo->tli,
tlInfo->tli,
(uint32) (backup->start_lsn >> 32),
(uint32) (backup->start_lsn));

tlinfo->anchor_lsn = backup->start_lsn;
tlinfo->anchor_tli = backup->tli;
tlInfo->anchor_lsn = backup->start_lsn;
tlInfo->anchor_tli = backup->tli;
break;
}
}
Expand All @@ -1916,7 +1916,7 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
* If closest_backup is not available, then general WAL purge rules
* are applied.
*/
if (XLogRecPtrIsInvalid(tlinfo->anchor_lsn))
if (XLogRecPtrIsInvalid(tlInfo->anchor_lsn))
{
/*
* Failed to find anchor_lsn in our own timeline.
Expand All @@ -1942,7 +1942,7 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
xlogInterval *interval = NULL;
TimeLineID tli = 0;
/* check if tli has closest_backup */
if (!tlinfo->closest_backup)
if (!tlInfo->closest_backup)
/* timeline has no closest_backup, wal retention cannot be
* applied to this timeline.
* Timeline will be purged up to oldest_backup if any or
Expand All @@ -1952,47 +1952,47 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
continue;

/* sanity for closest_backup */
if (XLogRecPtrIsInvalid(tlinfo->closest_backup->start_lsn) ||
tlinfo->closest_backup->tli <= 0)
if (XLogRecPtrIsInvalid(tlInfo->closest_backup->start_lsn) ||
tlInfo->closest_backup->tli <= 0)
continue;

/*
* Set anchor_lsn and anchor_tli to protect whole timeline from purge
* In the example above: tli3.
*/
tlinfo->anchor_lsn = tlinfo->closest_backup->start_lsn;
tlinfo->anchor_tli = tlinfo->closest_backup->tli;
tlInfo->anchor_lsn = tlInfo->closest_backup->start_lsn;
tlInfo->anchor_tli = tlInfo->closest_backup->tli;

/* closest backup may be located not in parent timeline */
closest_backup = tlinfo->closest_backup;
closest_backup = tlInfo->closest_backup;

tli = tlinfo->tli;
tli = tlInfo->tli;

/*
* Iterate over parent timeline chain and
* look for timeline where closest_backup belong
*/
while (tlinfo->parent_link)
while (tlInfo->parent_link)
{
/* In case of intermediate timeline save to keep_segments
* begin_segno and switchpoint segment.
* In case of final timelines save to keep_segments
* closest_backup start_lsn segment and switchpoint segment.
*/
XLogRecPtr switchpoint = tlinfo->switchpoint;
XLogRecPtr switchpoint = tlInfo->switchpoint;

tlinfo = tlinfo->parent_link;
tlInfo = tlInfo->parent_link;

if (tlinfo->keep_segments == NULL)
tlinfo->keep_segments = parray_new();
if (tlInfo->keep_segments == NULL)
tlInfo->keep_segments = parray_new();

/* in any case, switchpoint segment must be added to interval */
interval = palloc(sizeof(xlogInterval));
GetXLogSegNo(switchpoint, interval->end_segno, instance->xlog_seg_size);

/* Save [S1`, S2] to keep_segments */
if (tlinfo->tli != closest_backup->tli)
interval->begin_segno = tlinfo->begin_segno;
if (tlInfo->tli != closest_backup->tli)
interval->begin_segno = tlInfo->begin_segno;
/* Save [B1, S1] to keep_segments */
else
GetXLogSegNo(closest_backup->start_lsn, interval->begin_segno, instance->xlog_seg_size);
Expand All @@ -2002,27 +2002,27 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
* covered by other larger interval.
*/

GetXLogFileName(begin_segno_str, tlinfo->tli, interval->begin_segno, instance->xlog_seg_size);
GetXLogFileName(end_segno_str, tlinfo->tli, interval->end_segno, instance->xlog_seg_size);
GetXLogFileName(begin_segno_str, tlInfo->tli, interval->begin_segno, instance->xlog_seg_size);
GetXLogFileName(end_segno_str, tlInfo->tli, interval->end_segno, instance->xlog_seg_size);

elog(LOG, "Timeline %i to stay reachable from timeline %i "
"protect from purge WAL interval between "
"%s and %s on timeline %i",
tli, closest_backup->tli, begin_segno_str,
end_segno_str, tlinfo->tli);
end_segno_str, tlInfo->tli);

parray_append(tlinfo->keep_segments, interval);
parray_append(tlInfo->keep_segments, interval);
continue;
}
continue;
}

/* Iterate over backups left */
for (j = count; j < parray_num(tlinfo->backups); j++)
for (j = count; j < parray_num(tlInfo->backups); j++)
{
XLogSegNo segno = 0;
xlogInterval *interval = NULL;
pgBackup *backup = parray_get(tlinfo->backups, j);
pgBackup *backup = parray_get(tlInfo->backups, j);

/*
* We must calculate keep_segments intervals for ARCHIVE backups
Expand All @@ -2039,7 +2039,7 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
continue;

/* no point in clogging keep_segments by backups protected by anchor_lsn */
if (backup->start_lsn >= tlinfo->anchor_lsn)
if (backup->start_lsn >= tlInfo->anchor_lsn)
continue;

/* append interval to keep_segments */
Expand All @@ -2057,19 +2057,19 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
else
interval->end_segno = segno;

GetXLogFileName(begin_segno_str, tlinfo->tli, interval->begin_segno, instance->xlog_seg_size);
GetXLogFileName(end_segno_str, tlinfo->tli, interval->end_segno, instance->xlog_seg_size);
GetXLogFileName(begin_segno_str, tlInfo->tli, interval->begin_segno, instance->xlog_seg_size);
GetXLogFileName(end_segno_str, tlInfo->tli, interval->end_segno, instance->xlog_seg_size);

elog(LOG, "Archive backup %s to stay consistent "
"protect from purge WAL interval "
"between %s and %s on timeline %i",
backup_id_of(backup),
begin_segno_str, end_segno_str, backup->tli);

if (tlinfo->keep_segments == NULL)
tlinfo->keep_segments = parray_new();
if (tlInfo->keep_segments == NULL)
tlInfo->keep_segments = parray_new();

parray_append(tlinfo->keep_segments, interval);
parray_append(tlInfo->keep_segments, interval);
}
}

Expand All @@ -2081,27 +2081,27 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
for (i = 0; i < parray_num(timelineinfos); i++)
{
XLogSegNo anchor_segno = 0;
timelineInfo *tlinfo = parray_get(timelineinfos, i);
timelineInfo *tlInfo = parray_get(timelineinfos, i);

/*
* At this point invalid anchor_lsn can be only in one case:
* timeline is going to be purged by regular WAL purge rules.
*/
if (XLogRecPtrIsInvalid(tlinfo->anchor_lsn))
if (XLogRecPtrIsInvalid(tlInfo->anchor_lsn))
continue;

/*
* anchor_lsn is located in another timeline, it means that the timeline
* will be protected from purge entirely.
*/
if (tlinfo->anchor_tli > 0 && tlinfo->anchor_tli != tlinfo->tli)
if (tlInfo->anchor_tli > 0 && tlInfo->anchor_tli != tlInfo->tli)
continue;

GetXLogSegNo(tlinfo->anchor_lsn, anchor_segno, instance->xlog_seg_size);
GetXLogSegNo(tlInfo->anchor_lsn, anchor_segno, instance->xlog_seg_size);

for (j = 0; j < parray_num(tlinfo->xlog_filelist); j++)
for (j = 0; j < parray_num(tlInfo->xlog_filelist); j++)
{
xlogFile *wal_file = (xlogFile *) parray_get(tlinfo->xlog_filelist, j);
xlogFile *wal_file = (xlogFile *) parray_get(tlInfo->xlog_filelist, j);

if (wal_file->segno >= anchor_segno)
{
Expand All @@ -2110,13 +2110,13 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
}

/* no keep segments */
if (!tlinfo->keep_segments)
if (!tlInfo->keep_segments)
continue;

/* Protect segments belonging to one of the keep invervals */
for (k = 0; k < parray_num(tlinfo->keep_segments); k++)
for (k = 0; k < parray_num(tlInfo->keep_segments); k++)
{
xlogInterval *keep_segments = (xlogInterval *) parray_get(tlinfo->keep_segments, k);
xlogInterval *keep_segments = (xlogInterval *) parray_get(tlInfo->keep_segments, k);

if ((wal_file->segno >= keep_segments->begin_segno) &&
wal_file->segno <= keep_segments->end_segno)
Expand Down
20 changes: 20 additions & 0 deletions src/pg_probackup.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ typedef struct InstanceConfig
extern ConfigOption instance_options[];
extern InstanceConfig instance_config;
extern time_t current_time;
extern bool no_validate;
extern IncrRestoreMode incremental_mode;

typedef struct PGNodeInfo
{
Expand Down Expand Up @@ -805,9 +807,12 @@ extern pid_t my_pid;
extern __thread int my_thread_num;
extern int num_threads;
extern bool stream_wal;
extern bool no_color;
extern bool show_color;
extern bool progress;
extern bool no_sync;
extern bool is_archive_cmd; /* true for archive-{get,push} */
extern time_t start_time;
/* In pre-10 'replication_slot' is defined in receivelog.h */
extern char *replication_slot;
#if PG_VERSION_NUM >= 100000
Expand All @@ -816,6 +821,7 @@ extern bool temp_slot;
extern bool perm_slot;

/* backup options */
extern bool backup_logs;
extern bool smooth_checkpoint;

/* remote probackup options */
Expand All @@ -827,8 +833,15 @@ extern bool exclusive_backup;
extern bool delete_wal;
extern bool delete_expired;
extern bool merge_expired;
extern bool force;
extern bool dry_run;

/* archive push options */
extern int batch_size;

/* archive get options */
extern bool no_validate_wal;

/* ===== instanceState ===== */

typedef struct InstanceState
Expand Down Expand Up @@ -858,11 +871,18 @@ typedef struct InstanceState

/* show options */
extern ShowFormat show_format;
extern bool show_archive;

/* set backup options */
extern int64 ttl;

/* checkdb options */
extern bool need_amcheck;
extern bool heapallindexed;
extern bool checkunique;
extern bool amcheck_parent;
extern bool skip_block_validation;
extern bool skip_external_dirs;

/* current settings */
extern pgBackup current;
Expand Down
10 changes: 5 additions & 5 deletions src/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ parse_tli_history_buffer(char *history, TimeLineID tli)
if (curLineLen > 0)
{
char *ptr;
TimeLineID tli;
TimeLineID currTLI;
uint32 switchpoint_hi;
uint32 switchpoint_lo;
int nfields;
Expand All @@ -605,7 +605,7 @@ parse_tli_history_buffer(char *history, TimeLineID tli)
if (*ptr == '\0' || *ptr == '#')
continue;

nfields = sscanf(tempStr, "%u\t%X/%X", &tli, &switchpoint_hi, &switchpoint_lo);
nfields = sscanf(tempStr, "%u\t%X/%X", &currTLI, &switchpoint_hi, &switchpoint_lo);

if (nfields < 1)
{
Expand All @@ -615,11 +615,11 @@ parse_tli_history_buffer(char *history, TimeLineID tli)
if (nfields != 3)
elog(ERROR, "Syntax error in timeline history: \"%s\". Expected a transaction log switchpoint location.", tempStr);

if (last_timeline && tli <= last_timeline->tli)
if (last_timeline && currTLI <= last_timeline->tli)
elog(ERROR, "Timeline IDs must be in increasing sequence: \"%s\"", tempStr);

entry = pgut_new(TimeLineHistoryEntry);
entry->tli = tli;
entry->tli = currTLI;
entry->end = ((uint64) switchpoint_hi << 32) | switchpoint_lo;

last_timeline = entry;
Expand All @@ -628,7 +628,7 @@ parse_tli_history_buffer(char *history, TimeLineID tli)
result = parray_new();
parray_append(result, entry);
elog(VERBOSE, "parse_tli_history_buffer() found entry: tli = %X, end = %X/%X",
tli, switchpoint_hi, switchpoint_lo);
currTLI, switchpoint_hi, switchpoint_lo);

/* we ignore the remainder of each line */
}
Expand Down
Loading