Skip to content

Commit 1c43cd3

Browse files
authored
Merge branch 'master' into feature-explode-json-object
2 parents 34058b9 + 27152b2 commit 1c43cd3

File tree

432 files changed

+16565
-4155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

432 files changed

+16565
-4155
lines changed

be/src/cloud/cloud_meta_mgr.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,12 @@ Status CloudMetaMgr::abort_txn(const StreamLoadContext& ctx) {
839839
if (ctx.db_id > 0 && !ctx.label.empty()) {
840840
req.set_db_id(ctx.db_id);
841841
req.set_label(ctx.label);
842-
} else {
842+
} else if (ctx.txn_id > 0) {
843843
req.set_txn_id(ctx.txn_id);
844+
} else {
845+
LOG(WARNING) << "failed abort txn, with illegal input, db_id=" << ctx.db_id
846+
<< " txn_id=" << ctx.txn_id << " label=" << ctx.label;
847+
return Status::InternalError<false>("failed to abort txn");
844848
}
845849
return retry_rpc("abort txn", req, &res, &MetaService_Stub::abort_txn);
846850
}

be/src/cloud/cloud_stream_load_executor.cpp

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626

2727
namespace doris {
2828

29+
enum class TxnOpParamType : int {
30+
ILLEGAL,
31+
WITH_TXN_ID,
32+
WITH_LABEL,
33+
};
34+
2935
CloudStreamLoadExecutor::CloudStreamLoadExecutor(ExecEnv* exec_env)
3036
: StreamLoadExecutor(exec_env) {}
3137

@@ -42,13 +48,48 @@ Status CloudStreamLoadExecutor::pre_commit_txn(StreamLoadContext* ctx) {
4248
}
4349

4450
Status CloudStreamLoadExecutor::operate_txn_2pc(StreamLoadContext* ctx) {
45-
VLOG_DEBUG << "operate_txn_2pc, op: " << ctx->txn_operation;
51+
std::stringstream ss;
52+
ss << "db_id=" << ctx->db_id << " txn_id=" << ctx->txn_id << " label=" << ctx->label
53+
<< " txn_2pc_op=" << ctx->txn_operation;
54+
std::string op_info = ss.str();
55+
VLOG_DEBUG << "operate_txn_2pc " << op_info;
56+
TxnOpParamType topt = ctx->txn_id > 0 ? TxnOpParamType::WITH_TXN_ID
57+
: !ctx->label.empty() ? TxnOpParamType::WITH_LABEL
58+
: TxnOpParamType::ILLEGAL;
59+
60+
Status st = Status::InternalError<false>("impossible branch reached, " + op_info);
61+
4662
if (ctx->txn_operation.compare("commit") == 0) {
47-
return _exec_env->storage_engine().to_cloud().meta_mgr().commit_txn(*ctx, true);
63+
if (topt == TxnOpParamType::WITH_TXN_ID) {
64+
VLOG_DEBUG << "2pc commit stream load txn directly: " << op_info;
65+
st = _exec_env->storage_engine().to_cloud().meta_mgr().commit_txn(*ctx, true);
66+
} else if (topt == TxnOpParamType::WITH_LABEL) {
67+
VLOG_DEBUG << "2pc commit stream load txn with FE support: " << op_info;
68+
st = StreamLoadExecutor::operate_txn_2pc(ctx);
69+
} else {
70+
st = Status::InternalError<false>(
71+
"failed to 2pc commit txn, with TxnOpParamType::illegal input, " + op_info);
72+
}
73+
} else if (ctx->txn_operation.compare("abort") == 0) {
74+
if (topt == TxnOpParamType::WITH_TXN_ID) {
75+
LOG(INFO) << "2pc abort stream load txn directly: " << op_info;
76+
st = _exec_env->storage_engine().to_cloud().meta_mgr().abort_txn(*ctx);
77+
WARN_IF_ERROR(st, "failed to rollback txn " + op_info);
78+
} else if (topt == TxnOpParamType::WITH_LABEL) { // maybe a label send to FE to abort
79+
VLOG_DEBUG << "2pc abort stream load txn with FE support: " << op_info;
80+
StreamLoadExecutor::rollback_txn(ctx);
81+
st = Status::OK();
82+
} else {
83+
st = Status::InternalError<false>("failed abort txn, with illegal input, " + op_info);
84+
}
4885
} else {
49-
// 2pc abort
50-
return _exec_env->storage_engine().to_cloud().meta_mgr().abort_txn(*ctx);
86+
std::string msg =
87+
"failed to operate_txn_2pc, unrecognized operation: " + ctx->txn_operation;
88+
LOG(WARNING) << msg << " " << op_info;
89+
st = Status::InternalError<false>(msg + " " + op_info);
5190
}
91+
WARN_IF_ERROR(st, "failed to operate_txn_2pc " + op_info)
92+
return st;
5293
}
5394

5495
Status CloudStreamLoadExecutor::commit_txn(StreamLoadContext* ctx) {
@@ -85,8 +126,24 @@ Status CloudStreamLoadExecutor::commit_txn(StreamLoadContext* ctx) {
85126
}
86127

87128
void CloudStreamLoadExecutor::rollback_txn(StreamLoadContext* ctx) {
88-
WARN_IF_ERROR(_exec_env->storage_engine().to_cloud().meta_mgr().abort_txn(*ctx),
89-
"Failed to rollback txn");
129+
std::stringstream ss;
130+
ss << "db_id=" << ctx->db_id << " txn_id=" << ctx->txn_id << " label=" << ctx->label;
131+
std::string op_info = ss.str();
132+
LOG(INFO) << "rollback stream laod txn " << op_info;
133+
TxnOpParamType topt = ctx->txn_id > 0 ? TxnOpParamType::WITH_TXN_ID
134+
: !ctx->label.empty() ? TxnOpParamType::WITH_LABEL
135+
: TxnOpParamType::ILLEGAL;
136+
137+
if (topt == TxnOpParamType::WITH_TXN_ID) {
138+
VLOG_DEBUG << "abort stream load txn directly: " << op_info;
139+
WARN_IF_ERROR(_exec_env->storage_engine().to_cloud().meta_mgr().abort_txn(*ctx),
140+
"failed to rollback txn " + op_info);
141+
} else { // maybe a label send to FE to abort
142+
// does not care about the return status
143+
// ctx->db_id > 0 && !ctx->label.empty()
144+
VLOG_DEBUG << "abort stream load txn with FE support: " << op_info;
145+
StreamLoadExecutor::rollback_txn(ctx);
146+
}
90147
}
91148

92149
} // namespace doris

be/src/common/config.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ DEFINE_mBool(enable_stacktrace_in_allocator_check_failed, "false");
139139

140140
DEFINE_mInt64(large_memory_check_bytes, "2147483648");
141141

142-
DEFINE_mBool(enable_memory_orphan_check, "true");
142+
DEFINE_mBool(enable_memory_orphan_check, "false");
143143

144144
// The maximum time a thread waits for full GC. Currently only query will wait for full gc.
145145
DEFINE_mInt32(thread_wait_gc_max_milliseconds, "1000");
@@ -1068,7 +1068,7 @@ DEFINE_mInt32(schema_cache_sweep_time_sec, "100");
10681068

10691069
// max number of segment cache, default -1 for backward compatibility fd_number*2/5
10701070
DEFINE_mInt32(segment_cache_capacity, "-1");
1071-
DEFINE_mInt32(estimated_num_columns_per_segment, "30");
1071+
DEFINE_mInt32(estimated_num_columns_per_segment, "200");
10721072
DEFINE_mInt32(estimated_mem_per_column_reader, "1024");
10731073
// The value is calculate by storage_page_cache_limit * index_page_cache_percentage
10741074
DEFINE_mInt32(segment_cache_memory_percentage, "2");
@@ -1313,6 +1313,11 @@ DEFINE_Bool(enable_file_logger, "true");
13131313
// The minimum row group size when exporting Parquet files. default 128MB
13141314
DEFINE_Int64(min_row_group_size, "134217728");
13151315

1316+
// If set to false, the parquet reader will not use page index to filter data.
1317+
// This is only for debug purpose, in case sometimes the page index
1318+
// filter wrong data.
1319+
DEFINE_mBool(enable_parquet_page_index, "true");
1320+
13161321
// clang-format off
13171322
#ifdef BE_TEST
13181323
// test s3

be/src/common/config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,8 @@ DECLARE_Bool(enable_file_logger);
13991399
// The minimum row group size when exporting Parquet files.
14001400
DECLARE_Int64(min_row_group_size);
14011401

1402+
DECLARE_mBool(enable_parquet_page_index);
1403+
14021404
#ifdef BE_TEST
14031405
// test s3
14041406
DECLARE_String(test_s3_resource);

be/src/olap/lru_cache.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace doris {
2222

2323
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(cache_capacity, MetricUnit::BYTES);
2424
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(cache_usage, MetricUnit::BYTES);
25+
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(cache_element_count, MetricUnit::NOUNIT);
2526
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(cache_usage_ratio, MetricUnit::NOUNIT);
2627
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(cache_lookup_count, MetricUnit::OPERATIONS);
2728
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(cache_hit_count, MetricUnit::OPERATIONS);
@@ -542,6 +543,7 @@ ShardedLRUCache::ShardedLRUCache(const std::string& name, size_t total_capacity,
542543
_entity->register_hook(name, std::bind(&ShardedLRUCache::update_cache_metrics, this));
543544
INT_GAUGE_METRIC_REGISTER(_entity, cache_capacity);
544545
INT_GAUGE_METRIC_REGISTER(_entity, cache_usage);
546+
INT_GAUGE_METRIC_REGISTER(_entity, cache_element_count);
545547
INT_DOUBLE_METRIC_REGISTER(_entity, cache_usage_ratio);
546548
INT_ATOMIC_COUNTER_METRIC_REGISTER(_entity, cache_lookup_count);
547549
INT_ATOMIC_COUNTER_METRIC_REGISTER(_entity, cache_hit_count);
@@ -640,15 +642,18 @@ void ShardedLRUCache::update_cache_metrics() const {
640642
size_t total_usage = 0;
641643
size_t total_lookup_count = 0;
642644
size_t total_hit_count = 0;
645+
size_t total_element_count = 0;
643646
for (int i = 0; i < _num_shards; i++) {
644647
total_capacity += _shards[i]->get_capacity();
645648
total_usage += _shards[i]->get_usage();
646649
total_lookup_count += _shards[i]->get_lookup_count();
647650
total_hit_count += _shards[i]->get_hit_count();
651+
total_element_count += _shards[i]->get_element_count();
648652
}
649653

650654
cache_capacity->set_value(total_capacity);
651655
cache_usage->set_value(total_usage);
656+
cache_element_count->set_value(total_element_count);
652657
cache_lookup_count->set_value(total_lookup_count);
653658
cache_hit_count->set_value(total_hit_count);
654659
cache_usage_ratio->set_value(total_capacity == 0 ? 0 : ((double)total_usage / total_capacity));

be/src/olap/lru_cache.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ enum LRUCacheType {
6060
};
6161

6262
static constexpr LRUCacheType DEFAULT_LRU_CACHE_TYPE = LRUCacheType::SIZE;
63-
static constexpr uint32_t DEFAULT_LRU_CACHE_NUM_SHARDS = 16;
63+
static constexpr uint32_t DEFAULT_LRU_CACHE_NUM_SHARDS = 32;
6464
static constexpr size_t DEFAULT_LRU_CACHE_ELEMENT_COUNT_CAPACITY = 0;
6565

6666
class CacheKey {
@@ -349,6 +349,7 @@ class LRUCache {
349349
uint64_t get_hit_count() const { return _hit_count; }
350350
size_t get_usage() const { return _usage; }
351351
size_t get_capacity() const { return _capacity; }
352+
size_t get_element_count() const { return _table.element_count(); }
352353

353354
private:
354355
void _lru_remove(LRUHandle* e);
@@ -433,6 +434,7 @@ class ShardedLRUCache : public Cache {
433434
std::shared_ptr<MetricEntity> _entity;
434435
IntGauge* cache_capacity = nullptr;
435436
IntGauge* cache_usage = nullptr;
437+
IntGauge* cache_element_count = nullptr;
436438
DoubleGauge* cache_usage_ratio = nullptr;
437439
IntAtomicCounter* cache_lookup_count = nullptr;
438440
IntAtomicCounter* cache_hit_count = nullptr;

be/src/olap/rowset/segment_v2/column_reader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Status ColumnReader::create_map(const ColumnReaderOptions& opts, const ColumnMet
128128
const io::FileReaderSPtr& file_reader,
129129
std::unique_ptr<ColumnReader>* reader) {
130130
// map reader now has 3 sub readers for key, value, offsets(scalar), null(scala)
131+
DCHECK(meta.children_columns_size() == 3 || meta.children_columns_size() == 4);
131132
std::unique_ptr<ColumnReader> key_reader;
132133
RETURN_IF_ERROR(ColumnReader::create(opts, meta.children_columns(0),
133134
meta.children_columns(0).num_rows(), file_reader,

be/src/olap/rowset/segment_v2/column_writer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ Status ColumnWriter::create_map_writer(const ColumnWriterOptions& opts, const Ta
206206
io::FileWriter* file_writer,
207207
std::unique_ptr<ColumnWriter>* writer) {
208208
DCHECK(column->get_subtype_count() == 2);
209+
if (column->get_subtype_count() < 2) {
210+
return Status::InternalError(
211+
"If you upgraded from version 1.2.*, please DROP the MAP columns and then "
212+
"ADD the MAP columns back.");
213+
}
209214
// create key & value writer
210215
std::vector<std::unique_ptr<ColumnWriter>> inner_writer_list;
211216
for (int i = 0; i < 2; ++i) {
@@ -1141,4 +1146,4 @@ Status MapColumnWriter::write_inverted_index() {
11411146
return Status::OK();
11421147
}
11431148

1144-
} // namespace doris::segment_v2
1149+
} // namespace doris::segment_v2

be/src/olap/segment_loader.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ class SegmentCache : public LRUCachePolicyTrackingManual {
8080
segment_v2::SegmentSharedPtr segment;
8181
};
8282

83-
SegmentCache(size_t capacity)
84-
: LRUCachePolicyTrackingManual(CachePolicy::CacheType::SEGMENT_CACHE, capacity,
85-
LRUCacheType::SIZE,
86-
config::tablet_rowset_stale_sweep_time_sec) {}
83+
SegmentCache(size_t memory_bytes_limit, size_t segment_num_limit)
84+
: LRUCachePolicyTrackingManual(CachePolicy::CacheType::SEGMENT_CACHE,
85+
memory_bytes_limit, LRUCacheType::SIZE,
86+
config::tablet_rowset_stale_sweep_time_sec,
87+
DEFAULT_LRU_CACHE_NUM_SHARDS * 2, segment_num_limit) {}
8788

8889
// Lookup the given segment in the cache.
8990
// If the segment is found, the cache entry will be written into handle.
@@ -110,7 +111,9 @@ class SegmentLoader {
110111
// After the estimation of segment memory usage is provided later, it is recommended
111112
// to use Memory as the capacity limit of the cache.
112113

113-
SegmentLoader(size_t capacity) { _segment_cache = std::make_unique<SegmentCache>(capacity); }
114+
SegmentLoader(size_t memory_limit_bytes, size_t segment_num_count) {
115+
_segment_cache = std::make_unique<SegmentCache>(memory_limit_bytes, segment_num_count);
116+
}
114117

115118
// Load segments of "rowset", return the "cache_handle" which contains segments.
116119
// If use_cache is true, it will be loaded from _cache.

be/src/olap/tablet_schema.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,8 @@ void TabletColumn::init_from_pb(const ColumnPB& column) {
553553
CHECK(column.children_columns_size() == 1) << "ARRAY type has more than 1 children types.";
554554
}
555555
if (_type == FieldType::OLAP_FIELD_TYPE_MAP) {
556-
CHECK(column.children_columns_size() == 2) << "MAP type has more than 2 children types.";
556+
DCHECK(column.children_columns_size() == 2) << "MAP type has more than 2 children types.";
557+
LOG(WARNING) << "MAP type has more than 2 children types.";
557558
}
558559
for (size_t i = 0; i < column.children_columns_size(); i++) {
559560
TabletColumn child_column;
@@ -623,7 +624,8 @@ void TabletColumn::to_schema_pb(ColumnPB* column) const {
623624
CHECK(_sub_columns.size() == 1) << "ARRAY type has more than 1 children types.";
624625
}
625626
if (_type == FieldType::OLAP_FIELD_TYPE_MAP) {
626-
CHECK(_sub_columns.size() == 2) << "MAP type has more than 2 children types.";
627+
DCHECK(_sub_columns.size() == 2) << "MAP type has more than 2 children types.";
628+
LOG(WARNING) << "MAP type has more than 2 children types.";
627629
}
628630

629631
for (size_t i = 0; i < _sub_columns.size(); i++) {

0 commit comments

Comments
 (0)