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

Commite268421

Browse files
committed
Merge branch 'master' into release_2_5
2 parents23b5ea5 +8e930b7 commite268421

File tree

16 files changed

+639
-274
lines changed

16 files changed

+639
-274
lines changed

‎src/catalog.c

Lines changed: 322 additions & 159 deletions
Large diffs are not rendered by default.

‎src/data.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,9 @@ backup_non_data_file(pgFile *file, pgFile *prev_file,
711711
/*
712712
* If nonedata file exists in previous backup
713713
* and its mtime is less than parent backup start time ... */
714-
if (prev_file&&file->exists_in_prev&&
715-
file->mtime <=parent_backup_time)
714+
if ((pg_strcasecmp(file->name,RELMAPPER_FILENAME)!=0)&&
715+
(prev_file&&file->exists_in_prev&&
716+
file->mtime <=parent_backup_time))
716717
{
717718

718719
file->crc=fio_get_crc32(from_fullpath,FIO_DB_HOST, false);

‎src/pg_probackup.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ extern const char *PROGRAM_EMAIL;
7878
#defineBACKUP_RO_LOCK_FILE"backup_ro.pid"
7979
#defineDATABASE_FILE_LIST"backup_content.control"
8080
#definePG_BACKUP_LABEL_FILE"backup_label"
81-
#definePG_TABLESPACE_MAP_FILE "tablespace_map"
81+
#definePG_TABLESPACE_MAP_FILE"tablespace_map"
82+
#defineRELMAPPER_FILENAME"pg_filenode.map"
8283
#defineEXTERNAL_DIR"external_directories/externaldir"
8384
#defineDATABASE_MAP"database_map"
8485
#defineHEADER_MAP "page_header_map"
@@ -331,7 +332,10 @@ typedef enum ShowFormat
331332
#defineFILE_NOT_FOUND(-2)/* file disappeared during backup */
332333
#defineBLOCKNUM_INVALID(-1)
333334
#definePROGRAM_VERSION"2.5.0"
335+
336+
/* update when remote agent API or behaviour changes */
334337
#defineAGENT_PROTOCOL_VERSION 20500
338+
#defineAGENT_PROTOCOL_VERSION_STR "2.5.0"
335339

336340
/* update only when changing storage format */
337341
#defineSTORAGE_FORMAT_VERSION "2.5.0"

‎src/restore.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,11 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
905905
if (parray_bsearch(dest_backup->files,file,pgFileCompareRelPathWithExternal))
906906
redundant= false;
907907

908+
/* pg_filenode.map are always restored, because it's crc cannot be trusted */
909+
if (file->external_dir_num==0&&
910+
pg_strcasecmp(file->name,RELMAPPER_FILENAME)==0)
911+
redundant= true;
912+
908913
/* do not delete the useful internal directories */
909914
if (S_ISDIR(file->mode)&& !redundant)
910915
continue;
@@ -1541,6 +1546,7 @@ update_recovery_options(InstanceState *instanceState, pgBackup *backup,
15411546
if (errno!=ENOENT)
15421547
elog(ERROR,"cannot stat file \"%s\": %s",postgres_auto_path,
15431548
strerror(errno));
1549+
st.st_size=0;
15441550
}
15451551

15461552
/* Kludge for 0-sized postgresql.auto.conf file. TODO: make something more intelligent */

‎src/utils/remote.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ bool launch_agent(void)
247247
(agent_version /100) %100,
248248
agent_version %100);
249249

250-
elog(ERROR,"Remote agent version %s does not match local program version %s",
251-
agent_version_str,PROGRAM_VERSION);
250+
elog(ERROR,"Remote agent protocol version %s does not match local program protocol version %s, "
251+
"consider to upgrade pg_probackup binary",
252+
agent_version_str,AGENT_PROTOCOL_VERSION_STR);
252253
}
253254

254255
return true;

‎tests/Readme.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
[см wiki](https://confluence.postgrespro.ru/display/DEV/pg_probackup)
1+
[see wiki](https://confluence.postgrespro.ru/display/DEV/pg_probackup)
22

33
```
4-
Note: For now these are works on Linux and "kinda" works on Windows
4+
Note: For now these tests work on Linux and "kinda" work on Windows
5+
```
6+
7+
```
8+
Note: tests require python3 to work properly.
59
```
610

711
```

‎tests/archive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ def test_archive_push_sanity(self):
19131913

19141914
output=self.show_archive(
19151915
backup_dir,'node',as_json=False,as_text=True,
1916-
options=['--log-level-console=VERBOSE'])
1916+
options=['--log-level-console=INFO'])
19171917

19181918
self.assertNotIn('WARNING',output)
19191919

@@ -2186,7 +2186,7 @@ def test_archive_get_batching_sanity(self):
21862186

21872187
restore_command+=' -j 2 --batch-size=10'
21882188

2189-
print(restore_command)
2189+
#print(restore_command)
21902190

21912191
ifnode.major_version>=12:
21922192
self.set_auto_conf(replica, {'restore_command':restore_command})
@@ -2303,7 +2303,7 @@ def test_archive_get_prefetch_corruption(self):
23032303
dst_file=os.path.join(replica.data_dir,wal_dir,'pbk_prefetch',filename)
23042304
shutil.copyfile(src_file,dst_file)
23052305

2306-
print(dst_file)
2306+
#print(dst_file)
23072307

23082308
# corrupt file
23092309
iffiles[-2].endswith('.gz'):

‎tests/auth_test.py

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ def test_backup_via_unprivileged_user(self):
3434
node=self.make_simple_node(
3535
base_dir=os.path.join(module_name,fname,'node'),
3636
set_replication=True,
37-
initdb_params=['--data-checksums'],
38-
pg_options={
39-
'max_wal_senders':'2'}
40-
)
37+
initdb_params=['--data-checksums'])
38+
4139
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
4240
self.init_pb(backup_dir)
4341
self.add_instance(backup_dir,'node',node)
@@ -64,7 +62,15 @@ def test_backup_via_unprivileged_user(self):
6462
"GRANT EXECUTE ON FUNCTION"
6563
" pg_start_backup(text, boolean, boolean) TO backup;")
6664

67-
time.sleep(1)
65+
ifself.get_version(node)<100000:
66+
node.safe_psql(
67+
'postgres',
68+
"GRANT EXECUTE ON FUNCTION pg_catalog.pg_switch_xlog() TO backup")
69+
else:
70+
node.safe_psql(
71+
'postgres',
72+
"GRANT EXECUTE ON FUNCTION pg_catalog.pg_switch_wal() TO backup")
73+
6874
try:
6975
self.backup_node(
7076
backup_dir,'node',node,options=['-U','backup'])
@@ -84,8 +90,6 @@ def test_backup_via_unprivileged_user(self):
8490
"GRANT EXECUTE ON FUNCTION"
8591
" pg_create_restore_point(text) TO backup;")
8692

87-
time.sleep(1)
88-
8993
try:
9094
self.backup_node(
9195
backup_dir,'node',node,options=['-U','backup'])
@@ -129,50 +133,18 @@ def test_backup_via_unprivileged_user(self):
129133
node.stop()
130134
node.slow_start()
131135

132-
try:
133-
self.backup_node(
134-
backup_dir,'node',node,options=['-U','backup'])
135-
self.assertEqual(
136-
1,0,
137-
"Expecting Error due to missing grant on clearing ptrack_files.")
138-
exceptProbackupExceptionase:
139-
self.assertIn(
140-
"ERROR: must be superuser or replication role to clear ptrack files\n"
141-
"query was: SELECT pg_catalog.pg_ptrack_clear()",e.message,
142-
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
143-
repr(e.message),self.cmd))
144-
145-
time.sleep(1)
146-
147-
try:
148-
self.backup_node(
149-
backup_dir,'node',node,
150-
backup_type='ptrack',options=['-U','backup'])
151-
self.assertEqual(
152-
1,0,
153-
"Expecting Error due to missing grant on clearing ptrack_files.")
154-
exceptProbackupExceptionase:
155-
self.assertIn(
156-
"ERROR: must be superuser or replication role read ptrack files\n"
157-
"query was: select pg_catalog.pg_ptrack_control_lsn()",e.message,
158-
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
159-
repr(e.message),self.cmd))
160-
161136
node.safe_psql(
162137
"postgres",
163138
"ALTER ROLE backup REPLICATION")
164139

165-
time.sleep(1)
166-
167140
# FULL
168141
self.backup_node(
169-
backup_dir,'node',node,
170-
options=['-U','backup'])
142+
backup_dir,'node',node,options=['-U','backup'])
171143

172144
# PTRACK
173-
self.backup_node(
174-
backup_dir,'node',node,
175-
backup_type='ptrack',options=['-U','backup'])
145+
# self.backup_node(
146+
# backup_dir, 'node', node,
147+
# backup_type='ptrack', options=['-U', 'backup'])
176148

177149
# Clean after yourself
178150
self.del_test_dir(module_name,fname)

‎tests/backup.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
importshutil
66
fromdistutils.dir_utilimportcopy_tree
77
fromtestgresimportProcessType
8+
importsubprocess
89

910

1011
module_name='backup'
@@ -3027,3 +3028,54 @@ def test_issue_231(self):
30273028

30283029
# Clean after yourself
30293030
self.del_test_dir(module_name,fname)
3031+
3032+
deftest_incr_backup_filenode_map(self):
3033+
"""
3034+
https://github.com/postgrespro/pg_probackup/issues/320
3035+
"""
3036+
fname=self.id().split('.')[3]
3037+
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
3038+
node=self.make_simple_node(
3039+
base_dir=os.path.join(module_name,fname,'node'),
3040+
initdb_params=['--data-checksums'])
3041+
3042+
self.init_pb(backup_dir)
3043+
self.add_instance(backup_dir,'node',node)
3044+
self.set_archiving(backup_dir,'node',node)
3045+
node.slow_start()
3046+
3047+
node1=self.make_simple_node(
3048+
base_dir=os.path.join(module_name,fname,'node1'),
3049+
initdb_params=['--data-checksums'])
3050+
node1.cleanup()
3051+
3052+
node.pgbench_init(scale=5)
3053+
3054+
# FULL backup
3055+
backup_id=self.backup_node(backup_dir,'node',node)
3056+
3057+
pgbench=node.pgbench(
3058+
stdout=subprocess.PIPE,stderr=subprocess.STDOUT,
3059+
options=['-T','10','-c','1'])
3060+
3061+
backup_id=self.backup_node(backup_dir,'node',node,backup_type='delta')
3062+
3063+
node.safe_psql(
3064+
'postgres',
3065+
'reindex index pg_type_oid_index')
3066+
3067+
backup_id=self.backup_node(
3068+
backup_dir,'node',node,backup_type='delta')
3069+
3070+
# incremental restore into node1
3071+
node.cleanup()
3072+
3073+
self.restore_node(backup_dir,'node',node)
3074+
node.slow_start()
3075+
3076+
node.safe_psql(
3077+
'postgres',
3078+
'select 1')
3079+
3080+
# Clean after yourself
3081+
self.del_test_dir(module_name,fname)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp