Skip to content

Commit ab85396

Browse files
committed
Merge branch 'master' into release_2_5
2 parents d8050e5 + 4188a69 commit ab85396

21 files changed

+175
-352
lines changed

src/data.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,13 +2001,14 @@ send_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const char *from_f
20012001
{
20022002
FILE *in = NULL;
20032003
FILE *out = NULL;
2004-
int hdr_num = -1;
20052004
off_t cur_pos_out = 0;
20062005
char curr_page[BLCKSZ];
20072006
int n_blocks_read = 0;
20082007
BlockNumber blknum = 0;
20092008
datapagemap_iterator_t *iter = NULL;
20102009
int compressed_size = 0;
2010+
BackupPageHeader2 *header = NULL;
2011+
parray *harray = NULL;
20112012

20122013
/* stdio buffers */
20132014
char *in_buf = NULL;
@@ -2046,6 +2047,8 @@ send_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const char *from_f
20462047
setvbuf(in, in_buf, _IOFBF, STDIO_BUFSIZE);
20472048
}
20482049

2050+
harray = parray_new();
2051+
20492052
while (blknum < file->n_blocks)
20502053
{
20512054
PageState page_st;
@@ -2063,17 +2066,15 @@ send_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const char *from_f
20632066
if (!out)
20642067
out = open_local_file_rw(to_fullpath, &out_buf, STDIO_BUFSIZE);
20652068

2066-
hdr_num++;
2067-
2068-
if (!*headers)
2069-
*headers = (BackupPageHeader2 *) pgut_malloc(sizeof(BackupPageHeader2));
2070-
else
2071-
*headers = (BackupPageHeader2 *) pgut_realloc(*headers, (hdr_num+1) * sizeof(BackupPageHeader2));
2069+
header = pgut_new0(BackupPageHeader2);
2070+
*header = (BackupPageHeader2){
2071+
.block = blknum,
2072+
.pos = cur_pos_out,
2073+
.lsn = page_st.lsn,
2074+
.checksum = page_st.checksum,
2075+
};
20722076

2073-
(*headers)[hdr_num].block = blknum;
2074-
(*headers)[hdr_num].pos = cur_pos_out;
2075-
(*headers)[hdr_num].lsn = page_st.lsn;
2076-
(*headers)[hdr_num].checksum = page_st.checksum;
2077+
parray_append(harray, header);
20772078

20782079
compressed_size = compress_and_backup_page(file, blknum, in, out, &(file->crc),
20792080
rc, curr_page, calg, clevel,
@@ -2098,12 +2099,22 @@ send_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const char *from_f
20982099
* Add dummy header, so we can later extract the length of last header
20992100
* as difference between their offsets.
21002101
*/
2101-
if (*headers)
2102+
if (parray_num(harray) > 0)
21022103
{
2103-
file->n_headers = hdr_num +1;
2104-
*headers = (BackupPageHeader2 *) pgut_realloc(*headers, (hdr_num+2) * sizeof(BackupPageHeader2));
2105-
(*headers)[hdr_num+1].pos = cur_pos_out;
2104+
size_t hdr_num = parray_num(harray);
2105+
size_t i;
2106+
2107+
file->n_headers = (int) hdr_num; /* is it valid? */
2108+
*headers = (BackupPageHeader2 *) pgut_malloc0((hdr_num + 1) * sizeof(BackupPageHeader2));
2109+
for (i = 0; i < hdr_num; i++)
2110+
{
2111+
header = (BackupPageHeader2 *)parray_get(harray, i);
2112+
(*headers)[i] = *header;
2113+
pg_free(header);
2114+
}
2115+
(*headers)[hdr_num] = (BackupPageHeader2){.pos=cur_pos_out};
21062116
}
2117+
parray_free(harray);
21072118

21082119
/* cleanup */
21092120
if (in && fclose(in))

src/restore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,8 @@ do_restore_or_validate(InstanceState *instanceState, time_t target_backup_id, pg
559559
elog(INFO, "shift LSN: %X/%X",
560560
(uint32) (shift_lsn >> 32), (uint32) shift_lsn);
561561

562-
params->shift_lsn = shift_lsn;
563562
}
563+
params->shift_lsn = shift_lsn;
564564

565565
/* for validation or restore with enabled validation */
566566
if (!params->is_restore || !params->no_validate)

src/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ writeControlFile(ControlFileData *ControlFile, const char *path, fio_location lo
136136
#endif
137137

138138
/* copy controlFileSize */
139-
buffer = pg_malloc(ControlFileSize);
139+
buffer = pg_malloc0(ControlFileSize);
140140
memcpy(buffer, ControlFile, sizeof(ControlFileData));
141141

142142
/* Write pg_control */

src/utils/pgut.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,17 @@ pgut_malloc(size_t size)
877877
return ret;
878878
}
879879

880+
void *
881+
pgut_malloc0(size_t size)
882+
{
883+
char *ret;
884+
885+
ret = pgut_malloc(size);
886+
memset(ret, 0, size);
887+
888+
return ret;
889+
}
890+
880891
void *
881892
pgut_realloc(void *p, size_t size)
882893
{

src/utils/pgut.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ extern int pgut_wait(int num, PGconn *connections[], struct timeval *timeout);
5959
* memory allocators
6060
*/
6161
extern void *pgut_malloc(size_t size);
62+
extern void *pgut_malloc0(size_t size);
6263
extern void *pgut_realloc(void *p, size_t size);
6364
extern char *pgut_strdup(const char *str);
6465
extern char *pgut_strndup(const char *str, size_t n);
6566

6667
#define pgut_new(type) ((type *) pgut_malloc(sizeof(type)))
68+
#define pgut_new0(type) ((type *) pgut_malloc0(sizeof(type)))
6769
#define pgut_newarray(type, n) ((type *) pgut_malloc(sizeof(type) * (n)))
6870

6971
/*

tests/archive.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,6 @@ def test_basic_master_and_replica_concurrent_archiving(self):
908908
initdb_params=['--data-checksums'],
909909
pg_options={
910910
'checkpoint_timeout': '30s',
911-
'autovacuum': 'off',
912911
'archive_timeout': '10s'})
913912

914913
if self.get_version(master) < self.version_to_num('9.6.0'):
@@ -1012,8 +1011,7 @@ def test_concurrent_archiving(self):
10121011
master = self.make_simple_node(
10131012
base_dir=os.path.join(module_name, fname, 'master'),
10141013
set_replication=True,
1015-
initdb_params=['--data-checksums'],
1016-
pg_options={'autovacuum': 'off'})
1014+
initdb_params=['--data-checksums'])
10171015

10181016
self.init_pb(backup_dir)
10191017
self.add_instance(backup_dir, 'node', master)
@@ -1245,8 +1243,7 @@ def test_archive_catalog(self):
12451243
initdb_params=['--data-checksums'],
12461244
pg_options={
12471245
'archive_timeout': '30s',
1248-
'checkpoint_timeout': '30s',
1249-
'autovacuum': 'off'})
1246+
'checkpoint_timeout': '30s'})
12501247

12511248
if self.get_version(master) < self.version_to_num('9.6.0'):
12521249
self.del_test_dir(module_name, fname)
@@ -1568,8 +1565,7 @@ def test_archive_catalog_1(self):
15681565
initdb_params=['--data-checksums'],
15691566
pg_options={
15701567
'archive_timeout': '30s',
1571-
'checkpoint_timeout': '30s',
1572-
'autovacuum': 'off'})
1568+
'checkpoint_timeout': '30s'})
15731569

15741570
self.init_pb(backup_dir)
15751571
self.add_instance(backup_dir, 'node', node)
@@ -1624,8 +1620,7 @@ def test_archive_catalog_2(self):
16241620
initdb_params=['--data-checksums'],
16251621
pg_options={
16261622
'archive_timeout': '30s',
1627-
'checkpoint_timeout': '30s',
1628-
'autovacuum': 'off'})
1623+
'checkpoint_timeout': '30s'})
16291624

16301625
self.init_pb(backup_dir)
16311626
self.add_instance(backup_dir, 'node', node)
@@ -1821,8 +1816,7 @@ def test_hexadecimal_timeline(self):
18211816
node = self.make_simple_node(
18221817
base_dir=os.path.join(module_name, fname, 'node'),
18231818
set_replication=True,
1824-
initdb_params=['--data-checksums'],
1825-
pg_options={'autovacuum': 'off'})
1819+
initdb_params=['--data-checksums'])
18261820

18271821
self.init_pb(backup_dir)
18281822
self.add_instance(backup_dir, 'node', node)
@@ -1885,7 +1879,6 @@ def test_archiving_and_slots(self):
18851879
set_replication=True,
18861880
initdb_params=['--data-checksums'],
18871881
pg_options={
1888-
'autovacuum': 'off',
18891882
'checkpoint_timeout': '30s',
18901883
'max_wal_size': '64MB'})
18911884

@@ -2018,8 +2011,7 @@ def test_archive_pg_receivexlog_partial_handling(self):
20182011
node = self.make_simple_node(
20192012
base_dir=os.path.join(module_name, fname, 'node'),
20202013
set_replication=True,
2021-
initdb_params=['--data-checksums'],
2022-
pg_options={'autovacuum': 'off'})
2014+
initdb_params=['--data-checksums'])
20232015

20242016
self.init_pb(backup_dir)
20252017
self.add_instance(backup_dir, 'node', node)
@@ -2108,8 +2100,7 @@ def test_multi_timeline_recovery_prefetching(self):
21082100
node = self.make_simple_node(
21092101
base_dir=os.path.join(module_name, fname, 'node'),
21102102
set_replication=True,
2111-
initdb_params=['--data-checksums'],
2112-
pg_options={'autovacuum': 'off'})
2103+
initdb_params=['--data-checksums'])
21132104

21142105
self.init_pb(backup_dir)
21152106
self.add_instance(backup_dir, 'node', node)
@@ -2224,8 +2215,7 @@ def test_archive_get_batching_sanity(self):
22242215
node = self.make_simple_node(
22252216
base_dir=os.path.join(module_name, fname, 'node'),
22262217
set_replication=True,
2227-
initdb_params=['--data-checksums'],
2228-
pg_options={'autovacuum': 'off'})
2218+
initdb_params=['--data-checksums'])
22292219

22302220
if self.get_version(node) < self.version_to_num('9.6.0'):
22312221
self.del_test_dir(module_name, fname)
@@ -2297,8 +2287,7 @@ def test_archive_get_prefetch_corruption(self):
22972287
node = self.make_simple_node(
22982288
base_dir=os.path.join(module_name, fname, 'node'),
22992289
set_replication=True,
2300-
initdb_params=['--data-checksums'],
2301-
pg_options={'autovacuum': 'off'})
2290+
initdb_params=['--data-checksums'])
23022291

23032292
self.init_pb(backup_dir)
23042293
self.add_instance(backup_dir, 'node', node)

tests/backup.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,8 +1401,7 @@ def test_drop_rel_during_backup_page(self):
14011401
node = self.make_simple_node(
14021402
base_dir=os.path.join(module_name, fname, 'node'),
14031403
set_replication=True,
1404-
initdb_params=['--data-checksums'],
1405-
pg_options={'autovacuum': 'off'})
1404+
initdb_params=['--data-checksums'])
14061405

14071406
self.init_pb(backup_dir)
14081407
self.add_instance(backup_dir, 'node', node)
@@ -1660,8 +1659,7 @@ def test_pg_11_adjusted_wal_segment_size(self):
16601659
'--data-checksums',
16611660
'--wal-segsize=64'],
16621661
pg_options={
1663-
'min_wal_size': '128MB',
1664-
'autovacuum': 'off'})
1662+
'min_wal_size': '128MB'})
16651663

16661664
self.init_pb(backup_dir)
16671665
self.add_instance(backup_dir, 'node', node)
@@ -2576,9 +2574,7 @@ def test_issue_132(self):
25762574
node = self.make_simple_node(
25772575
base_dir=os.path.join(module_name, fname, 'node'),
25782576
set_replication=True,
2579-
initdb_params=['--data-checksums'],
2580-
pg_options={
2581-
'autovacuum': 'off'})
2577+
initdb_params=['--data-checksums'])
25822578

25832579
self.init_pb(backup_dir)
25842580
self.add_instance(backup_dir, 'node', node)
@@ -2616,9 +2612,7 @@ def test_issue_132_1(self):
26162612
node = self.make_simple_node(
26172613
base_dir=os.path.join(module_name, fname, 'node'),
26182614
set_replication=True,
2619-
initdb_params=['--data-checksums'],
2620-
pg_options={
2621-
'autovacuum': 'off'})
2615+
initdb_params=['--data-checksums'])
26222616

26232617
# TODO: check version of old binary, it should be 2.1.4, 2.1.5 or 2.2.1
26242618

@@ -2963,8 +2957,7 @@ def test_issue_203(self):
29632957
node = self.make_simple_node(
29642958
base_dir=os.path.join(module_name, fname, 'node'),
29652959
set_replication=True,
2966-
initdb_params=['--data-checksums'],
2967-
pg_options={'autovacuum': 'off'})
2960+
initdb_params=['--data-checksums'])
29682961

29692962
self.init_pb(backup_dir)
29702963
self.add_instance(backup_dir, 'node', node)
@@ -3004,8 +2997,7 @@ def test_issue_231(self):
30042997
node = self.make_simple_node(
30052998
base_dir=os.path.join(module_name, fname, 'node'),
30062999
set_replication=True,
3007-
initdb_params=['--data-checksums'],
3008-
pg_options={'autovacuum': 'off'})
3000+
initdb_params=['--data-checksums'])
30093001

30103002
self.init_pb(backup_dir)
30113003
self.add_instance(backup_dir, 'node', node)

0 commit comments

Comments
 (0)