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

Commit702d13e

Browse files
committed
PGPRO-2065: allow checkdb to be used without BACKUP_DIR
1 parent8964f2a commit702d13e

File tree

3 files changed

+171
-114
lines changed

3 files changed

+171
-114
lines changed

‎src/backup.c

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ do_block_validation(void)
940940
/* arrays with meta info for multi threaded backup */
941941
pthread_t*threads;
942942
backup_files_arg*threads_args;
943-
boolbackup_isok= true;
943+
boolcheck_isok= true;
944944

945945
pgBackupGetPath(&current,database_path,lengthof(database_path),
946946
DATABASE_DIR);
@@ -1017,14 +1017,14 @@ do_block_validation(void)
10171017
{
10181018
pthread_join(threads[i],NULL);
10191019
if (threads_args[i].ret>0)
1020-
backup_isok= false;
1020+
check_isok= false;
10211021
}
10221022

10231023
/* TODO write better info message */
1024-
if (backup_isok)
1025-
elog(INFO,"Data files arechecked");
1024+
if (check_isok)
1025+
elog(INFO,"Data files arevalid");
10261026
else
1027-
elog(ERROR,"Data fileschecking failed");
1027+
elog(ERROR,"Data filesare corrupted");
10281028

10291029
if (backup_files_list)
10301030
{
@@ -1042,7 +1042,7 @@ do_amcheck(void)
10421042
/* arrays with meta info for multi threaded backup */
10431043
pthread_t*threads;
10441044
backup_files_arg*threads_args;
1045-
boolbackup_isok= true;
1045+
boolcheck_isok= true;
10461046
PGresult*res_db;
10471047
intn_databases=0;
10481048
boolfirst_db_with_amcheck= true;
@@ -1118,13 +1118,13 @@ do_amcheck(void)
11181118
{
11191119
pthread_join(threads[j],NULL);
11201120
if (threads_args[j].ret==1)
1121-
backup_isok= false;
1121+
check_isok= false;
11221122
}
11231123
pgut_disconnect(db_conn);
11241124
}
11251125

11261126
/* TODO write better info message */
1127-
if (backup_isok)
1127+
if (check_isok)
11281128
elog(INFO,"Indexes are checked");
11291129
else
11301130
elog(ERROR,"Indexs checking failed");
@@ -1188,6 +1188,17 @@ pgdata_basic_setup(void)
11881188

11891189
is_checksum_enabled=pg_checksum_enable();
11901190

1191+
1192+
/*
1193+
* Ensure that backup directory was initialized for the same PostgreSQL
1194+
* instance we opened connection to. And that target backup database PGDATA
1195+
* belogns to the same instance.
1196+
*/
1197+
/* TODO fix it for remote backup */
1198+
1199+
if (!is_remote_backup)
1200+
check_system_identifiers();
1201+
11911202
if (is_checksum_enabled)
11921203
elog(LOG,"This PostgreSQL instance was initialized with data block checksums. "
11931204
"Data block corruption will be detected");
@@ -1225,10 +1236,6 @@ do_backup(time_t start_time)
12251236
current.compress_alg=instance_config.compress_alg;
12261237
current.compress_level=instance_config.compress_level;
12271238

1228-
/* TODO fix it for remote backup*/
1229-
if (!is_remote_backup)
1230-
current.checksum_version=get_data_checksum_version(true);
1231-
12321239
current.stream=stream_wal;
12331240

12341241
is_ptrack_support=pg_ptrack_support();
@@ -1261,15 +1268,6 @@ do_backup(time_t start_time)
12611268
instance_config.master_user);
12621269
}
12631270

1264-
/*
1265-
* Ensure that backup directory was initialized for the same PostgreSQL
1266-
* instance we opened connection to. And that target backup database PGDATA
1267-
* belogns to the same instance.
1268-
*/
1269-
/* TODO fix it for remote backup */
1270-
if (!is_remote_backup)
1271-
check_system_identifiers();
1272-
12731271
/* Start backup. Update backup status. */
12741272
current.status=BACKUP_STATUS_RUNNING;
12751273
current.start_time=start_time;
@@ -1415,10 +1413,24 @@ check_system_identifiers(void)
14151413
system_id_pgdata=get_system_identifier(instance_config.pgdata);
14161414
system_id_conn=get_remote_system_identifier(backup_conn);
14171415

1416+
/* for checkdb check only system_id_pgdata and system_id_conn */
1417+
if (current.backup_mode==BACKUP_MODE_INVALID)
1418+
{
1419+
if (system_id_conn!=system_id_pgdata)
1420+
{
1421+
elog(ERROR,"Data directory initialized with system id "UINT64_FORMAT", "
1422+
"but connected instance system id is "UINT64_FORMAT,
1423+
system_id_pgdata,system_id_conn);
1424+
}
1425+
return;
1426+
}
1427+
1428+
14181429
if (system_id_conn!=instance_config.system_identifier)
14191430
elog(ERROR,"Backup data directory was initialized for system id "UINT64_FORMAT", "
14201431
"but connected instance system id is "UINT64_FORMAT,
14211432
instance_config.system_identifier,system_id_conn);
1433+
14221434
if (system_id_pgdata!=instance_config.system_identifier)
14231435
elog(ERROR,"Backup data directory was initialized for system id "UINT64_FORMAT", "
14241436
"but target backup directory system id is "UINT64_FORMAT,
@@ -2562,7 +2574,7 @@ check_files(void *arg)
25622574
elog(VERBOSE,"Checking file: \"%s\" ",file->path);
25632575

25642576
/* check for interrupt */
2565-
if (interrupted)
2577+
if (interrupted||thread_interrupted)
25662578
elog(ERROR,"interrupted during checkdb");
25672579

25682580
if (progress)
@@ -2579,7 +2591,6 @@ check_files(void *arg)
25792591
* If file is not found, this is not en error.
25802592
* It could have been deleted by concurrent postgres transaction.
25812593
*/
2582-
file->write_size=BYTES_INVALID;
25832594
elog(LOG,"File \"%s\" is not found",file->path);
25842595
continue;
25852596
}
@@ -2597,7 +2608,7 @@ check_files(void *arg)
25972608

25982609
if (S_ISREG(buf.st_mode))
25992610
{
2600-
/* check only uncompressed datafiles */
2611+
/* check only uncompressedby cfsdatafiles */
26012612
if (file->is_datafile&& !file->is_cfs)
26022613
{
26032614
charto_path[MAXPGPATH];
@@ -2639,7 +2650,7 @@ check_indexes(void *arg)
26392650
continue;
26402651

26412652
/* check for interrupt */
2642-
if (interrupted)
2653+
if (interrupted||thread_interrupted)
26432654
elog(ERROR,"interrupted during checkdb --amcheck");
26442655

26452656
elog(VERBOSE,"Checking index number %d of %d : \"%s\" ",i,n_indexes,ind->name);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp