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

Commitde2fcea

Browse files
committed
Remove ptrack-1.* support
1 parentda2cbcb commitde2fcea

File tree

12 files changed

+104
-860
lines changed

12 files changed

+104
-860
lines changed

‎doc/pgprobackup.xml‎

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ GRANT SELECT ON TABLE pg_catalog.pg_database TO backup;
11621162
</para>
11631163
<note>
11641164
<para>
1165-
PTRACK versions lower than 2.0 are deprecated. Postgres Pro Standard and Postgres Pro Enterprise
1165+
PTRACK versions lower than 2.0 are deprecated and not supported. Postgres Pro Standard and Postgres Pro Enterprise
11661166
versions starting with 11.9.1 contain PTRACK 2.0. Upgrade your server to avoid issues in backups
11671167
that you will take in future and be sure to take fresh backups of your clusters with the upgraded
11681168
PTRACK since the backups taken with PTRACK 1.x might be corrupt.
@@ -1218,34 +1218,6 @@ CREATE EXTENSION ptrack;
12181218
</para>
12191219
</note>
12201220

1221-
<para>
1222-
For older <productname>PostgreSQL</productname> versions,
1223-
PTRACK required taking backups in the exclusive mode
1224-
to provide exclusive access to bitmaps with changed blocks.
1225-
To set up PTRACK backups for <productname>PostgreSQL</productname> 10
1226-
or lower, do the following:
1227-
</para>
1228-
<orderedlist>
1229-
<listitem>
1230-
<para>
1231-
Set the <parameter>ptrack_enable</parameter> parameter to
1232-
<literal>on</literal>.
1233-
</para>
1234-
</listitem>
1235-
<listitem>
1236-
<para>
1237-
Grant the right to execute <application>PTRACK</application>
1238-
functions to the <literal>backup</literal> role
1239-
<emphasisrole="strong">in every database</emphasis> of the
1240-
cluster:
1241-
</para>
1242-
<programlisting>
1243-
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ptrack_clear() TO backup;
1244-
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ptrack_get_and_clear(oid, oid) TO backup;
1245-
</programlisting>
1246-
</listitem>
1247-
</orderedlist>
1248-
12491221
</refsect2>
12501222
</refsect1>
12511223

‎src/backup.c‎

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
125125
check_external_for_tablespaces(external_dirs,backup_conn);
126126
}
127127

128-
/* Clear ptrack files for not PTRACK backups */
129-
if (current.backup_mode!=BACKUP_MODE_DIFF_PTRACK&&nodeInfo->is_ptrack_enable)
130-
pg_ptrack_clear(backup_conn,nodeInfo->ptrack_version_num);
131-
132128
/* notify start of backup to PostgreSQL server */
133129
time2iso(label,lengthof(label),current.start_time, false);
134130
strncat(label," with pg_probackup",lengthof(label)-
@@ -217,29 +213,14 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
217213
{
218214
XLogRecPtrptrack_lsn=get_last_ptrack_lsn(backup_conn,nodeInfo);
219215

220-
if (nodeInfo->ptrack_version_num<200)
221-
{
222-
// backward compatibility kludge: use Stop LSN for ptrack 1.x,
223-
if (ptrack_lsn>prev_backup->stop_lsn||ptrack_lsn==InvalidXLogRecPtr)
224-
{
225-
elog(ERROR,"LSN from ptrack_control %X/%X differs from Stop LSN of previous backup %X/%X.\n"
226-
"Create new full backup before an incremental one.",
227-
(uint32) (ptrack_lsn >>32), (uint32) (ptrack_lsn),
228-
(uint32) (prev_backup->stop_lsn >>32),
229-
(uint32) (prev_backup->stop_lsn));
230-
}
231-
}
232-
else
216+
// new ptrack (>=2.0) is more robust and checks Start LSN
217+
if (ptrack_lsn>prev_backup->start_lsn||ptrack_lsn==InvalidXLogRecPtr)
233218
{
234-
// new ptrack is more robust and checks Start LSN
235-
if (ptrack_lsn>prev_backup->start_lsn||ptrack_lsn==InvalidXLogRecPtr)
236-
{
237-
elog(ERROR,"LSN from ptrack_control %X/%X is greater than Start LSN of previous backup %X/%X.\n"
238-
"Create new full backup before an incremental one.",
239-
(uint32) (ptrack_lsn >>32), (uint32) (ptrack_lsn),
240-
(uint32) (prev_backup->start_lsn >>32),
241-
(uint32) (prev_backup->start_lsn));
242-
}
219+
elog(ERROR,"LSN from ptrack_control %X/%X is greater than Start LSN of previous backup %X/%X.\n"
220+
"Create new full backup before an incremental one.",
221+
(uint32) (ptrack_lsn >>32), (uint32) (ptrack_lsn),
222+
(uint32) (prev_backup->start_lsn >>32),
223+
(uint32) (prev_backup->start_lsn));
243224
}
244225
}
245226

@@ -407,15 +388,10 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
407388
/*
408389
* Build the page map from ptrack information.
409390
*/
410-
if (nodeInfo->ptrack_version_num >=200)
411-
make_pagemap_from_ptrack_2(backup_files_list,backup_conn,
412-
nodeInfo->ptrack_schema,
413-
nodeInfo->ptrack_version_num,
414-
prev_backup_start_lsn);
415-
elseif (nodeInfo->ptrack_version_num==105||
416-
nodeInfo->ptrack_version_num==106||
417-
nodeInfo->ptrack_version_num==107)
418-
make_pagemap_from_ptrack_1(backup_files_list,backup_conn);
391+
make_pagemap_from_ptrack_2(backup_files_list,backup_conn,
392+
nodeInfo->ptrack_schema,
393+
nodeInfo->ptrack_version_num,
394+
prev_backup_start_lsn);
419395
}
420396

421397
time(&end_time);
@@ -816,6 +792,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
816792

817793
if (current.backup_mode==BACKUP_MODE_DIFF_PTRACK)
818794
{
795+
/* ptrack_version_num < 2.0 was already checked in get_ptrack_version() */
819796
if (nodeInfo.ptrack_version_num==0)
820797
elog(ERROR,"This PostgreSQL instance does not support ptrack");
821798
else

‎src/data.c‎

Lines changed: 74 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ prepare_page(ConnectionArgs *conn_arg,
290290
inttry_again=PAGE_READ_ATTEMPTS;
291291
boolpage_is_valid= false;
292292
BlockNumberabsolute_blknum=file->segno*RELSEG_SIZE+blknum;
293+
intrc=0;
293294

294295
/* check for interrupt */
295296
if (interrupted||thread_interrupted)
@@ -300,161 +301,97 @@ prepare_page(ConnectionArgs *conn_arg,
300301
* Under high write load it's possible that we've read partly
301302
* flushed page, so try several times before throwing an error.
302303
*/
303-
if (backup_mode!=BACKUP_MODE_DIFF_PTRACK||ptrack_version_num >=200)
304+
while (!page_is_valid&&try_again--)
304305
{
305-
intrc=0;
306-
while (!page_is_valid&&try_again--)
307-
{
308-
/* read the block */
309-
intread_len=fio_pread(in,page,blknum*BLCKSZ);
306+
/* read the block */
307+
intread_len=fio_pread(in,page,blknum*BLCKSZ);
310308

311-
/* The block could have been truncated. It is fine. */
312-
if (read_len==0)
313-
{
314-
elog(VERBOSE,"Cannot read block %u of \"%s\": "
315-
"block truncated",blknum,from_fullpath);
316-
returnPageIsTruncated;
317-
}
318-
elseif (read_len<0)
319-
elog(ERROR,"Cannot read block %u of \"%s\": %s",
320-
blknum,from_fullpath,strerror(errno));
321-
elseif (read_len!=BLCKSZ)
322-
elog(WARNING,"Cannot read block %u of \"%s\": "
323-
"read %i of %d, try again",
324-
blknum,from_fullpath,read_len,BLCKSZ);
325-
else
309+
/* The block could have been truncated. It is fine. */
310+
if (read_len==0)
311+
{
312+
elog(VERBOSE,"Cannot read block %u of \"%s\": "
313+
"block truncated",blknum,from_fullpath);
314+
returnPageIsTruncated;
315+
}
316+
elseif (read_len<0)
317+
elog(ERROR,"Cannot read block %u of \"%s\": %s",
318+
blknum,from_fullpath,strerror(errno));
319+
elseif (read_len!=BLCKSZ)
320+
elog(WARNING,"Cannot read block %u of \"%s\": "
321+
"read %i of %d, try again",
322+
blknum,from_fullpath,read_len,BLCKSZ);
323+
else
324+
{
325+
/* We have BLCKSZ of raw data, validate it */
326+
rc=validate_one_page(page,absolute_blknum,
327+
InvalidXLogRecPtr,page_st,
328+
checksum_version);
329+
switch (rc)
326330
{
327-
/* We have BLCKSZ of raw data, validate it */
328-
rc=validate_one_page(page,absolute_blknum,
329-
InvalidXLogRecPtr,page_st,
330-
checksum_version);
331-
switch (rc)
332-
{
333-
casePAGE_IS_ZEROED:
334-
elog(VERBOSE,"File: \"%s\" blknum %u, empty page",from_fullpath,blknum);
331+
casePAGE_IS_ZEROED:
332+
elog(VERBOSE,"File: \"%s\" blknum %u, empty page",from_fullpath,blknum);
333+
returnPageIsOk;
334+
335+
casePAGE_IS_VALID:
336+
/* in DELTA or PTRACK modes we must compare lsn */
337+
if (backup_mode==BACKUP_MODE_DIFF_DELTA||backup_mode==BACKUP_MODE_DIFF_PTRACK)
338+
page_is_valid= true;
339+
else
335340
returnPageIsOk;
336-
337-
casePAGE_IS_VALID:
338-
/* in DELTA or PTRACK modes we must compare lsn */
339-
if (backup_mode==BACKUP_MODE_DIFF_DELTA||backup_mode==BACKUP_MODE_DIFF_PTRACK)
340-
page_is_valid= true;
341-
else
342-
returnPageIsOk;
343-
break;
344-
345-
casePAGE_HEADER_IS_INVALID:
346-
elog(VERBOSE,"File: \"%s\" blknum %u have wrong page header, try again",
347-
from_fullpath,blknum);
348-
break;
349-
350-
casePAGE_CHECKSUM_MISMATCH:
351-
elog(VERBOSE,"File: \"%s\" blknum %u have wrong checksum, try again",
352-
from_fullpath,blknum);
353-
break;
354-
default:
355-
Assert(false);
356-
}
341+
break;
342+
343+
casePAGE_HEADER_IS_INVALID:
344+
elog(VERBOSE,"File: \"%s\" blknum %u have wrong page header, try again",
345+
from_fullpath,blknum);
346+
break;
347+
348+
casePAGE_CHECKSUM_MISMATCH:
349+
elog(VERBOSE,"File: \"%s\" blknum %u have wrong checksum, try again",
350+
from_fullpath,blknum);
351+
break;
352+
default:
353+
Assert(false);
357354
}
358355
}
359-
360-
/*
361-
* If page is not valid after 100 attempts to read it
362-
* throw an error.
363-
*/
364-
if (!page_is_valid)
365-
{
366-
intelevel=ERROR;
367-
char*errormsg=NULL;
368-
369-
/* Get the details of corruption */
370-
if (rc==PAGE_HEADER_IS_INVALID)
371-
get_header_errormsg(page,&errormsg);
372-
elseif (rc==PAGE_CHECKSUM_MISMATCH)
373-
get_checksum_errormsg(page,&errormsg,
374-
file->segno*RELSEG_SIZE+blknum);
375-
376-
/* Error out in case of merge or backup without ptrack support;
377-
* issue warning in case of checkdb or backup with ptrack support
378-
*/
379-
if (!strict)
380-
elevel=WARNING;
381-
382-
if (errormsg)
383-
elog(elevel,"Corruption detected in file \"%s\", block %u: %s",
384-
from_fullpath,blknum,errormsg);
385-
else
386-
elog(elevel,"Corruption detected in file \"%s\", block %u",
387-
from_fullpath,blknum);
388-
389-
pg_free(errormsg);
390-
returnPageIsCorrupted;
391-
}
392-
393-
/* Checkdb not going futher */
394-
if (!strict)
395-
returnPageIsOk;
396356
}
397357

398358
/*
399-
*Get pagevia ptrack interface from PostgreSQL shared buffer.
400-
*We do this only in the cases of PTRACK 1.x versions backup
359+
*If pageis not valid after 100 attempts to read it
360+
*throw an error.
401361
*/
402-
if (backup_mode==BACKUP_MODE_DIFF_PTRACK
403-
&& (ptrack_version_num >=105&&ptrack_version_num<200))
362+
if (!page_is_valid)
404363
{
405-
intrc=0;
406-
size_tpage_size=0;
407-
Pageptrack_page=NULL;
408-
ptrack_page= (Page)pg_ptrack_get_block(conn_arg,file->dbOid,file->tblspcOid,
409-
file->relOid,absolute_blknum,&page_size,
410-
ptrack_version_num,ptrack_schema);
411-
412-
if (ptrack_page==NULL)
413-
/* This block was truncated.*/
414-
returnPageIsTruncated;
415-
416-
if (page_size!=BLCKSZ)
417-
elog(ERROR,"File: \"%s\", block %u, expected block size %d, but read %zu",
418-
from_fullpath,blknum,BLCKSZ,page_size);
419-
420-
/*
421-
* We need to copy the page that was successfully
422-
* retrieved from ptrack into our output "page" parameter.
423-
*/
424-
memcpy(page,ptrack_page,BLCKSZ);
425-
pg_free(ptrack_page);
426-
427-
/*
428-
* UPD: It apprears that is possible to get zeroed page or page with invalid header
429-
* from shared buffer.
430-
* Note, that getting page with wrong checksumm from shared buffer is
431-
* acceptable.
432-
*/
433-
rc=validate_one_page(page,absolute_blknum,
434-
InvalidXLogRecPtr,page_st,
435-
checksum_version);
364+
intelevel=ERROR;
365+
char*errormsg=NULL;
436366

437-
/* It is ok to get zeroed page */
438-
if (rc==PAGE_IS_ZEROED)
439-
returnPageIsOk;
440-
441-
/* Getting page with invalid header from shared buffers is unacceptable */
367+
/* Get the details of corruption */
442368
if (rc==PAGE_HEADER_IS_INVALID)
443-
{
444-
char*errormsg=NULL;
445369
get_header_errormsg(page,&errormsg);
446-
elog(ERROR,"Corruption detected in file \"%s\", block %u: %s",
447-
from_fullpath,blknum,errormsg);
448-
}
370+
elseif (rc==PAGE_CHECKSUM_MISMATCH)
371+
get_checksum_errormsg(page,&errormsg,
372+
file->segno*RELSEG_SIZE+blknum);
449373

450-
/*
451-
* We must set checksum here, because it is outdated
452-
* in the block recieved from shared buffers.
374+
/* Error out in case of merge or backup without ptrack support;
375+
* issue warning in case of checkdb or backup with ptrack support
453376
*/
454-
if (checksum_version)
455-
page_st->checksum= ((PageHeader)page)->pd_checksum=pg_checksum_page(page,absolute_blknum);
377+
if (!strict)
378+
elevel=WARNING;
379+
380+
if (errormsg)
381+
elog(elevel,"Corruption detected in file \"%s\", block %u: %s",
382+
from_fullpath,blknum,errormsg);
383+
else
384+
elog(elevel,"Corruption detected in file \"%s\", block %u",
385+
from_fullpath,blknum);
386+
387+
pg_free(errormsg);
388+
returnPageIsCorrupted;
456389
}
457390

391+
/* Checkdb not going futher */
392+
if (!strict)
393+
returnPageIsOk;
394+
458395
/*
459396
* Skip page if page lsn is less than START_LSN of parent backup.
460397
* Nullified pages must be copied by DELTA backup, just to be safe.

‎src/dir.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -677,26 +677,16 @@ dir_check_file(pgFile *file, bool backup_logs)
677677
*/
678678
if (sscanf_res==2&&strcmp(tmp_rel_path,TABLESPACE_VERSION_DIRECTORY)!=0)
679679
returnCHECK_FALSE;
680-
681-
if (sscanf_res==3&&S_ISDIR(file->mode)&&
682-
strcmp(tmp_rel_path,TABLESPACE_VERSION_DIRECTORY)==0)
683-
file->is_database= true;
684680
}
685681
elseif (path_is_prefix_of_path("global",file->rel_path))
686682
{
687683
file->tblspcOid=GLOBALTABLESPACE_OID;
688-
689-
if (S_ISDIR(file->mode)&&strcmp(file->name,"global")==0)
690-
file->is_database= true;
691684
}
692685
elseif (path_is_prefix_of_path("base",file->rel_path))
693686
{
694687
file->tblspcOid=DEFAULTTABLESPACE_OID;
695688

696689
sscanf(file->rel_path,"base/%u/",&(file->dbOid));
697-
698-
if (S_ISDIR(file->mode)&&strcmp(file->name,"base")!=0)
699-
file->is_database= true;
700690
}
701691

702692
/* Do not backup ptrack_init files */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp