Skip to content

Commit

Permalink
[enhance](partitionid) check partition id to avoid unexpected behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed Dec 6, 2023
1 parent 0b5b366 commit 9302d17
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions be/src/olap/rowset/rowset_meta_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ Status RowsetMetaManager::get_json_rowset_meta(OlapMeta* meta, TabletUid tablet_
}
Status RowsetMetaManager::save(OlapMeta* meta, TabletUid tablet_uid, const RowsetId& rowset_id,
const RowsetMetaPB& rowset_meta_pb, bool enable_binlog) {
if (rowset_meta_pb.partition_id <= 0) {
LOG(WARNING) << "invalid partition id " << rowset_meta_pb.partition_id() << " tablet "
<< rowset_meta_pb.tablet_id();
return Status::InternalError("invalid partition id {}, tablet {}",
rowset_meta_pb.partition_id(), rowset_meta_pb.tablet_id());
}
if (enable_binlog) {
return _save_with_binlog(meta, tablet_uid, rowset_id, rowset_meta_pb);
} else {
Expand Down
5 changes: 5 additions & 0 deletions be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ void WriteCooldownMetaExecutors::WriteCooldownMetaExecutors::submit(TabletShared

TabletSharedPtr Tablet::create_tablet_from_meta(TabletMetaSharedPtr tablet_meta,
DataDir* data_dir) {
if (tablet_meta->partition_id() <= 0) {
LOG(WARNING) << "unexpected partition id " << tablet_meta->partition_id()
<< ", tablet " << tablet_meta->tablet_id();
return nullptr;
}
return std::make_shared<Tablet>(tablet_meta, data_dir);
}

Expand Down
6 changes: 6 additions & 0 deletions be/src/olap/tablet_meta_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ Status TabletMetaManager::save(DataDir* store, TTabletId tablet_id, TSchemaHash
std::string key = fmt::format("{}{}_{}", header_prefix, tablet_id, schema_hash);
std::string value;
tablet_meta->serialize(&value);
if (tablet_meta->partition_id() <= 0) {
LOG(WARNING) << "invalid partition id " << tablet_meta->partition_id()
<< " tablet " << tablet_meta->tablet_id();
return Status::InternalError("invaid partition id {} tablet {}", tablet_meta->partition_id(),
tablet_meta->tablet_id());
}
OlapMeta* meta = store->get_meta();
VLOG_NOTICE << "save tablet meta"
<< ", key:" << key << ", meta length:" << value.length();
Expand Down
7 changes: 4 additions & 3 deletions be/src/olap/txn_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ Status TxnManager::commit_txn(OlapMeta* meta, TPartitionId partition_id,
const PUniqueId& load_id, const RowsetSharedPtr& rowset_ptr,
bool is_recovery) {
if (partition_id < 1 || transaction_id < 1 || tablet_id < 1) {
LOG(FATAL) << "invalid commit req "
<< " partition_id=" << partition_id << " transaction_id=" << transaction_id
<< " tablet_id=" << tablet_id;
LOG(WARNING) << "invalid commit req "
<< " partition_id=" << partition_id << " transaction_id=" << transaction_id
<< " tablet_id=" << tablet_id;
return Status::InternalError("invalid partition id");
}

pair<int64_t, int64_t> key(partition_id, transaction_id);
Expand Down

0 comments on commit 9302d17

Please sign in to comment.