weizuo93 commented on a change in pull request #4373:
URL: https://github.com/apache/incubator-doris/pull/4373#discussion_r475558052
##########
File path: be/src/olap/storage_engine.cpp
##########
@@ -428,6 +428,18 @@ std::vector<DataDir*>
StorageEngine::get_stores_for_create_tablet(
std::random_device rd;
srand(rd());
std::random_shuffle(stores.begin(), stores.end());
+ // Two random choices
+ 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()) {
+ std::swap(stores[i], stores[j]);
+ }
+ std::random_shuffle(stores.begin() + j, stores.end());
Review comment:
@chaoyli
The purpose of the this random_shuffle is that:
If it failed to create tablet on the first disk selected using "two
random choices", it is necessary to select another disk from the remaining
disks to create the tablet by using "two random choices" again. This
random_shuffle is the beginning of the next "two random choices".
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]