github-actions[bot] commented on code in PR #70646:
URL: https://github.com/apache/doris/pull/70646#discussion_r4662694527


##########
be/src/storage/task/engine_storage_migration_task.cpp:
##########
@@ -190,14 +191,24 @@ Status EngineStorageMigrationTask::_reload_tablet(const 
std::string& full_path)
 // if the size less than threshold, return true
 bool EngineStorageMigrationTask::_is_rowsets_size_less_than_threshold(
         const std::vector<RowsetSharedPtr>& consistent_rowsets) {
-    size_t total_size = 0;
-    for (const auto& rs : consistent_rowsets) {
-        total_size += rs->index_disk_size() + rs->data_disk_size();
+    constexpr int64_t bytes_per_mb = 1024 * 1024;
+    int64_t remaining_bytes =
+            
static_cast<int64_t>(config::migration_remaining_size_threshold_mb) * 
bytes_per_mb;
+    // Zero disables locked tail copying; negative settings must not become 
unsigned budgets.
+    if (remaining_bytes <= 0) {
+        return false;
     }
-    if (total_size < config::migration_remaining_size_threshold_mb) {
-        return true;
+    for (const auto& rs : consistent_rowsets) {
+        for (int64_t size : {rs->index_disk_size(), rs->data_disk_size()}) {
+            // Deduct each file category separately to avoid overflowing 
either a rowset sum
+            // or the accumulated size. Equality still exceeds the strict 
less-than budget.
+            if (size >= remaining_bytes) {
+                return false;
+            }
+            remaining_bytes -= size;

Review Comment:
   [P2] Reject negative rowset sizes before subtracting them from the remaining 
migration budget. Legacy rowset metadata can retain a negative 
`index_disk_size` (the compaction and beta-rowset writer paths explicitly 
repair this historical state), and `TabletMeta::init_from_pb` loads it without 
validation. With the new loop, a negative value bypasses the `size >= 
remaining_bytes` check and increases the budget (or overflows for `INT64_MIN`), 
so migration can enter the locked tail-copy path for an actually large rowset 
and hold the exclusive migration lock far longer than 
`migration_remaining_size_threshold_mb`. Treat invalid/negative sizes as 
oversized or recover the physical size before this predicate.



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

To unsubscribe, e-mail: [email protected]

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