Skip to content

Commit

Permalink
[BugFix] BE crash when insert into table with rollup in ASAN build (S…
Browse files Browse the repository at this point in the history
…tarRocks#33964)

Signed-off-by: ricky <[email protected]>
Signed-off-by: Moonm3n <[email protected]>
  • Loading branch information
rickif authored and Moonm3n committed Oct 31, 2023
1 parent bba8c98 commit 0e4eeb8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion be/src/storage/delta_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ Status DeltaWriter::write(const Chunk& chunk, const uint32_t* indexes, uint32_t
_opt.tablet_id, _replica_state_name(_replica_state)));
}

if (!_mem_table->check_supported_column_partial_update(chunk)) {
if (_tablet->keys_type() == KeysType::PRIMARY_KEYS && !_mem_table->check_supported_column_partial_update(chunk)) {
return Status::InternalError(
fmt::format("can't partial update for column with row. tablet_id: {}", _opt.tablet_id));
}
Expand Down
29 changes: 16 additions & 13 deletions be/src/storage/memtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,24 @@ bool MemTable::insert(const Chunk& chunk, const uint32_t* indexes, uint32_t from
}

bool is_column_with_row = false;
std::unique_ptr<Schema> schema_without_full_row_column;
auto full_row_col = std::make_unique<BinaryColumn>();
if (_vectorized_schema->field_names().back() == "__row") {
DCHECK_EQ(chunk.num_columns(), _vectorized_schema->num_fields() - 1);
std::vector<ColumnId> cids(_vectorized_schema->num_fields() - 1);
for (int i = 0; i < _vectorized_schema->num_fields() - 1; i++) {
cids[i] = i;
if (_keys_type == PRIMARY_KEYS) {
std::unique_ptr<Schema> schema_without_full_row_column;
if (_vectorized_schema->field_names().back() == "__row") {
DCHECK_EQ(chunk.num_columns(), _vectorized_schema->num_fields() - 1);
std::vector<ColumnId> cids(_vectorized_schema->num_fields() - 1);
for (int i = 0; i < _vectorized_schema->num_fields() - 1; i++) {
cids[i] = i;
}
schema_without_full_row_column = std::make_unique<Schema>(const_cast<Schema*>(_vectorized_schema), cids);
is_column_with_row = true;
// add row column
auto row_encoder = RowStoreEncoderFactory::instance()->get_or_create_encoder(SIMPLE);
(void)row_encoder->encode_chunk_to_full_row_column(*schema_without_full_row_column, chunk,
full_row_col.get());
} else {
DCHECK_EQ(chunk.num_columns(), _vectorized_schema->num_fields());
}
schema_without_full_row_column = std::make_unique<Schema>(const_cast<Schema*>(_vectorized_schema), cids);
is_column_with_row = true;
// add row column
auto row_encoder = RowStoreEncoderFactory::instance()->get_or_create_encoder(SIMPLE);
(void)row_encoder->encode_chunk_to_full_row_column(*schema_without_full_row_column, chunk, full_row_col.get());
} else {
DCHECK_EQ(chunk.num_columns(), _vectorized_schema->num_fields());
}

size_t cur_row_count = _chunk->num_rows();
Expand Down

0 comments on commit 0e4eeb8

Please sign in to comment.