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

Commitbbd4e81

Browse files
committed
Merge branch 'master' into issue_52
2 parentsc2d6824 +97e6182 commitbbd4e81

File tree

12 files changed

+97
-41
lines changed

12 files changed

+97
-41
lines changed

‎gen_probackup_project.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ sub build_pgprobackup
182182
$probackup->AddFile("$pgsrc/src/bin/pg_rewind/datapagemap.c");
183183

184184
$probackup->AddFile("$pgsrc/src/interfaces/libpq/pthread-win32.c");
185+
$probackup->AddFile("$pgsrc/src/timezone/strftime.c");
185186

186187
$probackup->AddIncludeDir("$pgsrc/src/bin/pg_basebackup");
187188
$probackup->AddIncludeDir("$pgsrc/src/bin/pg_rewind");

‎src/backup.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,15 @@ do_backup_instance(void)
582582
strlen(" with pg_probackup"));
583583
pg_start_backup(label,smooth_checkpoint,&current);
584584

585+
/* For incremental backup check that start_lsn is not from the past */
586+
if (current.backup_mode!=BACKUP_MODE_FULL&&
587+
prev_backup->start_lsn>current.start_lsn)
588+
elog(ERROR,"Current START LSN %X/%X is lower than START LSN %X/%X of previous backup %s. "
589+
"It may indicate that we are trying to backup PostgreSQL instance from the past.",
590+
(uint32) (current.start_lsn >>32), (uint32) (current.start_lsn),
591+
(uint32) (prev_backup->start_lsn >>32), (uint32) (prev_backup->start_lsn),
592+
base36enc(prev_backup->start_time));
593+
585594
/* Update running backup meta with START LSN */
586595
write_backup(&current);
587596

‎src/merge.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ do_merge(time_t backup_id)
8282
/* It is possible that previous merging was interrupted */
8383
backup->status!=BACKUP_STATUS_MERGING&&
8484
backup->status!=BACKUP_STATUS_DELETING)
85-
elog(ERROR,"Backup %s has status: %s",
86-
base36enc(backup->start_time),status2str(backup->status));
85+
elog(ERROR,"Backup %s has status: %s",
86+
base36enc(backup->start_time),status2str(backup->status));
8787

8888
if (backup->backup_mode==BACKUP_MODE_FULL)
8989
elog(ERROR,"Backup %s is full backup",
@@ -111,10 +111,8 @@ do_merge(time_t backup_id)
111111
full_backup->status!=BACKUP_STATUS_DONE&&
112112
/* It is possible that previous merging was interrupted */
113113
full_backup->status!=BACKUP_STATUS_MERGING)
114-
elog(ERROR,"Backup %s has status: %s",
115-
base36enc(full_backup->start_time),status2str(full_backup->status));
116-
117-
//Assert(full_backup_idx != dest_backup_idx);
114+
elog(ERROR,"Backup %s has status: %s",
115+
base36enc(full_backup->start_time),status2str(full_backup->status));
118116

119117
/* form merge list */
120118
while(dest_backup->parent_backup_link)
@@ -125,8 +123,8 @@ do_merge(time_t backup_id)
125123
/* It is possible that previous merging was interrupted */
126124
dest_backup->status!=BACKUP_STATUS_MERGING&&
127125
dest_backup->status!=BACKUP_STATUS_DELETING)
128-
elog(ERROR,"Backup %s has status: %s",
129-
base36enc(dest_backup->start_time),status2str(dest_backup->status));
126+
elog(ERROR,"Backup %s has status: %s",
127+
base36enc(dest_backup->start_time),status2str(dest_backup->status));
130128

131129
parray_append(merge_list,dest_backup);
132130
dest_backup=dest_backup->parent_backup_link;
@@ -210,7 +208,8 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
210208
*/
211209
Assert(from_backup->status==BACKUP_STATUS_OK||
212210
from_backup->status==BACKUP_STATUS_DONE||
213-
from_backup->status==BACKUP_STATUS_MERGING);
211+
from_backup->status==BACKUP_STATUS_MERGING||
212+
from_backup->status==BACKUP_STATUS_DELETING);
214213
pgBackupValidate(from_backup);
215214
if (from_backup->status==BACKUP_STATUS_CORRUPT)
216215
elog(ERROR,"Interrupt merging");

‎src/parsexlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,8 +1191,8 @@ XLogThreadWorker(void *arg)
11911191
* Consider thread_arg->endSegNo and thread_arg->endpoint only if
11921192
* they are valid.
11931193
*/
1194-
xlogreader->ReadRecPtr==thread_arg->endpoint&&
1195-
nextSegNo>thread_arg->endSegNo)
1194+
xlogreader->ReadRecPtr>=thread_arg->endpoint&&
1195+
nextSegNo >=thread_arg->endSegNo)
11961196
break;
11971197
}
11981198

‎src/utils/logger.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,11 @@ logfile_getname(const char *format, time_t timestamp)
470470
len=strlen(filename);
471471

472472
/* Treat log_filename as a strftime pattern */
473+
#ifdefWIN32
474+
if (pg_strftime(filename+len,MAXPGPATH-len,format,tm) <=0)
475+
#else
473476
if (strftime(filename+len,MAXPGPATH-len,format,tm) <=0)
477+
#endif
474478
elog_stderr(ERROR,"strftime(%s) failed: %s",format,strerror(errno));
475479

476480
returnfilename;

‎tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def load_tests(loader, tests, pattern):
1818
# suite.addTests(loader.loadTestsFromModule(cfs_backup))
1919
# suite.addTests(loader.loadTestsFromModule(cfs_restore))
2020
# suite.addTests(loader.loadTestsFromModule(cfs_validate_backup))
21-
# suite.addTests(loader.loadTestsFromModule(logging))
21+
suite.addTests(loader.loadTestsFromModule(logging))
2222
suite.addTests(loader.loadTestsFromModule(compression))
2323
suite.addTests(loader.loadTestsFromModule(delete))
2424
suite.addTests(loader.loadTestsFromModule(delta))

‎tests/archive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,10 @@ def test_replica_archive(self):
422422
set_replication=True,
423423
initdb_params=['--data-checksums'],
424424
pg_options={
425-
'max_wal_senders':'2',
426425
'archive_timeout':'10s',
427-
'max_wal_size':'1GB'}
428-
)
426+
'checkpoint_timeout':'30s',
427+
'max_wal_size':'16MB'})
428+
429429
self.init_pb(backup_dir)
430430
# ADD INSTANCE 'MASTER'
431431
self.add_instance(backup_dir,'master',master)

‎tests/delta.py

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,14 +711,12 @@ def test_create_db(self):
711711
1,0,
712712
"Expecting Error because we are connecting to deleted database"
713713
"\n Output: {0}\n CMD: {1}".format(
714-
repr(self.output),self.cmd)
715-
)
714+
repr(self.output),self.cmd))
716715
exceptQueryExceptionase:
717716
self.assertTrue(
718717
'FATAL: database "db1" does not exist'ine.message,
719718
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
720-
repr(e.message),self.cmd)
721-
)
719+
repr(e.message),self.cmd))
722720

723721
# Clean after yourself
724722
self.del_test_dir(module_name,fname)
@@ -1307,3 +1305,53 @@ def test_delta_nullified_heap_page_backup(self):
13071305

13081306
# Clean after yourself
13091307
self.del_test_dir(module_name,fname)
1308+
1309+
deftest_delta_backup_from_past(self):
1310+
"""
1311+
make node, take FULL stream backup, take DELTA stream backup,
1312+
restore FULL backup, try to take second DELTA stream backup
1313+
"""
1314+
fname=self.id().split('.')[3]
1315+
node=self.make_simple_node(
1316+
base_dir=os.path.join(module_name,fname,'node'),
1317+
initdb_params=['--data-checksums'])
1318+
1319+
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
1320+
self.init_pb(backup_dir)
1321+
self.add_instance(backup_dir,'node',node)
1322+
node.slow_start()
1323+
1324+
backup_id=self.backup_node(
1325+
backup_dir,'node',node,options=['--stream'])
1326+
1327+
node.pgbench_init(scale=3)
1328+
1329+
# First DELTA
1330+
self.backup_node(
1331+
backup_dir,'node',node,
1332+
backup_type='delta',options=['--stream'])
1333+
1334+
# Restore FULL backup
1335+
node.cleanup()
1336+
self.restore_node(backup_dir,'node',node,backup_id=backup_id)
1337+
node.slow_start()
1338+
1339+
# Second DELTA backup
1340+
try:
1341+
self.backup_node(
1342+
backup_dir,'node',node,
1343+
backup_type='delta',options=['--stream'])
1344+
# we should die here because exception is what we expect to happen
1345+
self.assertEqual(
1346+
1,0,
1347+
"Expecting Error because we are backing up an instance from the past"
1348+
"\n Output: {0}\n CMD: {1}".format(
1349+
repr(self.output),self.cmd))
1350+
exceptQueryExceptionase:
1351+
self.assertTrue(
1352+
'Insert error message'ine.message,
1353+
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
1354+
repr(e.message),self.cmd))
1355+
1356+
# Clean after yourself
1357+
self.del_test_dir(module_name,fname)

‎tests/external.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,7 @@ def test_backup_multiple_external(self):
253253
fname=self.id().split('.')[3]
254254
node=self.make_simple_node(
255255
base_dir=os.path.join(module_name,fname,'node'),
256-
initdb_params=['--data-checksums'],
257-
pg_options={
258-
'max_wal_senders':'2'})
256+
initdb_params=['--data-checksums'])
259257

260258
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
261259
self.init_pb(backup_dir)
@@ -326,9 +324,7 @@ def test_external_backward_compatibility(self):
326324
base_dir=os.path.join(module_name,fname,'node'),
327325
set_replication=True,
328326
initdb_params=['--data-checksums'],
329-
pg_options={
330-
'max_wal_senders':'2',
331-
'autovacuum':'off'})
327+
pg_options={'autovacuum':'off'})
332328

333329
self.init_pb(backup_dir,old_binary=True)
334330
self.show_pb(backup_dir)
@@ -429,9 +425,7 @@ def test_external_backward_compatibility_merge_1(self):
429425
base_dir=os.path.join(module_name,fname,'node'),
430426
set_replication=True,
431427
initdb_params=['--data-checksums'],
432-
pg_options={
433-
'max_wal_senders':'2',
434-
'autovacuum':'off'})
428+
pg_options={'autovacuum':'off'})
435429

436430
self.init_pb(backup_dir,old_binary=True)
437431
self.show_pb(backup_dir)
@@ -523,9 +517,7 @@ def test_external_backward_compatibility_merge_2(self):
523517
base_dir=os.path.join(module_name,fname,'node'),
524518
set_replication=True,
525519
initdb_params=['--data-checksums'],
526-
pg_options={
527-
'max_wal_senders':'2',
528-
'autovacuum':'off'})
520+
pg_options={'autovacuum':'off'})
529521

530522
self.init_pb(backup_dir,old_binary=True)
531523
self.show_pb(backup_dir)
@@ -641,12 +633,10 @@ def test_external_merge(self):
641633
base_dir=os.path.join(module_name,fname,'node'),
642634
set_replication=True,
643635
initdb_params=['--data-checksums'],
644-
pg_options={
645-
'max_wal_senders':'2',
646-
'autovacuum':'off'})
636+
pg_options={'autovacuum':'off'})
647637

648638
self.init_pb(backup_dir)
649-
self.add_instance(backup_dir,'node',node)
639+
self.add_instance(backup_dir,'node',node,old_binary=True)
650640
node.slow_start()
651641

652642
node.pgbench_init(scale=5)

‎tests/helpers/ptrack_helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,10 @@ def get_md5_per_page_for_fork(self, file, size_in_pages):
395395
defget_ptrack_bits_per_page_for_fork(self,node,file,size=[]):
396396

397397
ifself.get_pgpro_edition(node)=='enterprise':
398-
header_size=48
398+
ifself.get_version(node)<self.version_to_num('10.0'):
399+
header_size=48
400+
else
401+
header_size=24
399402
else:
400403
header_size=24
401404
ptrack_bits_for_fork= []

‎tests/merge.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ def test_continue_failed_merge_with_corrupted_delta_backup(self):
11971197

11981198
deftest_continue_failed_merge_2(self):
11991199
"""
1200-
Check that failed MERGE on delete can`t be continued
1200+
Check that failed MERGE on delete can be continued
12011201
"""
12021202
fname=self.id().split('.')[3]
12031203
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
@@ -1253,6 +1253,8 @@ def test_continue_failed_merge_2(self):
12531253

12541254
backup_id_deleted=self.show_pb(backup_dir,"node")[1]["id"]
12551255

1256+
# TODO check that full backup has meta info is equal to DELETTING
1257+
12561258
# Try to continue failed MERGE
12571259
self.merge_backup(backup_dir,"node",backup_id)
12581260
# Clean after yourself

‎tests/replica.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ def test_replica_archive_page_backup(self):
141141
set_replication=True,
142142
initdb_params=['--data-checksums'],
143143
pg_options={
144-
'wal_level':'replica',
145-
'max_wal_senders':'2',
146-
'archive_timeout':'10s'}
147-
)
144+
'archive_timeout':'10s',
145+
'checkpoint_timeout':'30s',
146+
'max_wal_size':'16MB'})
147+
148148
self.init_pb(backup_dir)
149149
self.add_instance(backup_dir,'master',master)
150150
self.set_archiving(backup_dir,'master',master)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp