Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement](Meta) add a fault check for create_rowset to prevent meta corrupt #11355

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions be/src/olap/data_dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
1 change: 1 addition & 0 deletions be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
13 changes: 13 additions & 0 deletions be/src/olap/tablet.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <unordered_set>
#include <vector>

#include "common/status.h"
#include "gen_cpp/AgentService_types.h"
#include "gen_cpp/MasterService_types.h"
#include "gen_cpp/olap_file.pb.h"
Expand Down Expand Up @@ -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,
Expand Down