Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improvement](routine-load) add routine load rows check #25818

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion be/src/runtime/routine_load/data_consumer_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ Status KafkaDataConsumerGroup::start_all(std::shared_ptr<StreamLoadContext> ctx,
bool eos = false;
while (true) {
if (eos || left_time <= 0 || left_rows <= 0 || left_bytes <= 0) {
_rows = ctx->max_batch_rows - left_rows;
LOG(INFO) << "consumer group done: " << _grp_id
<< ". consume time(ms)=" << ctx->max_interval_s * 1000 - left_time
<< ", received rows=" << ctx->max_batch_rows - left_rows
<< ", received rows=" << _rows
<< ", received bytes=" << ctx->max_batch_size - left_bytes << ", eos: " << eos
<< ", left_time: " << left_time << ", left_rows: " << left_rows
<< ", left_bytes: " << left_bytes
Expand Down
11 changes: 10 additions & 1 deletion be/src/runtime/routine_load/data_consumer_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class DataConsumerGroup {
typedef std::function<void(const Status&)> ConsumeFinishCallback;

DataConsumerGroup()
: _grp_id(UniqueId::gen_uid()), _thread_pool(3, 10, "data_consumer"), _counter(0) {}
: _grp_id(UniqueId::gen_uid()),
_thread_pool(3, 10, "data_consumer"),
_counter(0),
_rows(0) {}

virtual ~DataConsumerGroup() { _consumers.clear(); }

Expand All @@ -60,6 +63,10 @@ class DataConsumerGroup {
++_counter;
}

int64_t get_consumer_rows() const { return _rows; }

void set_consumer_rows(int64_t rows) { _rows = rows; }

// start all consumers
virtual Status start_all(std::shared_ptr<StreamLoadContext> ctx,
std::shared_ptr<io::KafkaConsumerPipe> kafka_pipe) {
Expand All @@ -77,6 +84,8 @@ class DataConsumerGroup {
// when the counter becomes zero, shutdown the queue to finish
std::mutex _mutex;
int _counter;
// received total rows
int64_t _rows;
sollhui marked this conversation as resolved.
Show resolved Hide resolved
};

// for kafka
Expand Down
9 changes: 9 additions & 0 deletions be/src/runtime/routine_load/routine_load_task_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,15 @@ void RoutineLoadTaskExecutor::exec_task(std::shared_ptr<StreamLoadContext> ctx,
// wait for all consumers finished
HANDLE_ERROR(ctx->future.get(), "consume failed");

// check received and load rows
LOG(INFO) << "routine load task received rows: " << consumer_grp.get()->get_consumer_rows()
<< " load total rows: " << ctx.get()->number_total_rows
<< " loaded rows: " << ctx.get()->number_loaded_rows
<< " filtered rows: " << ctx.get()->number_filtered_rows
<< " unselected rows: " << ctx.get()->number_unselected_rows;
DCHECK(consumer_grp.get()->get_consumer_rows() == ctx.get()->number_total_rows);
consumer_grp.get()->set_consumer_rows(0);

ctx->load_cost_millis = UnixMillis() - ctx->start_millis;

// return the consumer back to pool
Expand Down
Loading