Skip to content

Commit

Permalink
[fix](create table) Fix test_partition_create_tablet_rr docker regr…
Browse files Browse the repository at this point in the history
…ession case
  • Loading branch information
deardeng committed Sep 19, 2024
1 parent 2aab21f commit e291fdc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions be/src/olap/storage_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ StorageEngine::StorageEngine(const EngineOptions& options)
_txn_manager(new TxnManager(*this, config::txn_map_shard_size, config::txn_shard_size)),
_default_rowset_type(BETA_ROWSET),
_create_tablet_idx_lru_cache(
new CreateTabletIdxCache(config::partition_disk_index_lru_size)),
new CreateTabletRRIdxCache(config::partition_disk_index_lru_size)),
_snapshot_mgr(std::make_unique<SnapshotManager>(*this)) {
REGISTER_HOOK_METRIC(unused_rowsets_count, [this]() {
// std::lock_guard<std::mutex> lock(_gc_mutex);
Expand Down Expand Up @@ -515,7 +515,7 @@ Status StorageEngine::set_cluster_id(int32_t cluster_id) {

int StorageEngine::_get_and_set_next_disk_index(int64 partition_id,
TStorageMedium::type storage_medium) {
auto key = CreateTabletIdxCache::get_key(partition_id, storage_medium);
auto key = CreateTabletRRIdxCache::get_key(partition_id, storage_medium);
int curr_index = _create_tablet_idx_lru_cache->get_index(key);
// -1, lru can't find key
if (curr_index == -1) {
Expand Down Expand Up @@ -1511,7 +1511,7 @@ Status StorageEngine::_persist_broken_paths() {
return Status::OK();
}

int CreateTabletIdxCache::get_index(const std::string& key) {
int CreateTabletRRIdxCache::get_index(const std::string& key) {
auto* lru_handle = lookup(key);
if (lru_handle) {
Defer release([cache = this, lru_handle] { cache->release(lru_handle); });
Expand All @@ -1522,7 +1522,7 @@ int CreateTabletIdxCache::get_index(const std::string& key) {
return -1;
}

void CreateTabletIdxCache::set_index(const std::string& key, int next_idx) {
void CreateTabletRRIdxCache::set_index(const std::string& key, int next_idx) {
assert(next_idx >= 0);
auto* value = new CacheValue;
value->idx = next_idx;
Expand Down
10 changes: 5 additions & 5 deletions be/src/olap/storage_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Thread;
class ThreadPool;
class TxnManager;
class ReportWorker;
class CreateTabletIdxCache;
class CreateTabletRRIdxCache;
struct DirInfo;
class SnapshotManager;

Expand Down Expand Up @@ -532,15 +532,15 @@ class StorageEngine final : public BaseStorageEngine {
// next index for create tablet
std::map<TStorageMedium::type, int> _last_use_index;

std::unique_ptr<CreateTabletIdxCache> _create_tablet_idx_lru_cache;
std::unique_ptr<CreateTabletRRIdxCache> _create_tablet_idx_lru_cache;

std::unique_ptr<SnapshotManager> _snapshot_mgr;
};

// lru cache for create tabelt round robin in disks
// key: partitionId_medium
// value: index
class CreateTabletIdxCache : public LRUCachePolicy {
class CreateTabletRRIdxCache : public LRUCachePolicy {
public:
// get key, delimiter with DELIMITER '-'
static std::string get_key(int64_t partition_id, TStorageMedium::type medium) {
Expand All @@ -557,10 +557,10 @@ class CreateTabletIdxCache : public LRUCachePolicy {
int idx = 0;
};

CreateTabletIdxCache(size_t capacity)
CreateTabletRRIdxCache(size_t capacity)
: LRUCachePolicy(CachePolicy::CacheType::CREATE_TABLET_RR_IDX_CACHE, capacity,
LRUCacheType::NUMBER,
/*stale_sweep_time_s*/ 30 * 60) {}
/*stale_sweep_time_s*/ 30 * 60, 1) {}
};

struct DirInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ suite("test_partition_create_tablet_rr", "docker") {
options.beConfigs += [
'report_tablet_interval_seconds=1',
'report_disk_state_interval_seconds=1',
"partition_disk_index_lru_size=$partition_disk_index_lru_size"
"partition_disk_index_lru_size=$partition_disk_index_lru_size",
'sys_log_verbose_modules=*'
]
options.beDisks = ['HDD=4','SSD=4']
options.enableDebugPoints()
Expand Down

0 comments on commit e291fdc

Please sign in to comment.