weizuo93 commented on a change in pull request #4373:
URL: https://github.com/apache/incubator-doris/pull/4373#discussion_r475640545



##########
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]);
+            }

Review comment:
       @acelyc111 
   If we use std::sort directly, all tablets will be created on the same disk 
which has the least amount of tablets. I think it would be better to take into 
account both the number of tablets on the disk and the randomness of disk 
selection.




----------------------------------------------------------------
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]

Reply via email to