@@ -1299,24 +1299,33 @@ Status DBImplSecondary::CompactWithoutInstallation(
12991299 }
13001300 Status s;
13011301
1302+ const auto & mutable_cf_options = cfd->GetLatestMutableCFOptions ();
1303+
13021304 // TODO(hx235): Resuming compaction is currently incompatible with
1303- // paranoid_file_checks=true because OutputValidator hash verification would
1304- // fail during compaction resumption. Before interruption, resuming
1305- // compaction needs to persist the hash of each output file to enable
1306- // validation after resumption. Alternatively and preferably, we could move
1307- // the output verification to happen immediately after each output file is
1308- // created. This workaround currently disables resuming compaction when
1309- // paranoid_file_checks is enabled. Note that paranoid_file_checks is
1310- // disabled by default.
1305+ // output hash verification (enabled via paranoid_file_checks=true or
1306+ // verify_output_flags containing kVerifyIteration) because resumed compaction
1307+ // will lose the hash computed before interruption.
1308+ // Potential solutions:
1309+ // 1. Persist the hash state: Before interruption, save the current hash value
1310+ // of each output file to disk, allowing validation to continue correctly
1311+ // after resumption.
1312+ // 2. Immediate verification: Move output verification to happen
1313+ // immediately after each output file is created and closed, eliminating
1314+ // the need to maintain hash state across resumption boundaries.
1315+ bool output_hash_verification_enabled =
1316+ mutable_cf_options.paranoid_file_checks ||
1317+ !!(mutable_cf_options.verify_output_flags &
1318+ VerifyOutputFlags::kVerifyIteration );
1319+
13111320 bool allow_resumption =
1312- options.allow_resumption &&
1313- !cfd->GetLatestMutableCFOptions ().paranoid_file_checks ;
1321+ options.allow_resumption && !output_hash_verification_enabled;
13141322
1315- if (options.allow_resumption &&
1316- cfd->GetLatestMutableCFOptions ().paranoid_file_checks ) {
1323+ if (options.allow_resumption && output_hash_verification_enabled) {
13171324 ROCKS_LOG_WARN (immutable_db_options_.info_log ,
13181325 " Resume compaction configured but disabled due to "
1319- " incompatible with paranoid_file_checks=true" );
1326+ " incompatibility with output hash verification "
1327+ " (paranoid_file_checks=true or verify_output_flags "
1328+ " containing kVerifyIteration)" );
13201329 }
13211330
13221331 mutex_.Unlock ();
@@ -1345,8 +1354,8 @@ Status DBImplSecondary::CompactWithoutInstallation(
13451354 CompactionOptions comp_options;
13461355 comp_options.compression = kDisableCompressionOption ;
13471356 comp_options.output_file_size_limit = MaxFileSizeForLevel (
1348- cfd->GetLatestMutableCFOptions (), input. output_level ,
1349- cfd-> ioptions (). compaction_style , vstorage->base_level (),
1357+ mutable_cf_options, input. output_level , cfd->ioptions (). compaction_style ,
1358+ vstorage->base_level (),
13501359 cfd->ioptions ().level_compaction_dynamic_level_bytes );
13511360
13521361 std::vector<CompactionInputFiles> input_files;
@@ -1384,8 +1393,8 @@ Status DBImplSecondary::CompactWithoutInstallation(
13841393 }
13851394 c.reset (cfd->compaction_picker ()->PickCompactionForCompactFiles (
13861395 comp_options, input_files, input.output_level , vstorage,
1387- cfd-> GetLatestMutableCFOptions () , mutable_db_options_, 0 ,
1388- earliest_snapshot, job_context.snapshot_checker ));
1396+ mutable_cf_options , mutable_db_options_, 0 , earliest_snapshot ,
1397+ job_context.snapshot_checker ));
13891398 assert (c != nullptr );
13901399 c->FinalizeInputInfo (version);
13911400
0 commit comments