Skip to content

Commit 9216ca8

Browse files
committed
debug
1 parent 7975d1a commit 9216ca8

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

be/src/olap/compaction.cpp

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,18 @@ namespace {
9191
#include "common/compile_check_begin.h"
9292

9393
bool is_rowset_tidy(std::string& pre_max_key, bool& pre_rs_key_bounds_truncated,
94-
const RowsetSharedPtr& rhs) {
94+
const RowsetSharedPtr& rhs, int64_t tablet_id) {
9595
size_t min_tidy_size = config::ordered_data_compaction_min_segment_size;
9696
if (rhs->num_segments() == 0) {
97+
LOG(INFO) << "rowset is tidy for tablet=" << tablet_id
98+
<< ", rowset_id=" << rhs->rowset_id().to_string()
99+
<< ", reason: num_segments is 0";
97100
return true;
98101
}
99102
if (rhs->is_segments_overlapping()) {
103+
LOG(INFO) << "rowset is not tidy for tablet=" << tablet_id
104+
<< ", rowset_id=" << rhs->rowset_id().to_string()
105+
<< ", reason: segments are overlapping";
100106
return false;
101107
}
102108
// check segment size
@@ -106,21 +112,33 @@ bool is_rowset_tidy(std::string& pre_max_key, bool& pre_rs_key_bounds_truncated,
106112
for (auto segment_size : segments_size) {
107113
// is segment is too small, need to do compaction
108114
if (segment_size < min_tidy_size) {
115+
LOG(INFO) << "rowset is not tidy for tablet=" << tablet_id
116+
<< ", rowset_id=" << rhs->rowset_id().to_string() << ", reason: segment size "
117+
<< segment_size << " is less than min_tidy_size " << min_tidy_size;
109118
return false;
110119
}
111120
}
112121
std::string min_key;
113122
auto ret = rhs->first_key(&min_key);
114123
if (!ret) {
124+
LOG(INFO) << "rowset is not tidy for tablet=" << tablet_id
125+
<< ", rowset_id=" << rhs->rowset_id().to_string()
126+
<< ", reason: failed to get first_key";
115127
return false;
116128
}
117129
bool cur_rs_key_bounds_truncated {rhs->is_segments_key_bounds_truncated()};
118130
if (!Slice::lhs_is_strictly_less_than_rhs(Slice {pre_max_key}, pre_rs_key_bounds_truncated,
119131
Slice {min_key}, cur_rs_key_bounds_truncated)) {
132+
LOG(INFO)
133+
<< "rowset is not tidy for tablet=" << tablet_id
134+
<< ", rowset_id=" << rhs->rowset_id().to_string()
135+
<< ", reason: key range overlaps with previous rowset (pre_max_key >= cur_min_key)";
120136
return false;
121137
}
122138
CHECK(rhs->last_key(&pre_max_key));
123139
pre_rs_key_bounds_truncated = cur_rs_key_bounds_truncated;
140+
LOG(INFO) << "rowset is tidy for tablet=" << tablet_id
141+
<< ", rowset_id=" << rhs->rowset_id().to_string();
124142
return true;
125143
}
126144

@@ -428,20 +446,28 @@ Status CompactionMixin::build_basic_info(bool is_ordered_compaction) {
428446

429447
bool CompactionMixin::handle_ordered_data_compaction() {
430448
if (!config::enable_ordered_data_compaction) {
449+
LOG(INFO) << "skip ordered data compaction for tablet=" << _tablet->tablet_id()
450+
<< ", reason: enable_ordered_data_compaction config is disabled";
431451
return false;
432452
}
433453
if (compaction_type() == ReaderType::READER_COLD_DATA_COMPACTION ||
434454
compaction_type() == ReaderType::READER_FULL_COMPACTION) {
435455
// The remote file system and full compaction does not support to link files.
456+
LOG(INFO) << "skip ordered data compaction for tablet=" << _tablet->tablet_id()
457+
<< ", reason: compaction type is COLD_DATA or FULL_COMPACTION";
436458
return false;
437459
}
438460
if (_tablet->keys_type() == KeysType::UNIQUE_KEYS &&
439461
_tablet->enable_unique_key_merge_on_write()) {
462+
LOG(INFO) << "skip ordered data compaction for tablet=" << _tablet->tablet_id()
463+
<< ", reason: unique keys with merge-on-write enabled";
440464
return false;
441465
}
442466

443467
if (_tablet->tablet_meta()->tablet_schema()->skip_write_index_on_load()) {
444468
// Expected to create index through normal compaction
469+
LOG(INFO) << "skip ordered data compaction for tablet=" << _tablet->tablet_id()
470+
<< ", reason: skip_write_index_on_load is enabled";
445471
return false;
446472
}
447473

@@ -452,6 +478,9 @@ bool CompactionMixin::handle_ordered_data_compaction() {
452478
compaction_type() == ReaderType::READER_CUMULATIVE_COMPACTION)) {
453479
for (auto& rowset : _input_rowsets) {
454480
if (rowset->rowset_meta()->has_delete_predicate()) {
481+
LOG(INFO) << "skip ordered data compaction for tablet=" << _tablet->tablet_id()
482+
<< ", reason: rowset has delete predicate, rowset_id="
483+
<< rowset->rowset_id().to_string();
455484
return false;
456485
}
457486
}
@@ -463,8 +492,12 @@ bool CompactionMixin::handle_ordered_data_compaction() {
463492
std::string pre_max_key;
464493
bool pre_rs_key_bounds_truncated {false};
465494
for (auto i = 0; i < input_size; ++i) {
466-
if (!is_rowset_tidy(pre_max_key, pre_rs_key_bounds_truncated, _input_rowsets[i])) {
495+
if (!is_rowset_tidy(pre_max_key, pre_rs_key_bounds_truncated, _input_rowsets[i],
496+
_tablet->tablet_id())) {
467497
if (i <= input_size / 2) {
498+
LOG(INFO) << "skip ordered data compaction for tablet=" << _tablet->tablet_id()
499+
<< ", reason: rowsets are not tidy, untidy rowset at position " << i
500+
<< " out of " << input_size << " (less than half)";
468501
return false;
469502
} else {
470503
_input_rowsets.resize(i);
@@ -478,6 +511,11 @@ bool CompactionMixin::handle_ordered_data_compaction() {
478511
if (!st.ok()) {
479512
LOG(WARNING) << "failed to compact ordered rowsets: " << st;
480513
_pending_rs_guard.drop();
514+
LOG(INFO) << "skip ordered data compaction for tablet=" << _tablet->tablet_id()
515+
<< ", reason: do_compact_ordered_rowsets failed with status: " << st;
516+
} else {
517+
LOG(INFO) << "handle ordered data compaction success for tablet=" << _tablet->tablet_id()
518+
<< ", input_rowsets=" << _input_rowsets.size();
481519
}
482520

483521
return st.ok();

regression-test/suites/fault_injection_p0/test_ordered_compaction_num_seg_rows.groovy

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,23 @@ suite("test_ordered_compaction_num_seg_rows","nonConcurrent") {
2323
}
2424

2525
def custoBeConfig = [
26-
ordered_data_compaction_min_segment_size : 1
26+
ordered_data_compaction_min_segment_size : 1,
27+
enable_ordered_data_compaction: true
2728
]
2829
setBeConfigTemporary(custoBeConfig) {
30+
31+
String backend_id;
32+
def backendId_to_backendIP = [:]
33+
def backendId_to_backendHttpPort = [:]
34+
getBackendIpHttpPort(backendId_to_backendIP, backendId_to_backendHttpPort);
35+
36+
backend_id = backendId_to_backendIP.keySet()[0]
37+
def (code1, out1, err1) = show_be_config(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id))
38+
39+
logger.info("Show config: code=" + code1 + ", out=" + out1 + ", err=" + err1)
40+
assert code1 == 0
41+
42+
2943
def tableName = "test_ordered_compaction_num_seg_rows"
3044
sql """ DROP TABLE IF EXISTS ${tableName} """
3145
sql """

0 commit comments

Comments
 (0)