This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new fa4407c  Fix bug for cumulative compaction on singleton rowset with 
multiple segments (#2719)
fa4407c is described below

commit fa4407cf4f06d5dbad8b6be6ede91118d703bb61
Author: lichaoyong <[email protected]>
AuthorDate: Thu Jan 9 21:08:21 2020 +0800

    Fix bug for cumulative compaction on singleton rowset with multiple 
segments (#2719)
    
    Row will be scanned mistakenly after cumulative compaction on singleton 
rowset.
    If I have (1, 1), (2, 2), (3, 3) three records.
    Now I have read (1, 1), this bug will make return row is (2, 2)
    instead of (1, 1).
---
 be/src/olap/rowset/alpha_rowset_reader.cpp | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/be/src/olap/rowset/alpha_rowset_reader.cpp 
b/be/src/olap/rowset/alpha_rowset_reader.cpp
index 18aec29..9460601 100644
--- a/be/src/olap/rowset/alpha_rowset_reader.cpp
+++ b/be/src/olap/rowset/alpha_rowset_reader.cpp
@@ -156,6 +156,18 @@ OLAPStatus AlphaRowsetReader::_merge_block(RowBlock** 
block) {
         copy_row(_dst_cursor, *row_cursor, _read_block->mem_pool());
         _read_block->pos_inc();
         num_rows_in_block++;
+
+        // MergeHeap should advance one step after row been read.
+        // This function must be called after copy_row
+        // Otherwise, the row has read will be modified instantly before 
handled.
+        // For example:
+        // If I have (1, 1), (2, 2), (3, 3) three records.
+        // Now I have read (1, 1).
+        // Before copy_row, I rebuild the heap
+        // The returned row will be (2, 2) instead of (1, 1)
+        AlphaMergeContext* merge_ctx = _merge_heap.top();
+        _merge_heap.pop();
+        RETURN_NOT_OK(_update_merge_ctx_and_build_merge_heap(merge_ctx));
     }
     _read_block->set_pos(0);
     _read_block->set_limit(num_rows_in_block);
@@ -205,9 +217,9 @@ OLAPStatus 
AlphaRowsetReader::_pull_next_row_for_merge_rowset_v2(RowCursor** row
     if (!_merge_heap.empty()) {
         AlphaMergeContext* merge_ctx = _merge_heap.top();
         *row = merge_ctx->row_cursor.get();
-        _merge_heap.pop();
-        
-        RETURN_NOT_OK(_update_merge_ctx_and_build_merge_heap(merge_ctx));
+        // Must not rebuild merge_heap in this place.
+        // Because row have not been copied and is a pointer.
+        // If rebuild merge_heap, content in row will be modified.
         return OLAP_SUCCESS;
     } else {
         // all rows are read


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to