Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcca2631

Browse files
committed
Merge remote-tracking branch 'origin/master' into issue_188
2 parents09a78d2 +5699b13 commitcca2631

26 files changed

+398
-469
lines changed

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[![Build Status](https://travis-ci.com/postgrespro/pg_probackup.svg?branch=master)](https://travis-ci.com/postgrespro/pg_probackup)
2+
[![GitHub release](https://img.shields.io/github/v/release/postgrespro/pg_probackup?include_prereleases)](https://github.com/postgrespro/pg_probackup/releases/latest)
23

34
#pg_probackup
45

@@ -53,15 +54,15 @@ Regardless of the chosen backup type, all backups taken with `pg_probackup` supp
5354

5455
##Current release
5556

56-
[2.3.2](https://github.com/postgrespro/pg_probackup/releases/tag/2.3.2)
57+
[2.3.4](https://github.com/postgrespro/pg_probackup/releases/tag/2.3.4)
5758

5859
##Documentation
5960

6061
Documentation can be found at[github](https://postgrespro.github.io/pg_probackup) and[Postgres Professional documentation](https://postgrespro.com/docs/postgrespro/current/app-pgprobackup)
6162

6263
##Installation and Setup
6364
###Windows Installation
64-
Installers are available in release**assets**.[Latests](https://github.com/postgrespro/pg_probackup/releases/2.3.1).
65+
Installers are available in release**assets**.[Latests](https://github.com/postgrespro/pg_probackup/releases/2.3.3).
6566

6667
###Linux Installation
6768
####pg_probackup for vanilla PostgreSQL

‎doc/pgprobackup.xml‎

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,16 @@ ALTER ROLE backup WITH REPLICATION;
740740
DELTA, and PTRACK backups in the
741741
<linklinkend="pbk-stream-mode">STREAM</link> WAL mode.
742742
</para>
743+
<note>
744+
<para>
745+
If you are planning to rely on
746+
<ulinkurl="https://postgrespro.com/docs/postgresql/current/libpq-pgpass.html">.pgpass</ulink>
747+
for authentication when running backup in STREAM mode,
748+
then .pgpass must contain credentials for <literal>replication</literal> database,
749+
used to establish connection via replication protocol. Example:
750+
pghost:5432:replication:backup_user:my_strong_password
751+
</para>
752+
</note>
743753
</refsect2>
744754
<refsect2id="pbk-setting-up-continuous-wal-archiving">
745755
<title>Setting up Continuous WAL Archiving</title>
@@ -1158,20 +1168,20 @@ CREATE EXTENSION ptrack;
11581168
</listitem>
11591169
<listitem>
11601170
<para>
1161-
To enable tracking page updates, set <varname>ptrack_map_size</varname>
1171+
To enable tracking page updates, set <varname>ptrack.map_size</varname>
11621172
parameter to a positive integer and restart the server.
11631173
</para>
11641174
<para>
11651175
For optimal performance, it is recommended to set
1166-
<varname>ptrack_map_size</varname> to
1176+
<varname>ptrack.map_size</varname> to
11671177
<literal><replaceable>N</replaceable> / 1024</literal>, where
11681178
<replaceable>N</replaceable> is the size of the
11691179
<productname>PostgreSQL</productname> cluster, in MB. If you set this
11701180
parameter to a lower value, PTRACK is more likely to map several blocks
11711181
together, which leads to false-positive results when tracking changed
11721182
blocks and increases the incremental backup size as unchanged blocks
11731183
can also be copied into the incremental backup.
1174-
Setting <varname>ptrack_map_size</varname> to a higher value
1184+
Setting <varname>ptrack.map_size</varname> to a higher value
11751185
does not affect PTRACK operation. The maximum allowed value is 1024.
11761186
</para>
11771187
</listitem>
@@ -1191,11 +1201,11 @@ GRANT EXECUTE ON FUNCTION pg_ptrack_get_block(oid, oid, oid, bigint) TO backup;
11911201

11921202
<note>
11931203
<para>
1194-
If you change the <varname>ptrack_map_size</varname> parameter value,
1204+
If you change the <varname>ptrack.map_size</varname> parameter value,
11951205
the previously created PTRACK map file is cleared,
11961206
and tracking newly changed blocks starts from scratch. Thus, you have
11971207
to retake a full backup before taking incremental PTRACK backups after
1198-
changing <varname>ptrack_map_size</varname>.
1208+
changing <varname>ptrack.map_size</varname>.
11991209
</para>
12001210
</note>
12011211

@@ -4045,10 +4055,10 @@ pg_probackup archive-push -B <replaceable>backup_dir</replaceable> --instance <r
40454055
corruption.
40464056
</para>
40474057
<para>
4048-
To speed up archiving, you can specify the <option>-j</option> option
4049-
torun <command>archive-push</command> on multiple threads.
4050-
Ifyou provide the<option>--batch-size</option> option, WAL files
4051-
will be copied in batchesofthe specified size.
4058+
To speed up archiving, you can specify the <option>--batch-size</option> option
4059+
tocopy WAL segments in batches of the specified size.
4060+
If <option>--batch-size</option> option is used, then you can also specify
4061+
the <option>-j</option> option to copy the batchofWAL segments on multiple threads.
40524062
</para>
40534063
<para>
40544064
WAL segments copied to the archive are synced to disk unless
@@ -4086,10 +4096,10 @@ pg_probackup archive-get -B <replaceable>backup_dir</replaceable> --instance <re
40864096
</para>
40874097

40884098
<para>
4089-
To speed up recovery, you can specify the <option>-j</option> option
4090-
torun <command>archive-get</command> on multiple threads.
4091-
Ifyou provide the<option>--batch-size</option> option, WAL segments
4092-
will be copied in batchesofthe specified size.
4099+
To speed up recovery, you can specify the <option>--batch-size</option> option
4100+
tocopy WAL segments in batches of the specified size.
4101+
If <option>--batch-size</option> option is used, then you can also specify
4102+
the <option>-j</option> option to copy the batchofWAL segments on multiple threads.
40934103
</para>
40944104

40954105
<para>
@@ -4714,7 +4724,7 @@ pg_probackup archive-get -B <replaceable>backup_dir</replaceable> --instance <re
47144724
<term><option>--password</option></term>
47154725
<listitem>
47164726
<para>
4717-
Forces a password prompt.
4727+
Forces a password prompt. (Deprecated)
47184728
</para>
47194729
</listitem>
47204730
</varlistentry>

‎src/archive.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ setup_push_filelist(const char *archive_status_dir, const char *first_file,
944944

945945
/* get list of files from archive_status */
946946
status_files=parray_new();
947-
dir_list_file(status_files,archive_status_dir, false, false, false,0,FIO_DB_HOST);
947+
dir_list_file(status_files,archive_status_dir, false, false, false,true,0,FIO_DB_HOST);
948948
parray_qsort(status_files,pgFileComparePath);
949949

950950
for (i=0;i<parray_num(status_files);i++)

‎src/backup.c‎

Lines changed: 88 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
192192
{
193193
/* try to setup multi-timeline backup chain */
194194
elog(WARNING,"Valid backup on current timeline %u is not found, "
195-
"try to look up on previous timelines",
195+
"trying to look up on previous timelines",
196196
current.tli);
197197

198198
tli_list=catalog_get_timelines(&instance_config);
@@ -333,7 +333,7 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
333333

334334
/* list files with the logical path. omit $PGDATA */
335335
dir_list_file(backup_files_list,instance_config.pgdata,
336-
true, true, false,0,FIO_DB_HOST);
336+
true, true, false,true,0,FIO_DB_HOST);
337337

338338
/*
339339
* Get database_map (name to oid) for use in partial restore feature.
@@ -350,7 +350,7 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
350350
/* External dirs numeration starts with 1.
351351
* 0 value is not external dir */
352352
dir_list_file(backup_files_list,parray_get(external_dirs,i),
353-
false, true, false,i+1,FIO_DB_HOST);
353+
false, true, false,true,i+1,FIO_DB_HOST);
354354

355355
/* close ssh session in main thread */
356356
fio_disconnect();
@@ -401,10 +401,10 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
401401

402402
if (current.backup_mode!=BACKUP_MODE_FULL)
403403
{
404-
elog(LOG,"current_tli:%X",current.tli);
405-
elog(LOG,"prev_backup->start_lsn: %X/%X",
404+
elog(LOG,"Current tli:%X",current.tli);
405+
elog(LOG,"Parentstart_lsn: %X/%X",
406406
(uint32) (prev_backup->start_lsn >>32), (uint32) (prev_backup->start_lsn));
407-
elog(LOG,"current.start_lsn: %X/%X",
407+
elog(LOG,"start_lsn: %X/%X",
408408
(uint32) (current.start_lsn >>32), (uint32) (current.start_lsn));
409409
}
410410

@@ -436,10 +436,11 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
436436
/*
437437
* Build the page map from ptrack information.
438438
*/
439-
if (nodeInfo->ptrack_version_num==20)
439+
if (nodeInfo->ptrack_version_num>=20)
440440
make_pagemap_from_ptrack_2(backup_files_list,backup_conn,
441-
nodeInfo->ptrack_schema,
442-
prev_backup_start_lsn);
441+
nodeInfo->ptrack_schema,
442+
nodeInfo->ptrack_version_num,
443+
prev_backup_start_lsn);
443444
elseif (nodeInfo->ptrack_version_num==15||
444445
nodeInfo->ptrack_version_num==16||
445446
nodeInfo->ptrack_version_num==17)
@@ -582,9 +583,6 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
582583
/* Notify end of backup */
583584
pg_stop_backup(&current,pg_startbackup_conn,nodeInfo);
584585

585-
elog(LOG,"current.stop_lsn: %X/%X",
586-
(uint32) (stop_backup_lsn >>32), (uint32) (stop_backup_lsn));
587-
588586
/* In case of backup from replica >= 9.6 we must fix minRecPoint,
589587
* First we must find pg_control in backup_files_list.
590588
*/
@@ -626,7 +624,7 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
626624
/* Scan backup PG_XLOG_DIR */
627625
xlog_files_list=parray_new();
628626
join_path_components(pg_xlog_path,database_path,PG_XLOG_DIR);
629-
dir_list_file(xlog_files_list,pg_xlog_path, false, true, false,0,
627+
dir_list_file(xlog_files_list,pg_xlog_path, false, true, false,true,0,
630628
FIO_BACKUP_HOST);
631629

632630
/* TODO: Drop streamed WAL segments greater than stop_lsn */
@@ -884,15 +882,10 @@ do_backup(time_t start_time, bool no_validate,
884882
#endif
885883

886884
get_ptrack_version(backup_conn,&nodeInfo);
887-
//elog(WARNING, "ptrack_version_num %d", ptrack_version_num);
885+
//elog(WARNING, "ptrack_version_num %d", ptrack_version_num);
888886

889887
if (nodeInfo.ptrack_version_num>0)
890-
{
891-
if (nodeInfo.ptrack_version_num >=20)
892-
nodeInfo.is_ptrack_enable=pg_ptrack_enable2(backup_conn);
893-
else
894-
nodeInfo.is_ptrack_enable=pg_ptrack_enable(backup_conn);
895-
}
888+
nodeInfo.is_ptrack_enable=pg_ptrack_enable(backup_conn,nodeInfo.ptrack_version_num);
896889

897890
if (current.backup_mode==BACKUP_MODE_DIFF_PTRACK)
898891
{
@@ -1746,65 +1739,66 @@ pg_stop_backup(pgBackup *backup, PGconn *pg_startbackup_conn,
17461739
/* Calculate LSN */
17471740
stop_backup_lsn_tmp= ((uint64)lsn_hi) <<32 |lsn_lo;
17481741

1742+
/* It is ok for replica to return invalid STOP LSN
1743+
* UPD: Apparently it is ok even for a master.
1744+
*/
17491745
if (!XRecOffIsValid(stop_backup_lsn_tmp))
17501746
{
1751-
/* It is ok for replica to return STOP LSN with NullXRecOff
1752-
* UPD: Apparently it is ok even for master.
1753-
*/
1754-
if (XRecOffIsNull(stop_backup_lsn_tmp))
1755-
{
1756-
char*xlog_path,
1757-
stream_xlog_path[MAXPGPATH];
1758-
XLogSegNosegno=0;
1759-
XLogRecPtrlsn_tmp=InvalidXLogRecPtr;
1747+
char*xlog_path,
1748+
stream_xlog_path[MAXPGPATH];
1749+
XLogSegNosegno=0;
1750+
XLogRecPtrlsn_tmp=InvalidXLogRecPtr;
17601751

1761-
/*
1762-
* Even though the value is invalid, it's expected postgres behaviour
1763-
* and we're trying to fix it below.
1764-
*/
1765-
elog(LOG,"Null offset instop_backup_lsn value %X/%X, trying to fix",
1766-
(uint32) (stop_backup_lsn_tmp >>32), (uint32) (stop_backup_lsn_tmp));
1752+
/*
1753+
* Even though the value is invalid, it's expected postgres behaviour
1754+
* and we're trying to fix it below.
1755+
*/
1756+
elog(LOG,"Invalid offset instop_lsn value %X/%X, trying to fix",
1757+
(uint32) (stop_backup_lsn_tmp >>32), (uint32) (stop_backup_lsn_tmp));
17671758

1768-
/*
1769-
* Note: even with gdb it is very hard to produce automated tests for
1770-
* contrecord +NullXRecOff, so emulate it for manual testing.
1771-
*/
1772-
//stop_backup_lsn_tmp = stop_backup_lsn_tmp - XLOG_SEG_SIZE;
1773-
//elog(WARNING, "New Invalid stop_backup_lsn value %X/%X",
1774-
// (uint32) (stop_backup_lsn_tmp >> 32), (uint32) (stop_backup_lsn_tmp));
1759+
/*
1760+
* Note: even with gdb it is very hard to produce automated tests for
1761+
* contrecord +invalid LSN, so emulate it for manual testing.
1762+
*/
1763+
//stop_backup_lsn_tmp = stop_backup_lsn_tmp - XLOG_SEG_SIZE;
1764+
//elog(WARNING, "New Invalid stop_backup_lsn value %X/%X",
1765+
// (uint32) (stop_backup_lsn_tmp >> 32), (uint32) (stop_backup_lsn_tmp));
17751766

1776-
if (stream_wal)
1777-
{
1778-
pgBackupGetPath2(backup,stream_xlog_path,
1779-
lengthof(stream_xlog_path),
1780-
DATABASE_DIR,PG_XLOG_DIR);
1781-
xlog_path=stream_xlog_path;
1782-
}
1783-
else
1784-
xlog_path=arclog_path;
1767+
if (stream_wal)
1768+
{
1769+
pgBackupGetPath2(backup,stream_xlog_path,
1770+
lengthof(stream_xlog_path),
1771+
DATABASE_DIR,PG_XLOG_DIR);
1772+
xlog_path=stream_xlog_path;
1773+
}
1774+
else
1775+
xlog_path=arclog_path;
17851776

1786-
GetXLogSegNo(stop_backup_lsn_tmp,segno,instance_config.xlog_seg_size);
1777+
GetXLogSegNo(stop_backup_lsn_tmp,segno,instance_config.xlog_seg_size);
17871778

1788-
/*
1789-
* Note, that there is no guarantee that corresponding WAL file even exists.
1790-
* Replica may return LSN from future and keep staying in present.
1791-
* Or it can returnLSN with NullXRecOff.
1792-
*
1793-
* That's bad, since we want to get real LSN to save it in backup label file
1794-
* and to use it in WAL validation.
1795-
*
1796-
* So we try to do the following:
1797-
* 1. Wait 'archive_timeout' seconds for segment containing stop_lsn and
1798-
* look for the first valid record in it.
1799-
* It solves the problem of occasional invalidXRecOff on write-busy system.
1800-
* 2. Failing that, look for record in previous segment with endpoint
1801-
* equal or greater than stop_lsn. It may(!) solve the problem ofNullXRecOff
1802-
* on write-idle system. If that fails too, error out.
1803-
*/
1779+
/*
1780+
* Note, that there is no guarantee that corresponding WAL file even exists.
1781+
* Replica may return LSN from future and keep staying in present.
1782+
* Or it can returninvalid LSN.
1783+
*
1784+
* That's bad, since we want to get real LSN to save it in backup label file
1785+
* and to use it in WAL validation.
1786+
*
1787+
* So we try to do the following:
1788+
* 1. Wait 'archive_timeout' seconds for segment containing stop_lsn and
1789+
* look for the first valid record in it.
1790+
* It solves the problem of occasional invalidLSN on write-busy system.
1791+
* 2. Failing that, look for record in previous segment with endpoint
1792+
* equal or greater than stop_lsn. It may(!) solve the problem ofinvalid LSN
1793+
* on write-idle system. If that fails too, error out.
1794+
*/
18041795

1796+
/* stop_lsn is pointing to a 0 byte of xlog segment */
1797+
if (stop_backup_lsn_tmp %instance_config.xlog_seg_size==0)
1798+
{
18051799
/* Wait for segment with current stop_lsn, it is ok for it to never arrive */
18061800
wait_wal_lsn(stop_backup_lsn_tmp, false,backup->tli,
1807-
false, true,WARNING,stream_wal);
1801+
false, true,WARNING,stream_wal);
18081802

18091803
/* Get the first record in segment with current stop_lsn */
18101804
lsn_tmp=get_first_record_lsn(xlog_path,segno,backup->tli,
@@ -1840,17 +1834,39 @@ pg_stop_backup(pgBackup *backup, PGconn *pg_startbackup_conn,
18401834
(uint32) (stop_backup_lsn_tmp >>32),
18411835
(uint32) (stop_backup_lsn_tmp));
18421836
}
1837+
}
1838+
/* stop lsn is aligned to xlog block size, just find next lsn */
1839+
elseif (stop_backup_lsn_tmp %XLOG_BLCKSZ==0)
1840+
{
1841+
/* Wait for segment with current stop_lsn */
1842+
wait_wal_lsn(stop_backup_lsn_tmp, false,backup->tli,
1843+
false, true,ERROR,stream_wal);
1844+
1845+
/* Get the next closest record in segment with current stop_lsn */
1846+
lsn_tmp=get_next_record_lsn(xlog_path,segno,backup->tli,
1847+
instance_config.xlog_seg_size,
1848+
instance_config.archive_timeout,
1849+
stop_backup_lsn_tmp);
18431850

1844-
/* Setting stop_backup_lsn will set stop point for streaming */
1845-
stop_backup_lsn=lsn_tmp;
1846-
stop_lsn_exists= true;
1851+
/* sanity */
1852+
if (!XRecOffIsValid(lsn_tmp)||XLogRecPtrIsInvalid(lsn_tmp))
1853+
elog(ERROR,"Failed to get WAL record next to %X/%X",
1854+
(uint32) (stop_backup_lsn_tmp >>32),
1855+
(uint32) (stop_backup_lsn_tmp));
18471856
}
18481857
/* PostgreSQL returned something very illegal as STOP_LSN, error out */
18491858
else
18501859
elog(ERROR,"Invalid stop_backup_lsn value %X/%X",
18511860
(uint32) (stop_backup_lsn_tmp >>32), (uint32) (stop_backup_lsn_tmp));
1861+
1862+
/* Setting stop_backup_lsn will set stop point for streaming */
1863+
stop_backup_lsn=lsn_tmp;
1864+
stop_lsn_exists= true;
18521865
}
18531866

1867+
elog(LOG,"stop_lsn: %X/%X",
1868+
(uint32) (stop_backup_lsn >>32), (uint32) (stop_backup_lsn));
1869+
18541870
/* Write backup_label and tablespace_map */
18551871
if (!exclusive_backup)
18561872
{

‎src/catalog.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ catalog_get_timelines(InstanceConfig *instance)
872872

873873
/* read all xlog files that belong to this archive */
874874
sprintf(arclog_path,"%s/%s/%s",backup_path,"wal",instance->name);
875-
dir_list_file(xlog_files_list,arclog_path, false, false, false,0,FIO_BACKUP_HOST);
875+
dir_list_file(xlog_files_list,arclog_path, false, false, false,true,0,FIO_BACKUP_HOST);
876876
parray_qsort(xlog_files_list,pgFileComparePath);
877877

878878
timelineinfos=parray_new();

‎src/checkdb.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ do_block_validation(char *pgdata, uint32 checksum_version)
208208

209209
/* list files with the logical path. omit $PGDATA */
210210
dir_list_file(files_list,pgdata,
211-
true, true, false,0,FIO_DB_HOST);
211+
true, true, false,true,0,FIO_DB_HOST);
212212

213213
/*
214214
* Sort pathname ascending.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp