@@ -214,33 +214,35 @@ void SingleFileCheckpointWriter::CreateCheckpoint() {
214214 header.vector_size = STANDARD_VECTOR_SIZE;
215215 block_manager.WriteHeader (context, header);
216216
217- #ifdef DUCKDB_BLOCK_VERIFICATION
218- // extend verify_block_usage_count
219- auto metadata_info = storage_manager.GetMetadataInfo ();
220- for (auto &info : metadata_info) {
221- verify_block_usage_count[info.block_id ]++;
222- }
223- for (auto &entry_ref : catalog_entries) {
224- auto &entry = entry_ref.get ();
225- if (entry.type == CatalogType::TABLE_ENTRY) {
226- auto &table = entry.Cast <DuckTableEntry>();
227- auto &storage = table.GetStorage ();
228- auto segment_info = storage.GetColumnSegmentInfo ();
229- for (auto &segment : segment_info) {
230- verify_block_usage_count[segment.block_id ]++;
231- if (StringUtil::Contains (segment.segment_info , " Overflow String Block Ids: " )) {
232- auto overflow_blocks = StringUtil::Replace (segment.segment_info , " Overflow String Block Ids: " , " " );
233- auto splits = StringUtil::Split (overflow_blocks, " , " );
234- for (auto &split : splits) {
235- auto overflow_block_id = std::stoll (split);
236- verify_block_usage_count[overflow_block_id]++;
217+ auto debug_verify_blocks = DBConfig::GetSetting<DebugVerifyBlocksSetting>(db.GetDatabase ());
218+ if (debug_verify_blocks) {
219+ // extend verify_block_usage_count
220+ auto metadata_info = storage_manager.GetMetadataInfo ();
221+ for (auto &info : metadata_info) {
222+ verify_block_usage_count[info.block_id ]++;
223+ }
224+ for (auto &entry_ref : catalog_entries) {
225+ auto &entry = entry_ref.get ();
226+ if (entry.type == CatalogType::TABLE_ENTRY) {
227+ auto &table = entry.Cast <DuckTableEntry>();
228+ auto &storage = table.GetStorage ();
229+ auto segment_info = storage.GetColumnSegmentInfo ();
230+ for (auto &segment : segment_info) {
231+ verify_block_usage_count[segment.block_id ]++;
232+ if (StringUtil::Contains (segment.segment_info , " Overflow String Block Ids: " )) {
233+ auto overflow_blocks =
234+ StringUtil::Replace (segment.segment_info , " Overflow String Block Ids: " , " " );
235+ auto splits = StringUtil::Split (overflow_blocks, " , " );
236+ for (auto &split : splits) {
237+ auto overflow_block_id = std::stoll (split);
238+ verify_block_usage_count[overflow_block_id]++;
239+ }
237240 }
238241 }
239242 }
240243 }
244+ block_manager.VerifyBlocks (verify_block_usage_count);
241245 }
242- block_manager.VerifyBlocks (verify_block_usage_count);
243- #endif
244246
245247 if (debug_checkpoint_abort == CheckpointAbort::DEBUG_ABORT_BEFORE_TRUNCATE) {
246248 throw FatalException (" Checkpoint aborted before truncate because of PRAGMA checkpoint_abort flag" );
0 commit comments