Skip to content
Merged
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
5 changes: 5 additions & 0 deletions be/src/olap/data_dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,11 @@ void DataDir::update_user_data_size(int64_t size) {
disks_data_used_capacity->set_value(size);
}

size_t DataDir::tablet_size() const {
std::lock_guard<std::mutex> l(_mutex);
return _tablet_set.size();
}

bool DataDir::reach_capacity_limit(int64_t incoming_data_size) {
double used_pct = (_disk_capacity_bytes - _available_bytes + incoming_data_size) /
(double)_disk_capacity_bytes;
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/data_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class DataDir {

void update_user_data_size(int64_t size);

std::set<TabletInfo> tablet_set() { return _tablet_set; }
size_t tablet_size() const;

void disks_compaction_score_increment(int64_t delta);

Expand Down Expand Up @@ -180,7 +180,7 @@ class DataDir {
bool _to_be_deleted;

// used to protect _current_shard and _tablet_set
std::mutex _mutex;
mutable std::mutex _mutex;
uint64_t _current_shard;
std::set<TabletInfo> _tablet_set;

Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/storage_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ std::vector<DataDir*> StorageEngine::get_stores_for_create_tablet(
for (int i = 0; i < stores.size(); i++) {
int j = i + 1;
if (j < stores.size()) {
if (stores[i]->tablet_set().size() > stores[j]->tablet_set().size()) {
if (stores[i]->tablet_size() > stores[j]->tablet_size()) {
std::swap(stores[i], stores[j]);
}
std::random_shuffle(stores.begin() + j, stores.end());
Expand Down