From 5609a4c9331bc8db929a7efcab9921d713b0a2b5 Mon Sep 17 00:00:00 2001 From: Xin Liao Date: Thu, 24 Oct 2024 16:12:58 +0800 Subject: [PATCH] [fix](load) Fix potential data loss during disk migration #42296 (#42387) cherry pick from #42296 --- be/src/olap/txn_manager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/be/src/olap/txn_manager.cpp b/be/src/olap/txn_manager.cpp index 4d06ab36e97924..2497b582eb282f 100644 --- a/be/src/olap/txn_manager.cpp +++ b/be/src/olap/txn_manager.cpp @@ -91,6 +91,15 @@ Status TxnManager::prepare_txn(TPartitionId partition_id, const TabletSharedPtr& const auto& schema_hash = tablet->schema_hash(); const auto& tablet_uid = tablet->tablet_uid(); + // check if the tablet has already been shutdown. If it has, it indicates that + // it is an old tablet, and data should not be imported into the old tablet. + // Otherwise, it may lead to data loss during migration. + if (tablet->tablet_state() == TABLET_SHUTDOWN) { + return Status::InternalError( + "The tablet's state is shutdown, tablet_id: {}. The tablet may have been dropped " + "or migrationed. Please check if the table has been dropped or try again.", + tablet_id); + } return prepare_txn(partition_id, transaction_id, tablet_id, schema_hash, tablet_uid, load_id, ingest); }