Skip to content

Commit fc1bef8

Browse files
committedJan 27, 2021
Merge branch 'master' into release_2_5
2 parents 40aeb8b + 0fbf1a2 commit fc1bef8

16 files changed

+391
-2191
lines changed
 

‎.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@ env:
4545
jobs:
4646
allow_failures:
4747
- if: env(MODE) IN (archive, backup, delta, locking, merge, replica, retention, restore)
48+
49+
# Only run CI for master branch commits to limit our travis usage
50+
branches:
51+
only:
52+
- master

‎Documentation.md

Lines changed: 0 additions & 2096 deletions
This file was deleted.

‎README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,17 @@ Regardless of the chosen backup type, all backups taken with `pg_probackup` supp
5656

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

59+
## Development
60+
61+
* Stable version state can be found under the respective [release tag](https://github.com/postgrespro/pg_probackup/releases).
62+
* `master` branch contains minor fixes that are planned to the nearest minor release.
63+
* Upcoming major release is developed in a release branch i.e. `release_2_5`.
64+
65+
For detailed release plans check [Milestones](https://github.com/postgrespro/pg_probackup/milestones)
66+
5967
## Installation and Setup
6068
### Windows Installation
61-
Installers are available in release **assets**. [Latests](https://github.com/postgrespro/pg_probackup/releases/2.4.4).
69+
Installers are available in release **assets**. [Latests](https://github.com/postgrespro/pg_probackup/releases/2.4.9).
6270

6371
### Linux Installation
6472
#### pg_probackup for vanilla PostgreSQL
@@ -160,7 +168,7 @@ sudo apt-get install pg_probackup-{std,ent}-{12,11,10,9.6}
160168
sudo apt-get install pg_probackup-{std,ent}-{12,11,10,9.6}-debuginfo
161169
```
162170

163-
Once you have `pg_probackup` installed, complete [the setup](https://github.com/postgrespro/pg_probackup/blob/master/Documentation.md#installation-and-setup).
171+
Once you have `pg_probackup` installed, complete [the setup](https://postgrespro.github.io/pg_probackup/#pbk-install-and-setup).
164172

165173
## Building from source
166174
### Linux

‎doc/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
```
33
xmllint --noout --valid probackup.xml
44
xsltproc stylesheet.xsl probackup.xml >pg-probackup.html
5-
```
5+
```

‎doc/pgprobackup.xml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,18 +1206,6 @@ CREATE EXTENSION ptrack;
12061206
does not affect PTRACK operation. The maximum allowed value is 1024.
12071207
</para>
12081208
</listitem>
1209-
<listitem>
1210-
<para>
1211-
Grant the right to execute <application>PTRACK</application>
1212-
functions to the <literal>backup</literal> role
1213-
in the database used to connect to the cluster:
1214-
</para>
1215-
<programlisting>
1216-
GRANT EXECUTE ON FUNCTION pg_ptrack_get_pagemapset(pg_lsn) TO backup;
1217-
GRANT EXECUTE ON FUNCTION pg_ptrack_control_lsn() TO backup;
1218-
GRANT EXECUTE ON FUNCTION pg_ptrack_get_block(oid, oid, oid, bigint) TO backup;
1219-
</programlisting>
1220-
</listitem>
12211209
</orderedlist>
12221210

12231211
<note>
@@ -1254,7 +1242,6 @@ GRANT EXECUTE ON FUNCTION pg_ptrack_get_block(oid, oid, oid, bigint) TO backup;
12541242
<programlisting>
12551243
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ptrack_clear() TO backup;
12561244
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ptrack_get_and_clear(oid, oid) TO backup;
1257-
GRANT EXECUTE ON FUNCTION pg_catalog.pg_stop_backup() TO backup;
12581245
</programlisting>
12591246
</listitem>
12601247
</orderedlist>
@@ -1875,8 +1862,9 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
18751862
<command>DROP DATABASE</command> command.
18761863
</para>
18771864
<para>
1878-
If want to decouple a single cluster with multiple databases into separate clusters with minimal downtime, then
1879-
you can partially restore cluster as standby via <option>--restore-as-replica</option> options.
1865+
To decouple a single cluster containing multiple databases into separate clusters with minimal downtime,
1866+
you can do partial restore of the cluster as a standby using the <option>--restore-as-replica</option> option
1867+
for specific databases.
18801868
</para>
18811869
<note>
18821870
<para>
@@ -1886,10 +1874,12 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
18861874
</note>
18871875
<note>
18881876
<para>
1889-
Due to how recovery works in PostgreSQL < 12 it is advisable to
1890-
disable <option>hot_standby</option> option, when running partial
1891-
restore of PostgreSQL cluster of version less than <option>12</option>.
1892-
Otherwise recovery may fail.
1877+
Due to recovery specifics of PostgreSQL versions earlier than 12,
1878+
it is advisable that you set the
1879+
<ulink url="https://postgrespro.com/docs/postgresql/current/runtime-config-replication.html#GUC-HOT-STANDBY">hot_standby</ulink>
1880+
parameter to <literal>off</literal> when running partial
1881+
restore of a PostgreSQL cluster of version earlier than 12.
1882+
Otherwise the recovery may fail.
18931883
</para>
18941884
</note>
18951885
</refsect3>
@@ -3978,10 +3968,11 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
39783968
this flag if you need to restore the
39793969
<productname>PostgreSQL</productname> cluster from a corrupt or an invalid backup.
39803970
Use with caution.
3981-
When used with <link linkend="pbk-incremental-restore">incremental restore</link> this flag
3982-
allows to replace already existing PGDATA with different system ID. In case of tablespaces,
3983-
remapped via <literal>--tablespace-mapping</literal> option into not empty directories,
3984-
the old content of such directories will be deleted.
3971+
If <envar>PGDATA</envar> contains a non-empty directory with system ID different from that
3972+
of the backup being restored, <link linkend="pbk-incremental-restore">incremental restore</link>
3973+
with this flag overwrites the directory contents (while an error occurs without the flag). If tablespaces
3974+
are remapped through the <literal>--tablespace-mapping</literal> option into non-empty directories,
3975+
the contents of such directories will be deleted.
39853976
</para>
39863977
</listitem>
39873978
</varlistentry>
@@ -4427,7 +4418,7 @@ pg_probackup archive-get -B <replaceable>backup_dir</replaceable> --instance <re
44274418
<listitem>
44284419
<para>
44294420
Specifies the timestamp up to which recovery will proceed.
4430-
If timezone offset is not specified, local timezone is used.
4421+
If the time zone offset is not specified, the local time zone is used.
44314422
</para>
44324423
<para>
44334424
Example: <literal>--recovery-target-time='2020-01-01 00:00:00+03'</literal>
@@ -4617,7 +4608,7 @@ pg_probackup archive-get -B <replaceable>backup_dir</replaceable> --instance <re
46174608
<para>
46184609
Specifies the timestamp up to which the backup will stay
46194610
pinned. Must be an ISO-8601 complaint timestamp.
4620-
If timezone offset is not specified, local timezone is used.
4611+
If the time zone offset is not specified, the local time zone is used.
46214612
</para>
46224613
<para>
46234614
Example: <literal>--expire-time='2020-01-01 00:00:00+03'</literal>

‎src/archive.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
421421
int partial_try_count = 0;
422422
int partial_file_size = 0;
423423
bool partial_is_stale = true;
424+
/* remote agent error message */
425+
char *errmsg = NULL;
424426

425427
/* from path */
426428
join_path_components(from_fullpath, pg_xlog_dir, wal_file_name);
@@ -579,7 +581,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
579581
from_fullpath, strerror(errno));
580582
}
581583

582-
if (read_len > 0 && fio_write(out, buf, read_len) != read_len)
584+
if (read_len > 0 && fio_write_async(out, buf, read_len) != read_len)
583585
{
584586
fio_unlink(to_fullpath_part, FIO_BACKUP_HOST);
585587
elog(ERROR, "Cannot write to destination temp file \"%s\": %s",
@@ -593,6 +595,14 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
593595
/* close source file */
594596
fclose(in);
595597

598+
/* Writing is asynchronous in case of push in remote mode, so check agent status */
599+
if (fio_check_error_fd(out, &errmsg))
600+
{
601+
fio_unlink(to_fullpath_part, FIO_BACKUP_HOST);
602+
elog(ERROR, "Cannot write to the remote file \"%s\": %s",
603+
to_fullpath_part, errmsg);
604+
}
605+
596606
/* close temp file */
597607
if (fio_close(out) != 0)
598608
{
@@ -652,6 +662,8 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
652662
int partial_try_count = 0;
653663
int partial_file_size = 0;
654664
bool partial_is_stale = true;
665+
/* remote agent errormsg */
666+
char *errmsg = NULL;
655667

656668
/* from path */
657669
join_path_components(from_fullpath, pg_xlog_dir, wal_file_name);
@@ -804,6 +816,7 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
804816
}
805817

806818
/* copy content */
819+
/* TODO: move to separate function */
807820
for (;;)
808821
{
809822
size_t read_len = 0;
@@ -831,7 +844,15 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
831844
/* close source file */
832845
fclose(in);
833846

834-
/* close temp file */
847+
/* Writing is asynchronous in case of push in remote mode, so check agent status */
848+
if (fio_check_error_fd_gz(out, &errmsg))
849+
{
850+
fio_unlink(to_fullpath_gz_part, FIO_BACKUP_HOST);
851+
elog(ERROR, "Cannot write to the remote compressed file \"%s\": %s",
852+
to_fullpath_gz_part, errmsg);
853+
}
854+
855+
/* close temp file, TODO: make it synchronous */
835856
if (fio_gzclose(out) != 0)
836857
{
837858
fio_unlink(to_fullpath_gz_part, FIO_BACKUP_HOST);

‎src/data.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,21 +1084,22 @@ restore_data_file_internal(FILE *in, FILE *out, pgFile *file, uint32 backup_vers
10841084
cur_pos_out = write_pos;
10851085
}
10861086

1087-
/* If page is compressed and restore is in remote mode, send compressed
1088-
* page to the remote side.
1087+
/*
1088+
* If page is compressed and restore is in remote mode,
1089+
* send compressed page to the remote side.
10891090
*/
10901091
if (is_compressed)
10911092
{
10921093
ssize_t rc;
1093-
rc = fio_fwrite_compressed(out, page.data, compressed_size, file->compress_alg);
1094+
rc = fio_fwrite_async_compressed(out, page.data, compressed_size, file->compress_alg);
10941095

10951096
if (!fio_is_remote_file(out) && rc != BLCKSZ)
10961097
elog(ERROR, "Cannot write block %u of \"%s\": %s, size: %u",
10971098
blknum, to_fullpath, strerror(errno), compressed_size);
10981099
}
10991100
else
11001101
{
1101-
if (fio_fwrite(out, page.data, BLCKSZ) != BLCKSZ)
1102+
if (fio_fwrite_async(out, page.data, BLCKSZ) != BLCKSZ)
11021103
elog(ERROR, "Cannot write block %u of \"%s\": %s",
11031104
blknum, to_fullpath, strerror(errno));
11041105
}
@@ -1144,7 +1145,7 @@ restore_non_data_file_internal(FILE *in, FILE *out, pgFile *file,
11441145

11451146
if (read_len > 0)
11461147
{
1147-
if (fio_fwrite(out, buf, read_len) != read_len)
1148+
if (fio_fwrite_async(out, buf, read_len) != read_len)
11481149
elog(ERROR, "Cannot write to \"%s\": %s", to_fullpath,
11491150
strerror(errno));
11501151
}

‎src/pg_probackup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ extern datapagemap_t *fio_get_lsn_map(const char *fullpath, uint32 checksum_vers
12061206
fio_location location);
12071207
extern pid_t fio_check_postmaster(const char *pgdata, fio_location location);
12081208

1209-
extern int32 fio_decompress(void* dst, void const* src, size_t size, int compress_alg);
1209+
extern int32 fio_decompress(void* dst, void const* src, size_t size, int compress_alg, char **errormsg);
12101210

12111211
/* return codes for fio_send_pages() and fio_send_file() */
12121212
#define SEND_OK (0)

‎src/restore.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ restore_files(void *arg)
11091109
bool already_exists = false;
11101110
PageState *checksum_map = NULL; /* it should take ~1.5MB at most */
11111111
datapagemap_t *lsn_map = NULL; /* it should take 16kB at most */
1112+
char *errmsg = NULL; /* remote agent error message */
11121113
pgFile *dest_file = (pgFile *) parray_get(arguments->dest_files, i);
11131114

11141115
/* Directories were created before */
@@ -1262,6 +1263,10 @@ restore_files(void *arg)
12621263
}
12631264

12641265
done:
1266+
/* Writing is asynchronous in case of restore in remote mode, so check the agent status */
1267+
if (fio_check_error_file(out, &errmsg))
1268+
elog(ERROR, "Cannot write to the remote file \"%s\": %s", to_fullpath, errmsg);
1269+
12651270
/* close file */
12661271
if (fio_fclose(out) != 0)
12671272
elog(ERROR, "Cannot close file \"%s\": %s", to_fullpath,
@@ -1510,8 +1515,8 @@ update_recovery_options(pgBackup *backup,
15101515
char postgres_auto_path[MAXPGPATH];
15111516
char postgres_auto_path_tmp[MAXPGPATH];
15121517
char path[MAXPGPATH];
1513-
FILE *fp;
1514-
FILE *fp_tmp;
1518+
FILE *fp = NULL;
1519+
FILE *fp_tmp = NULL;
15151520
struct stat st;
15161521
char current_time_str[100];
15171522
/* postgresql.auto.conf parsing */
@@ -1535,9 +1540,13 @@ update_recovery_options(pgBackup *backup,
15351540
strerror(errno));
15361541
}
15371542

1538-
fp = fio_open_stream(postgres_auto_path, FIO_DB_HOST);
1539-
if (fp == NULL && errno != ENOENT)
1540-
elog(ERROR, "cannot open \"%s\": %s", postgres_auto_path, strerror(errno));
1543+
/* Kludge for 0-sized postgresql.auto.conf file. TODO: make something more intelligent */
1544+
if (st.st_size > 0)
1545+
{
1546+
fp = fio_open_stream(postgres_auto_path, FIO_DB_HOST);
1547+
if (fp == NULL)
1548+
elog(ERROR, "cannot open \"%s\": %s", postgres_auto_path, strerror(errno));
1549+
}
15411550

15421551
sprintf(postgres_auto_path_tmp, "%s.tmp", postgres_auto_path);
15431552
fp_tmp = fio_fopen(postgres_auto_path_tmp, "w", FIO_DB_HOST);
@@ -1577,9 +1586,11 @@ update_recovery_options(pgBackup *backup,
15771586
if (fp)
15781587
fio_close_stream(fp);
15791588

1580-
/* TODO: detect remote error */
1581-
if (buf_len > 0)
1582-
fio_fwrite(fp_tmp, buf, buf_len);
1589+
/* Write data to postgresql.auto.conf.tmp */
1590+
if (buf_len > 0 &&
1591+
(fio_fwrite(fp_tmp, buf, buf_len) != buf_len))
1592+
elog(ERROR, "Cannot write to \"%s\": %s",
1593+
postgres_auto_path_tmp, strerror(errno));
15831594

15841595
if (fio_fflush(fp_tmp) != 0 ||
15851596
fio_fclose(fp_tmp))

0 commit comments

Comments
 (0)
Please sign in to comment.