diff --git a/be/src/olap/data_dir.cpp b/be/src/olap/data_dir.cpp index baf51034e6a266..e8d99a9ae235da 100644 --- a/be/src/olap/data_dir.cpp +++ b/be/src/olap/data_dir.cpp @@ -469,8 +469,8 @@ Status DataDir::load() { if (!create_status) { LOG(WARNING) << "could not create rowset from rowsetmeta: " << " rowset_id: " << rowset_meta->rowset_id() - << " rowset_type: " << rowset_meta->rowset_type() - << " rowset_state: " << rowset_meta->rowset_state(); + << ", rowset_type: " << rowset_meta->rowset_type() + << ", rowset_state: " << rowset_meta->rowset_state(); continue; } if (rowset_meta->rowset_state() == RowsetStatePB::COMMITTED && diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp index 75e64f875ee593..d8595c52be5abc 100644 --- a/be/src/olap/tablet.cpp +++ b/be/src/olap/tablet.cpp @@ -1681,6 +1681,7 @@ void Tablet::_init_context_common_fields(RowsetWriterContext& context) { } Status Tablet::create_rowset(RowsetMetaSharedPtr rowset_meta, RowsetSharedPtr* rowset) { + RETURN_IF_ERROR(check_valid()); return RowsetFactory::create_rowset(&tablet_schema(), tablet_path(), rowset_meta, rowset); } diff --git a/be/src/olap/tablet.h b/be/src/olap/tablet.h index adacb11eb2f279..ef4a7231e5e933 100644 --- a/be/src/olap/tablet.h +++ b/be/src/olap/tablet.h @@ -25,6 +25,7 @@ #include #include +#include "common/status.h" #include "gen_cpp/AgentService_types.h" #include "gen_cpp/MasterService_types.h" #include "gen_cpp/olap_file.pb.h" @@ -282,6 +283,18 @@ class Tablet : public BaseTablet { return _tablet_meta->all_beta(); } + Status check_valid() { + if (_tablet_meta->all_rs_metas().empty()) { + return Status::Corruption("tablet_schema.all_rs_metas is empty."); + } + for (auto meta : _tablet_meta->all_rs_metas()) { + if (!meta.get() || !meta->tablet_schema()) { + return Status::Corruption("tablet_schema have null meta."); + } + } + return Status::OK(); + } + const TabletSchema& tablet_schema() const override; Status create_rowset_writer(const Version& version, const RowsetStatePB& rowset_state,