[improvement](BE) Remove unnecessary error handling codes (#26760)
This commit is contained in:
@ -252,15 +252,14 @@ Status DataDir::_read_and_write_test_file() {
|
||||
return read_write_test_file(test_file);
|
||||
}
|
||||
|
||||
Status DataDir::get_shard(uint64_t* shard) {
|
||||
uint64_t DataDir::get_shard() {
|
||||
uint32_t next_shard = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> l(_mutex);
|
||||
next_shard = _current_shard;
|
||||
_current_shard = (_current_shard + 1) % MAX_SHARD_NUM;
|
||||
}
|
||||
*shard = next_shard;
|
||||
return Status::OK();
|
||||
return next_shard;
|
||||
}
|
||||
|
||||
void DataDir::register_tablet(Tablet* tablet) {
|
||||
|
||||
@ -82,7 +82,7 @@ public:
|
||||
Status set_cluster_id(int32_t cluster_id);
|
||||
void health_check();
|
||||
|
||||
Status get_shard(uint64_t* shard);
|
||||
uint64_t get_shard();
|
||||
|
||||
OlapMeta* get_meta() { return _meta; }
|
||||
|
||||
|
||||
@ -1152,20 +1152,14 @@ Status StorageEngine::obtain_shard_path(TStorageMedium::type storage_medium, int
|
||||
*store = stores[0];
|
||||
}
|
||||
|
||||
Status res = Status::OK();
|
||||
uint64_t shard = 0;
|
||||
res = (*store)->get_shard(&shard);
|
||||
if (!res.ok()) {
|
||||
LOG(WARNING) << "fail to get root path shard. res=" << res;
|
||||
return res;
|
||||
}
|
||||
uint64_t shard = (*store)->get_shard();
|
||||
|
||||
std::stringstream root_path_stream;
|
||||
root_path_stream << (*store)->path() << "/" << DATA_PREFIX << "/" << shard;
|
||||
*shard_path = root_path_stream.str();
|
||||
|
||||
LOG(INFO) << "success to process obtain root path. path=" << shard_path;
|
||||
return res;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status StorageEngine::load_header(const string& shard_path, const TCloneReq& request,
|
||||
|
||||
@ -235,11 +235,6 @@ void WriteCooldownMetaExecutors::WriteCooldownMetaExecutors::submit(TabletShared
|
||||
[task = std::move(async_write_task)]() { task(); });
|
||||
}
|
||||
|
||||
TabletSharedPtr Tablet::create_tablet_from_meta(TabletMetaSharedPtr tablet_meta,
|
||||
DataDir* data_dir) {
|
||||
return std::make_shared<Tablet>(std::move(tablet_meta), data_dir);
|
||||
}
|
||||
|
||||
Tablet::Tablet(TabletMetaSharedPtr tablet_meta, DataDir* data_dir,
|
||||
const std::string_view& cumulative_compaction_type)
|
||||
: BaseTablet(std::move(tablet_meta)),
|
||||
|
||||
@ -89,9 +89,6 @@ extern const std::chrono::seconds TRACE_TABLET_LOCK_THRESHOLD;
|
||||
|
||||
class Tablet final : public BaseTablet {
|
||||
public:
|
||||
static TabletSharedPtr create_tablet_from_meta(TabletMetaSharedPtr tablet_meta,
|
||||
DataDir* data_dir = nullptr);
|
||||
|
||||
Tablet(TabletMetaSharedPtr tablet_meta, DataDir* data_dir,
|
||||
const std::string_view& cumulative_compaction_type = "");
|
||||
|
||||
|
||||
@ -498,10 +498,9 @@ TabletSharedPtr TabletManager::_create_tablet_meta_and_dir_unlocked(
|
||||
}
|
||||
}
|
||||
|
||||
TabletSharedPtr new_tablet = Tablet::create_tablet_from_meta(tablet_meta, data_dir);
|
||||
TabletSharedPtr new_tablet = std::make_shared<Tablet>(std::move(tablet_meta), data_dir);
|
||||
COUNTER_UPDATE(ADD_CHILD_TIMER(profile, "CreateTabletFromMeta", parent_timer_name),
|
||||
static_cast<int64_t>(watch.reset()));
|
||||
DCHECK(new_tablet != nullptr);
|
||||
return new_tablet;
|
||||
}
|
||||
return nullptr;
|
||||
@ -836,11 +835,7 @@ Status TabletManager::load_tablet_from_meta(DataDir* data_dir, TTabletId tablet_
|
||||
tablet_meta->set_tablet_state(TABLET_RUNNING);
|
||||
}
|
||||
|
||||
TabletSharedPtr tablet = Tablet::create_tablet_from_meta(tablet_meta, data_dir);
|
||||
if (tablet == nullptr) {
|
||||
return Status::Error<TABLE_CREATE_FROM_HEADER_ERROR>(
|
||||
"fail to load tablet. tablet_id={}, schema_hash={}", tablet_id, schema_hash);
|
||||
}
|
||||
TabletSharedPtr tablet = std::make_shared<Tablet>(std::move(tablet_meta), data_dir);
|
||||
|
||||
// NOTE: method load_tablet_from_meta could be called by two cases as below
|
||||
// case 1: BE start;
|
||||
@ -859,7 +854,7 @@ Status TabletManager::load_tablet_from_meta(DataDir* data_dir, TTabletId tablet_
|
||||
}
|
||||
}
|
||||
|
||||
if (tablet_meta->tablet_state() == TABLET_SHUTDOWN) {
|
||||
if (tablet->tablet_meta()->tablet_state() == TABLET_SHUTDOWN) {
|
||||
{
|
||||
std::lock_guard<std::shared_mutex> shutdown_tablets_wrlock(_shutdown_tablets_lock);
|
||||
_shutdown_tablets.push_back(tablet);
|
||||
@ -1282,11 +1277,9 @@ Status TabletManager::_create_tablet_meta_unlocked(const TCreateTabletReq& reque
|
||||
VLOG_NOTICE << "creating tablet meta. next_unique_id=" << next_unique_id;
|
||||
|
||||
// We generate a new tablet_uid for this new tablet.
|
||||
uint64_t shard_id = 0;
|
||||
RETURN_NOT_OK_STATUS_WITH_WARN(store->get_shard(&shard_id), "fail to get root path shard");
|
||||
Status res = TabletMeta::create(request, TabletUid::gen_uid(), shard_id, next_unique_id,
|
||||
col_idx_to_unique_id, tablet_meta);
|
||||
RETURN_IF_ERROR(res);
|
||||
uint64_t shard_id = store->get_shard();
|
||||
*tablet_meta = TabletMeta::create(request, TabletUid::gen_uid(), shard_id, next_unique_id,
|
||||
col_idx_to_unique_id);
|
||||
if (request.__isset.storage_format) {
|
||||
if (request.storage_format == TStorageFormat::DEFAULT) {
|
||||
(*tablet_meta)
|
||||
@ -1300,7 +1293,7 @@ Status TabletManager::_create_tablet_meta_unlocked(const TCreateTabletReq& reque
|
||||
request.storage_format);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
TabletSharedPtr TabletManager::_get_tablet_unlocked(TTabletId tablet_id) {
|
||||
|
||||
@ -48,15 +48,15 @@ using std::vector;
|
||||
namespace doris {
|
||||
using namespace ErrorCode;
|
||||
|
||||
Status TabletMeta::create(const TCreateTabletReq& request, const TabletUid& tablet_uid,
|
||||
uint64_t shard_id, uint32_t next_unique_id,
|
||||
const unordered_map<uint32_t, uint32_t>& col_ordinal_to_unique_id,
|
||||
TabletMetaSharedPtr* tablet_meta) {
|
||||
TabletMetaSharedPtr TabletMeta::create(
|
||||
const TCreateTabletReq& request, const TabletUid& tablet_uid, uint64_t shard_id,
|
||||
uint32_t next_unique_id,
|
||||
const unordered_map<uint32_t, uint32_t>& col_ordinal_to_unique_id) {
|
||||
std::optional<TBinlogConfig> binlog_config;
|
||||
if (request.__isset.binlog_config) {
|
||||
binlog_config = request.binlog_config;
|
||||
}
|
||||
*tablet_meta = std::make_shared<TabletMeta>(
|
||||
return std::make_shared<TabletMeta>(
|
||||
request.table_id, request.partition_id, request.tablet_id, request.replica_id,
|
||||
request.tablet_schema.schema_hash, shard_id, request.tablet_schema, next_unique_id,
|
||||
col_ordinal_to_unique_id, tablet_uid,
|
||||
@ -69,7 +69,6 @@ Status TabletMeta::create(const TCreateTabletReq& request, const TabletUid& tabl
|
||||
request.time_series_compaction_goal_size_mbytes,
|
||||
request.time_series_compaction_file_count_threshold,
|
||||
request.time_series_compaction_time_threshold_seconds);
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
TabletMeta::TabletMeta()
|
||||
|
||||
@ -91,10 +91,10 @@ class TBinlogConfig;
|
||||
// The concurrency control is handled in Tablet Class, not in this class.
|
||||
class TabletMeta {
|
||||
public:
|
||||
static Status create(const TCreateTabletReq& request, const TabletUid& tablet_uid,
|
||||
uint64_t shard_id, uint32_t next_unique_id,
|
||||
const std::unordered_map<uint32_t, uint32_t>& col_ordinal_to_unique_id,
|
||||
TabletMetaSharedPtr* tablet_meta);
|
||||
static TabletMetaSharedPtr create(
|
||||
const TCreateTabletReq& request, const TabletUid& tablet_uid, uint64_t shard_id,
|
||||
uint32_t next_unique_id,
|
||||
const std::unordered_map<uint32_t, uint32_t>& col_ordinal_to_unique_id);
|
||||
|
||||
TabletMeta();
|
||||
TabletMeta(int64_t table_id, int64_t partition_id, int64_t tablet_id, int64_t replica_id,
|
||||
|
||||
@ -214,7 +214,7 @@ Status EngineStorageMigrationTask::_migrate() {
|
||||
RETURN_IF_ERROR(_get_versions(start_version, &end_version, &consistent_rowsets));
|
||||
|
||||
// TODO(ygl): the tablet should not under schema change or rollup or load
|
||||
RETURN_IF_ERROR(_dest_store->get_shard(&shard));
|
||||
shard = _dest_store->get_shard();
|
||||
|
||||
auto shard_path = fmt::format("{}/{}/{}", _dest_store->path(), DATA_PREFIX, shard);
|
||||
full_path = SnapshotManager::get_schema_hash_full_path(_tablet, shard_path);
|
||||
|
||||
Reference in New Issue
Block a user