@@ -940,7 +940,7 @@ do_block_validation(void)
940
940
/* arrays with meta info for multi threaded backup */
941
941
pthread_t * threads ;
942
942
backup_files_arg * threads_args ;
943
- bool backup_isok = true;
943
+ bool check_isok = true;
944
944
945
945
pgBackupGetPath (& current ,database_path ,lengthof (database_path ),
946
946
DATABASE_DIR );
@@ -1017,14 +1017,14 @@ do_block_validation(void)
1017
1017
{
1018
1018
pthread_join (threads [i ],NULL );
1019
1019
if (threads_args [i ].ret > 0 )
1020
- backup_isok = false;
1020
+ check_isok = false;
1021
1021
}
1022
1022
1023
1023
/* 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 " );
1026
1026
else
1027
- elog (ERROR ,"Data fileschecking failed " );
1027
+ elog (ERROR ,"Data filesare corrupted " );
1028
1028
1029
1029
if (backup_files_list )
1030
1030
{
@@ -1042,7 +1042,7 @@ do_amcheck(void)
1042
1042
/* arrays with meta info for multi threaded backup */
1043
1043
pthread_t * threads ;
1044
1044
backup_files_arg * threads_args ;
1045
- bool backup_isok = true;
1045
+ bool check_isok = true;
1046
1046
PGresult * res_db ;
1047
1047
int n_databases = 0 ;
1048
1048
bool first_db_with_amcheck = true;
@@ -1118,13 +1118,13 @@ do_amcheck(void)
1118
1118
{
1119
1119
pthread_join (threads [j ],NULL );
1120
1120
if (threads_args [j ].ret == 1 )
1121
- backup_isok = false;
1121
+ check_isok = false;
1122
1122
}
1123
1123
pgut_disconnect (db_conn );
1124
1124
}
1125
1125
1126
1126
/* TODO write better info message */
1127
- if (backup_isok )
1127
+ if (check_isok )
1128
1128
elog (INFO ,"Indexes are checked" );
1129
1129
else
1130
1130
elog (ERROR ,"Indexs checking failed" );
@@ -1188,6 +1188,17 @@ pgdata_basic_setup(void)
1188
1188
1189
1189
is_checksum_enabled = pg_checksum_enable ();
1190
1190
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
+
1191
1202
if (is_checksum_enabled )
1192
1203
elog (LOG ,"This PostgreSQL instance was initialized with data block checksums. "
1193
1204
"Data block corruption will be detected" );
@@ -1225,10 +1236,6 @@ do_backup(time_t start_time)
1225
1236
current .compress_alg = instance_config .compress_alg ;
1226
1237
current .compress_level = instance_config .compress_level ;
1227
1238
1228
- /* TODO fix it for remote backup*/
1229
- if (!is_remote_backup )
1230
- current .checksum_version = get_data_checksum_version (true);
1231
-
1232
1239
current .stream = stream_wal ;
1233
1240
1234
1241
is_ptrack_support = pg_ptrack_support ();
@@ -1261,15 +1268,6 @@ do_backup(time_t start_time)
1261
1268
instance_config .master_user );
1262
1269
}
1263
1270
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
-
1273
1271
/* Start backup. Update backup status. */
1274
1272
current .status = BACKUP_STATUS_RUNNING ;
1275
1273
current .start_time = start_time ;
@@ -1415,10 +1413,24 @@ check_system_identifiers(void)
1415
1413
system_id_pgdata = get_system_identifier (instance_config .pgdata );
1416
1414
system_id_conn = get_remote_system_identifier (backup_conn );
1417
1415
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
+
1418
1429
if (system_id_conn != instance_config .system_identifier )
1419
1430
elog (ERROR ,"Backup data directory was initialized for system id " UINT64_FORMAT ", "
1420
1431
"but connected instance system id is " UINT64_FORMAT ,
1421
1432
instance_config .system_identifier ,system_id_conn );
1433
+
1422
1434
if (system_id_pgdata != instance_config .system_identifier )
1423
1435
elog (ERROR ,"Backup data directory was initialized for system id " UINT64_FORMAT ", "
1424
1436
"but target backup directory system id is " UINT64_FORMAT ,
@@ -2562,7 +2574,7 @@ check_files(void *arg)
2562
2574
elog (VERBOSE ,"Checking file: \"%s\" " ,file -> path );
2563
2575
2564
2576
/* check for interrupt */
2565
- if (interrupted )
2577
+ if (interrupted || thread_interrupted )
2566
2578
elog (ERROR ,"interrupted during checkdb" );
2567
2579
2568
2580
if (progress )
@@ -2579,7 +2591,6 @@ check_files(void *arg)
2579
2591
* If file is not found, this is not en error.
2580
2592
* It could have been deleted by concurrent postgres transaction.
2581
2593
*/
2582
- file -> write_size = BYTES_INVALID ;
2583
2594
elog (LOG ,"File \"%s\" is not found" ,file -> path );
2584
2595
continue ;
2585
2596
}
@@ -2597,7 +2608,7 @@ check_files(void *arg)
2597
2608
2598
2609
if (S_ISREG (buf .st_mode ))
2599
2610
{
2600
- /* check only uncompressed datafiles */
2611
+ /* check only uncompressedby cfs datafiles */
2601
2612
if (file -> is_datafile && !file -> is_cfs )
2602
2613
{
2603
2614
char to_path [MAXPGPATH ];
@@ -2639,7 +2650,7 @@ check_indexes(void *arg)
2639
2650
continue ;
2640
2651
2641
2652
/* check for interrupt */
2642
- if (interrupted )
2653
+ if (interrupted || thread_interrupted )
2643
2654
elog (ERROR ,"interrupted during checkdb --amcheck" );
2644
2655
2645
2656
elog (VERBOSE ,"Checking index number %d of %d : \"%s\" " ,i ,n_indexes ,ind -> name );