@@ -390,7 +390,11 @@ StatusOr<TabletMetadataPtr> publish_version(TabletManager* tablet_mgr, int64_t t
390390 }
391391 for (const auto & load_id : txns[i].load_ids ()) {
392392 auto tablet_log_path = tablet_mgr->txn_log_location (tablet_id, txns[i].txn_id (), load_id);
393- files_to_delete.emplace_back (tablet_log_path);
393+ if (!skip_write_tablet_metadata) {
394+ // CAN NOT delete txn log immediately, let vacuum do the work
395+ // because tablet meta may not be written successfully, and may need to reapply the txn log.
396+ files_to_delete.emplace_back (tablet_log_path);
397+ }
394398 tablet_mgr->metacache ()->erase (tablet_log_path);
395399 }
396400 continue ;
@@ -409,7 +413,7 @@ StatusOr<TabletMetadataPtr> publish_version(TabletManager* tablet_mgr, int64_t t
409413 }
410414
411415 auto tablet_log_path = tablet_mgr->txn_log_location (tablet_id, txns[i].txn_id ());
412- if (txns.size () == 1 && !txns[i].combined_txn_log ()) {
416+ if (txns.size () == 1 && !txns[i].combined_txn_log () && !skip_write_tablet_metadata ) {
413417 files_to_delete.emplace_back (tablet_log_path);
414418 }
415419
@@ -444,7 +448,11 @@ StatusOr<TabletMetadataPtr> publish_version(TabletManager* tablet_mgr, int64_t t
444448 return st;
445449 }
446450
447- files_to_delete.emplace_back (vlog_path);
451+ if (!skip_write_tablet_metadata) {
452+ // CAN NOT delete txn log immediately, let vacuum do the work
453+ // because tablet meta may not be written successfully, and may need to reapply the txn log.
454+ files_to_delete.emplace_back (vlog_path);
455+ }
448456
449457 tablet_mgr->metacache ()->erase (vlog_path);
450458 }
0 commit comments