-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[fix](wal) Fix WAL replay loading 0 rows due to columns being marked as missing #62658
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,16 +41,16 @@ Status WalReader::init_reader(const TupleDescriptor* tuple_descriptor) { | |
|
|
||
| // ---- Unified init_reader(ReaderInitContext*) overrides ---- | ||
|
|
||
| Status WalReader::_open_file_reader(ReaderInitContext* /*ctx*/) { | ||
| Status WalReader::_open_file_reader(ReaderInitContext* ctx) { | ||
| auto* wal_ctx = checked_context_cast<WalInitContext>(ctx); | ||
| _tuple_descriptor = wal_ctx->output_tuple_descriptor; | ||
| RETURN_IF_ERROR(_state->exec_env()->wal_mgr()->get_wal_path(_wal_id, _wal_path)); | ||
| _wal_reader = std::make_shared<doris::WalFileReader>(_wal_path); | ||
| RETURN_IF_ERROR(_wal_reader->init()); | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| Status WalReader::_do_init_reader(ReaderInitContext* base_ctx) { | ||
| auto* ctx = checked_context_cast<WalInitContext>(base_ctx); | ||
| _tuple_descriptor = ctx->output_tuple_descriptor; | ||
| Status WalReader::_do_init_reader(ReaderInitContext* /*base_ctx*/) { | ||
| return Status::OK(); | ||
| } | ||
|
|
||
|
|
@@ -131,6 +131,14 @@ Status WalReader::_get_columns_impl(std::unordered_map<std::string, DataTypePtr> | |
| } catch (const std::invalid_argument& e) { | ||
| return Status::InvalidArgument("Invalid format, {}", e.what()); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a regression test for this path. This patch fixes the |
||
| // Report WAL columns so on_before_init_reader does not mark them as missing. | ||
| if (_tuple_descriptor) { | ||
| for (auto* slot_desc : _tuple_descriptor->slots()) { | ||
| if (_column_pos_map.contains(slot_desc->col_unique_id())) { | ||
| name_to_type->emplace(slot_desc->col_name(), slot_desc->get_data_type_ptr()); | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+134
to
+141
|
||
| return Status::OK(); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wal_ctx->output_tuple_descriptoris dereferenced later via_tuple_descriptor->slots()(both in_do_get_next_blockand in_get_columns_impl). If it is ever null, this will crash and/or silently reintroduce the “all columns missing” behavior. Please add an explicit validation here (return an error Status with a clear message) instead of relying on implicit invariants.