Coverage Report

Created: 2025-05-09 16:48

/root/doris/be/src/olap/rowset/segcompaction.cpp
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "segcompaction.h"
19
20
#include <fmt/format.h>
21
#include <gen_cpp/olap_file.pb.h>
22
#include <limits.h>
23
24
#include <algorithm>
25
#include <atomic>
26
#include <condition_variable>
27
#include <filesystem>
28
#include <map>
29
#include <memory>
30
#include <mutex>
31
#include <sstream>
32
#include <string>
33
#include <utility>
34
35
#include "absl/strings/substitute.h"
36
#include "beta_rowset_writer.h"
37
#include "common/compiler_util.h" // IWYU pragma: keep
38
#include "common/logging.h"
39
#include "io/fs/file_system.h"
40
#include "io/fs/file_writer.h"
41
#include "io/io_common.h"
42
#include "olap/data_dir.h"
43
#include "olap/iterators.h"
44
#include "olap/merger.h"
45
#include "olap/olap_common.h"
46
#include "olap/olap_define.h"
47
#include "olap/rowset/beta_rowset.h"
48
#include "olap/rowset/rowset_meta.h"
49
#include "olap/rowset/rowset_writer_context.h"
50
#include "olap/rowset/segment_v2/inverted_index_cache.h"
51
#include "olap/rowset/segment_v2/inverted_index_desc.h"
52
#include "olap/rowset/segment_v2/segment.h"
53
#include "olap/rowset/segment_v2/segment_writer.h"
54
#include "olap/schema.h"
55
#include "olap/storage_engine.h"
56
#include "olap/tablet_reader.h"
57
#include "olap/tablet_schema.h"
58
#include "runtime/memory/global_memory_arbitrator.h"
59
#include "runtime/thread_context.h"
60
#include "util/debug_points.h"
61
#include "util/mem_info.h"
62
#include "util/time.h"
63
#include "vec/olap/vertical_block_reader.h"
64
#include "vec/olap/vertical_merge_iterator.h"
65
66
namespace doris {
67
#include "common/compile_check_begin.h"
68
using namespace ErrorCode;
69
70
805
SegcompactionWorker::SegcompactionWorker(BetaRowsetWriter* writer) : _writer(writer) {}
71
72
805
void SegcompactionWorker::init_mem_tracker(const RowsetWriterContext& rowset_writer_context) {
73
805
    _seg_compact_mem_tracker = MemTrackerLimiter::create_shared(
74
805
            MemTrackerLimiter::Type::COMPACTION,
75
805
            fmt::format("segcompaction-txnID_{}-loadID_{}-tabletID_{}-indexID_{}-"
76
805
                        "partitionID_{}-version_{}",
77
805
                        std::to_string(rowset_writer_context.txn_id),
78
805
                        print_id(rowset_writer_context.load_id),
79
805
                        std::to_string(rowset_writer_context.tablet_id),
80
805
                        std::to_string(rowset_writer_context.index_id),
81
805
                        std::to_string(rowset_writer_context.partition_id),
82
805
                        rowset_writer_context.version.to_string()));
83
805
}
84
85
Status SegcompactionWorker::_get_segcompaction_reader(
86
        SegCompactionCandidatesSharedPtr segments, TabletSharedPtr tablet,
87
        std::shared_ptr<Schema> schema, OlapReaderStatistics* stat,
88
        vectorized::RowSourcesBuffer& row_sources_buf, bool is_key,
89
        std::vector<uint32_t>& return_columns, std::vector<uint32_t>& key_group_cluster_key_idxes,
90
22
        std::unique_ptr<vectorized::VerticalBlockReader>* reader) {
91
22
    const auto& ctx = _writer->_context;
92
22
    bool record_rowids = need_convert_delete_bitmap() && is_key;
93
22
    StorageReadOptions read_options;
94
22
    read_options.stats = stat;
95
22
    read_options.use_page_cache = false;
96
22
    read_options.tablet_schema = ctx.tablet_schema;
97
22
    read_options.record_rowids = record_rowids;
98
22
    if (!tablet->tablet_schema()->cluster_key_uids().empty()) {
99
0
        DeleteBitmapPtr delete_bitmap = std::make_shared<DeleteBitmap>(tablet->tablet_id());
100
0
        RETURN_IF_ERROR(tablet->calc_delete_bitmap_between_segments(ctx.rowset_id, *segments,
101
0
                                                                    delete_bitmap));
102
0
        for (auto& seg_ptr : *segments) {
103
0
            auto d = delete_bitmap->get_agg(
104
0
                    {ctx.rowset_id, seg_ptr->id(), DeleteBitmap::TEMP_VERSION_COMMON});
105
0
            if (d->isEmpty()) {
106
0
                continue; // Empty delete bitmap for the segment
107
0
            }
108
0
            read_options.delete_bitmap.emplace(seg_ptr->id(), std::move(d));
109
0
        }
110
0
    }
111
22
    std::vector<std::unique_ptr<RowwiseIterator>> seg_iterators;
112
22
    std::map<uint32_t, uint32_t> segment_rows;
113
118
    for (auto& seg_ptr : *segments) {
114
118
        std::unique_ptr<RowwiseIterator> iter;
115
118
        auto s = seg_ptr->new_iterator(schema, read_options, &iter);
116
118
        if (!s.ok()) {
117
0
            return Status::Error<INIT_FAILED>("failed to create iterator[{}]: {}", seg_ptr->id(),
118
0
                                              s.to_string());
119
0
        }
120
118
        seg_iterators.push_back(std::move(iter));
121
118
        segment_rows.emplace(seg_ptr->id(), seg_ptr->num_rows());
122
118
    }
123
22
    if (record_rowids && _rowid_conversion != nullptr) {
124
4
        _rowid_conversion->reset_segment_map(segment_rows);
125
4
    }
126
127
22
    *reader = std::make_unique<vectorized::VerticalBlockReader>(&row_sources_buf);
128
129
22
    TabletReader::ReaderParams reader_params;
130
22
    reader_params.is_segcompaction = true;
131
22
    reader_params.segment_iters_ptr = &seg_iterators;
132
    // no reader_params.version shouldn't break segcompaction
133
22
    reader_params.tablet_schema = ctx.tablet_schema;
134
22
    reader_params.tablet = tablet;
135
22
    reader_params.return_columns = return_columns;
136
22
    reader_params.is_key_column_group = is_key;
137
22
    reader_params.use_page_cache = false;
138
22
    reader_params.record_rowids = record_rowids;
139
22
    reader_params.key_group_cluster_key_idxes = key_group_cluster_key_idxes;
140
22
    return (*reader)->init(reader_params, nullptr);
141
22
}
142
143
std::unique_ptr<segment_v2::SegmentWriter> SegcompactionWorker::_create_segcompaction_writer(
144
11
        uint32_t begin, uint32_t end) {
145
11
    Status status;
146
11
    std::unique_ptr<segment_v2::SegmentWriter> writer = nullptr;
147
11
    status = _create_segment_writer_for_segcompaction(&writer, begin, end);
148
11
    if (!status.ok() || writer == nullptr) {
149
0
        LOG(ERROR) << "failed to create segment writer for begin:" << begin << " end:" << end
150
0
                   << " status:" << status;
151
0
        return nullptr;
152
11
    } else {
153
11
        return writer;
154
11
    }
155
11
}
156
157
11
Status SegcompactionWorker::_delete_original_segments(uint32_t begin, uint32_t end) {
158
11
    DCHECK(_writer->rowset_meta()->is_local());
159
160
11
    const auto& fs = io::global_local_filesystem();
161
11
    auto ctx = _writer->_context;
162
11
    auto schema = ctx.tablet_schema;
163
164
70
    for (uint32_t i = begin; i <= end; ++i) {
165
59
        auto seg_path = local_segment_path(ctx.tablet_path, ctx.rowset_id.to_string(), i);
166
        // Even if an error is encountered, these files that have not been cleaned up
167
        // will be cleaned up by the GC background. So here we only print the error
168
        // message when we encounter an error.
169
59
        RETURN_NOT_OK_STATUS_WITH_WARN(fs->delete_file(seg_path),
170
59
                                       absl::Substitute("Failed to delete file=$0", seg_path));
171
59
        if (schema->has_inverted_index() &&
172
59
            schema->get_inverted_index_storage_format() >= InvertedIndexStorageFormatPB::V2) {
173
29
            auto idx_path = InvertedIndexDescriptor::get_index_file_path_v2(
174
29
                    InvertedIndexDescriptor::get_index_file_path_prefix(seg_path));
175
29
            VLOG_DEBUG << "segcompaction index. delete file " << idx_path;
176
29
            RETURN_NOT_OK_STATUS_WITH_WARN(fs->delete_file(idx_path),
177
29
                                           absl::Substitute("Failed to delete file=$0", idx_path));
178
29
        }
179
        // Delete inverted index files
180
207
        for (auto&& column : schema->columns()) {
181
207
            if (const auto* index_info = schema->inverted_index(*column); index_info != nullptr) {
182
58
                auto index_id = index_info->index_id();
183
58
                if (schema->get_inverted_index_storage_format() ==
184
58
                    InvertedIndexStorageFormatPB::V1) {
185
0
                    auto idx_path = InvertedIndexDescriptor::get_index_file_path_v1(
186
0
                            InvertedIndexDescriptor::get_index_file_path_prefix(seg_path), index_id,
187
0
                            index_info->get_index_suffix());
188
0
                    VLOG_DEBUG << "segcompaction index. delete file " << idx_path;
189
0
                    RETURN_NOT_OK_STATUS_WITH_WARN(
190
0
                            fs->delete_file(idx_path),
191
0
                            absl::Substitute("Failed to delete file=$0", idx_path));
192
0
                }
193
                // Erase the origin index file cache
194
58
                auto idx_file_cache_key = InvertedIndexDescriptor::get_index_file_cache_key(
195
58
                        InvertedIndexDescriptor::get_index_file_path_prefix(seg_path), index_id,
196
58
                        index_info->get_index_suffix());
197
58
                RETURN_IF_ERROR(InvertedIndexSearcherCache::instance()->erase(idx_file_cache_key));
198
58
            }
199
207
        }
200
59
    }
201
11
    return Status::OK();
202
11
}
203
204
Status SegcompactionWorker::_check_correctness(OlapReaderStatistics& reader_stat,
205
                                               Merger::Statistics& merger_stat, uint32_t begin,
206
11
                                               uint32_t end, bool is_mow_with_cluster_keys) {
207
11
    uint64_t raw_rows_read = reader_stat.raw_rows_read; /* total rows read before merge */
208
11
    uint64_t rows_del_by_bitmap = reader_stat.rows_del_by_bitmap;
209
11
    uint64_t sum_src_row = 0; /* sum of rows in each involved source segments */
210
11
    uint64_t filtered_rows = merger_stat.filtered_rows; /* rows filtered by del conditions */
211
11
    uint64_t output_rows = merger_stat.output_rows;     /* rows after merge */
212
11
    uint64_t merged_rows = merger_stat.merged_rows;     /* dup key merged by unique/agg */
213
214
11
    {
215
11
        std::lock_guard<std::mutex> lock(_writer->_segid_statistics_map_mutex);
216
70
        for (int i = begin; i <= end; ++i) {
217
59
            sum_src_row += _writer->_segid_statistics_map[i].row_num;
218
59
        }
219
11
    }
220
221
11
    DBUG_EXECUTE_IF("SegcompactionWorker._check_correctness_wrong_sum_src_row", { sum_src_row++; });
222
11
    uint64_t raw_rows = raw_rows_read;
223
11
    if (is_mow_with_cluster_keys) {
224
0
        raw_rows += rows_del_by_bitmap;
225
0
    }
226
11
    if (raw_rows != sum_src_row) {
227
0
        return Status::Error<CHECK_LINES_ERROR>(
228
0
                "segcompaction read row num does not match source. expect read row:{}, actual read "
229
0
                "row:{}(raw_rows_read: {}, rows_del_by_bitmap: {})",
230
0
                sum_src_row, raw_rows, raw_rows_read, rows_del_by_bitmap);
231
0
    }
232
233
11
    DBUG_EXECUTE_IF("SegcompactionWorker._check_correctness_wrong_merged_rows", { merged_rows++; });
234
11
    if ((output_rows + merged_rows) != raw_rows_read) {
235
0
        return Status::Error<CHECK_LINES_ERROR>(
236
0
                "segcompaction total row num does not match after merge. expect total row:{},  "
237
0
                "actual total row:{}, (output_rows:{},merged_rows:{})",
238
0
                raw_rows_read, output_rows + merged_rows, output_rows, merged_rows);
239
0
    }
240
11
    DBUG_EXECUTE_IF("SegcompactionWorker._check_correctness_wrong_filtered_rows",
241
11
                    { filtered_rows++; });
242
11
    if (filtered_rows != 0) {
243
0
        return Status::Error<CHECK_LINES_ERROR>(
244
0
                "segcompaction should not have filtered rows but actual filtered rows:{}",
245
0
                filtered_rows);
246
0
    }
247
11
    return Status::OK();
248
11
}
249
250
Status SegcompactionWorker::_create_segment_writer_for_segcompaction(
251
11
        std::unique_ptr<segment_v2::SegmentWriter>* writer, uint32_t begin, uint32_t end) {
252
11
    return _writer->create_segment_writer_for_segcompaction(writer, begin, end);
253
11
}
254
255
11
Status SegcompactionWorker::_do_compact_segments(SegCompactionCandidatesSharedPtr segments) {
256
11
    DCHECK(_seg_compact_mem_tracker != nullptr);
257
11
    SCOPED_ATTACH_TASK(_seg_compact_mem_tracker);
258
    /* throttle segcompaction task if memory depleted */
259
11
    if (GlobalMemoryArbitrator::is_exceed_soft_mem_limit(GB_EXCHANGE_BYTE)) {
260
0
        return Status::Error<FETCH_MEMORY_EXCEEDED>("skip segcompaction due to memory shortage");
261
0
    }
262
263
11
    uint32_t begin = (*(segments->begin()))->id();
264
11
    uint32_t end = (*(segments->end() - 1))->id();
265
11
    uint64_t begin_time = GetCurrentTimeMicros();
266
11
    uint64_t index_size = 0;
267
11
    uint64_t total_index_size = 0;
268
11
    auto ctx = _writer->_context;
269
270
11
    auto writer = _create_segcompaction_writer(begin, end);
271
11
    if (UNLIKELY(writer == nullptr)) {
272
0
        return Status::Error<SEGCOMPACTION_INIT_WRITER>("failed to get segcompaction writer");
273
0
    }
274
275
11
    DCHECK(ctx.tablet);
276
11
    auto tablet = std::static_pointer_cast<Tablet>(ctx.tablet);
277
11
    if (need_convert_delete_bitmap() && _rowid_conversion == nullptr) {
278
3
        _rowid_conversion = std::make_unique<SimpleRowIdConversion>(_writer->rowset_id());
279
3
    }
280
281
11
    std::vector<std::vector<uint32_t>> column_groups;
282
11
    std::vector<uint32_t> key_group_cluster_key_idxes;
283
11
    Merger::vertical_split_columns(*ctx.tablet_schema, &column_groups,
284
11
                                   &key_group_cluster_key_idxes);
285
11
    vectorized::RowSourcesBuffer row_sources_buf(tablet->tablet_id(), tablet->tablet_path(),
286
11
                                                 ReaderType::READER_SEGMENT_COMPACTION);
287
288
11
    KeyBoundsPB key_bounds;
289
11
    Merger::Statistics key_merger_stats;
290
11
    OlapReaderStatistics key_reader_stats;
291
    /* compact group one by one */
292
33
    for (auto i = 0; i < column_groups.size(); ++i) {
293
22
        VLOG_NOTICE << "row source size: " << row_sources_buf.total_size();
294
22
        bool is_key = (i == 0);
295
22
        std::vector<uint32_t> column_ids = column_groups[i];
296
297
22
        writer->clear();
298
22
        RETURN_IF_ERROR(writer->init(column_ids, is_key));
299
22
        auto schema = std::make_shared<Schema>(ctx.tablet_schema->columns(), column_ids);
300
22
        OlapReaderStatistics reader_stats;
301
22
        std::unique_ptr<vectorized::VerticalBlockReader> reader;
302
22
        auto s =
303
22
                _get_segcompaction_reader(segments, tablet, schema, &reader_stats, row_sources_buf,
304
22
                                          is_key, column_ids, key_group_cluster_key_idxes, &reader);
305
22
        if (UNLIKELY(reader == nullptr || !s.ok())) {
306
0
            return Status::Error<SEGCOMPACTION_INIT_READER>(
307
0
                    "failed to get segcompaction reader. err: {}", s.to_string());
308
0
        }
309
310
22
        Merger::Statistics merger_stats;
311
22
        RETURN_IF_ERROR(Merger::vertical_compact_one_group(
312
22
                tablet->tablet_id(), ReaderType::READER_SEGMENT_COMPACTION, *ctx.tablet_schema,
313
22
                is_key, column_ids, &row_sources_buf, *reader, *writer, &merger_stats, &index_size,
314
22
                key_bounds, _rowid_conversion.get()));
315
22
        total_index_size += index_size;
316
22
        if (is_key) {
317
11
            RETURN_IF_ERROR(row_sources_buf.flush());
318
11
            key_merger_stats = merger_stats;
319
11
            key_reader_stats = reader_stats;
320
11
        }
321
22
        RETURN_IF_ERROR(row_sources_buf.seek_to_begin());
322
22
    }
323
324
    /* check row num after merge/aggregation */
325
11
    bool is_mow_with_cluster_keys = !tablet->tablet_schema()->cluster_key_uids().empty();
326
11
    RETURN_NOT_OK_STATUS_WITH_WARN(_check_correctness(key_reader_stats, key_merger_stats, begin,
327
11
                                                      end, is_mow_with_cluster_keys),
328
11
                                   "check correctness failed");
329
11
    {
330
11
        std::lock_guard<std::mutex> lock(_writer->_segid_statistics_map_mutex);
331
11
        _writer->_clear_statistics_for_deleting_segments_unsafe(begin, end);
332
11
    }
333
11
    RETURN_IF_ERROR(
334
11
            _writer->flush_segment_writer_for_segcompaction(&writer, total_index_size, key_bounds));
335
336
11
    if (_file_writer != nullptr && _file_writer->state() != io::FileWriter::State::CLOSED) {
337
11
        RETURN_IF_ERROR(_file_writer->close());
338
11
    }
339
340
11
    RETURN_IF_ERROR(_delete_original_segments(begin, end));
341
11
    if (_rowid_conversion != nullptr) {
342
4
        convert_segment_delete_bitmap(ctx.mow_context->delete_bitmap, begin, end,
343
4
                                      _writer->_num_segcompacted);
344
4
    }
345
11
    RETURN_IF_ERROR(_writer->_rename_compacted_segments(begin, end));
346
11
    if (_inverted_index_file_writer != nullptr) {
347
7
        _inverted_index_file_writer.reset();
348
7
    }
349
11
    if (VLOG_DEBUG_IS_ON) {
350
0
        _writer->vlog_buffer.clear();
351
0
        for (const auto& entry : std::filesystem::directory_iterator(ctx.tablet_path)) {
352
0
            fmt::format_to(_writer->vlog_buffer, "[{}]", string(entry.path()));
353
0
        }
354
0
        VLOG_DEBUG << "tablet_id:" << ctx.tablet_id << " rowset_id:" << ctx.rowset_id
355
0
                   << "_segcompacted_point:" << _writer->_segcompacted_point
356
0
                   << " _num_segment:" << _writer->_num_segment
357
0
                   << " _num_segcompacted:" << _writer->_num_segcompacted
358
0
                   << " list directory:" << fmt::to_string(_writer->vlog_buffer);
359
0
    }
360
361
11
    _writer->_segcompacted_point += (end - begin + 1);
362
363
11
    uint64_t elapsed = GetCurrentTimeMicros() - begin_time;
364
11
    LOG(INFO) << "segcompaction completed. tablet_id:" << ctx.tablet_id
365
11
              << " rowset_id:" << ctx.rowset_id << " elapsed time:" << elapsed
366
11
              << "us. update segcompacted_point:" << _writer->_segcompacted_point
367
11
              << " segment num:" << segments->size() << " begin:" << begin << " end:" << end;
368
369
11
    return Status::OK();
370
11
}
371
372
11
void SegcompactionWorker::compact_segments(SegCompactionCandidatesSharedPtr segments) {
373
11
    Status status = Status::OK();
374
11
    if (_is_compacting_state_mutable.exchange(false)) {
375
11
        status = _do_compact_segments(segments);
376
11
    } else {
377
        // note: be aware that _writer maybe released when the task is cancelled
378
0
        LOG(INFO) << "segcompaction worker is cancelled, skipping segcompaction task";
379
0
        return;
380
0
    }
381
11
    if (!status.ok()) {
382
0
        int errcode = status.code();
383
0
        switch (errcode) {
384
0
        case FETCH_MEMORY_EXCEEDED:
385
0
        case SEGCOMPACTION_INIT_READER:
386
0
        case SEGCOMPACTION_INIT_WRITER:
387
0
            LOG(WARNING) << "segcompaction failed, try next time:" << status;
388
0
            break;
389
0
        default:
390
0
            auto ctx = _writer->_context;
391
0
            LOG(WARNING) << "segcompaction fatal, terminating the write job."
392
0
                         << " tablet_id:" << ctx.tablet_id << " rowset_id:" << ctx.rowset_id
393
0
                         << " status:" << status;
394
            // status will be checked by the next trigger of segcompaction or the final wait
395
0
            _writer->_segcompaction_status.store(ErrorCode::INTERNAL_ERROR);
396
0
        }
397
0
    }
398
11
    DCHECK_EQ(_writer->_is_doing_segcompaction, true);
399
11
    {
400
11
        std::lock_guard lk(_writer->_is_doing_segcompaction_lock);
401
11
        _writer->_is_doing_segcompaction = false;
402
11
        _writer->_segcompacting_cond.notify_all();
403
11
    }
404
11
    _is_compacting_state_mutable = true;
405
11
}
406
407
84
bool SegcompactionWorker::need_convert_delete_bitmap() {
408
84
    if (_writer == nullptr) {
409
0
        return false;
410
0
    }
411
84
    auto tablet = _writer->context().tablet;
412
84
    return tablet != nullptr && tablet->keys_type() == KeysType::UNIQUE_KEYS &&
413
84
           tablet->enable_unique_key_merge_on_write() &&
414
84
           tablet->tablet_schema()->has_sequence_col();
415
84
}
416
417
void SegcompactionWorker::convert_segment_delete_bitmap(DeleteBitmapPtr src_delete_bitmap,
418
22
                                                        uint32_t src_seg_id, uint32_t dest_seg_id) {
419
    // lazy init
420
22
    if (nullptr == _converted_delete_bitmap) {
421
1
        _converted_delete_bitmap = std::make_shared<DeleteBitmap>(_writer->context().tablet_id);
422
1
    }
423
22
    auto rowset_id = _writer->context().rowset_id;
424
22
    const auto* seg_map =
425
22
            src_delete_bitmap->get({rowset_id, src_seg_id, DeleteBitmap::TEMP_VERSION_COMMON});
426
22
    if (seg_map != nullptr) {
427
15
        _converted_delete_bitmap->set({rowset_id, dest_seg_id, DeleteBitmap::TEMP_VERSION_COMMON},
428
15
                                      *seg_map);
429
15
    }
430
22
}
431
432
void SegcompactionWorker::convert_segment_delete_bitmap(DeleteBitmapPtr src_delete_bitmap,
433
                                                        uint32_t src_begin, uint32_t src_end,
434
4
                                                        uint32_t dst_seg_id) {
435
    // lazy init
436
4
    if (nullptr == _converted_delete_bitmap) {
437
3
        _converted_delete_bitmap = std::make_shared<DeleteBitmap>(_writer->context().tablet_id);
438
3
    }
439
4
    auto rowset_id = _writer->context().rowset_id;
440
4
    RowLocation src(rowset_id, 0, 0);
441
34
    for (uint32_t seg_id = src_begin; seg_id <= src_end; seg_id++) {
442
30
        const auto* seg_map =
443
30
                src_delete_bitmap->get({rowset_id, seg_id, DeleteBitmap::TEMP_VERSION_COMMON});
444
30
        if (!seg_map) {
445
6
            continue;
446
6
        }
447
24
        src.segment_id = seg_id;
448
57.3k
        for (unsigned int row_id : *seg_map) {
449
57.3k
            src.row_id = row_id;
450
57.3k
            auto dst_row_id = _rowid_conversion->get(src);
451
57.3k
            if (dst_row_id < 0) {
452
5.23k
                continue;
453
5.23k
            }
454
52.1k
            _converted_delete_bitmap->add(
455
52.1k
                    {rowset_id, dst_seg_id, DeleteBitmap::TEMP_VERSION_COMMON}, dst_row_id);
456
52.1k
        }
457
24
    }
458
4
}
459
460
466
bool SegcompactionWorker::cancel() {
461
    // return true if the task is canncellable (actual compaction is not started)
462
    // return false when the task is not cancellable (it is in the middle of segcompaction)
463
466
    return _is_compacting_state_mutable.exchange(false);
464
466
}
465
466
#include "common/compile_check_end.h"
467
} // namespace doris