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

[fix](partial update) fix data correctness risk when load delete sign data into a table with sequence col #32574

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 7 additions & 5 deletions be/src/olap/rowset/segment_v2/segment_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,12 @@ Status SegmentWriter::append_block_with_partial_content(const vectorized::Block*
return st;
}

// if the delete sign is marked, it means that the value columns of the row
// will not be read. So we don't need to read the missing values from the previous rows.
// But we still need to mark the previous row on delete bitmap
if (have_delete_sign) {
// 1. if the delete sign is marked, it means that the value columns of the row will not
// be read. So we don't need to read the missing values from the previous rows.
// 2. the one exception is when there are sequence columns in the table, we need to read
// the sequence columns, otherwise it may cause the merge-on-read based compaction
// policy to produce incorrect results
if (have_delete_sign && !_tablet_schema->has_sequence_col()) {
has_default_or_nullable = true;
use_default_or_null_flag.emplace_back(true);
} else {
Expand Down Expand Up @@ -722,7 +724,7 @@ Status SegmentWriter::fill_missing_columns(vectorized::MutableColumns& mutable_f
(delete_sign_column_data != nullptr &&
delete_sign_column_data[read_index[idx + segment_start_pos]] != 0)) {
for (auto i = 0; i < cids_missing.size(); ++i) {
// if the column has default value, fiil it with default value
// if the column has default value, fill it with default value
// otherwise, if the column is nullable, fill it with null value
const auto& tablet_column = _tablet_schema->column(cids_missing[i]);
if (tablet_column.has_default_value()) {
Expand Down
12 changes: 7 additions & 5 deletions be/src/olap/rowset/segment_v2/vertical_segment_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,12 @@ Status VerticalSegmentWriter::_append_block_with_partial_content(RowsInBlock& da
return st;
}

// if the delete sign is marked, it means that the value columns of the row
// will not be read. So we don't need to read the missing values from the previous rows.
// But we still need to mark the previous row on delete bitmap
if (have_delete_sign) {
// 1. if the delete sign is marked, it means that the value columns of the row will not
// be read. So we don't need to read the missing values from the previous rows.
// 2. the one exception is when there are sequence columns in the table, we need to read
// the sequence columns, otherwise it may cause the merge-on-read based compaction
// policy to produce incorrect results
if (have_delete_sign && !_tablet_schema->has_sequence_col()) {
has_default_or_nullable = true;
use_default_or_null_flag.emplace_back(true);
} else {
Expand Down Expand Up @@ -648,7 +650,7 @@ Status VerticalSegmentWriter::_fill_missing_columns(
(delete_sign_column_data != nullptr &&
delete_sign_column_data[read_index[idx + segment_start_pos]] != 0)) {
for (auto i = 0; i < missing_cids.size(); ++i) {
// if the column has default value, fiil it with default value
// if the column has default value, fill it with default value
// otherwise, if the column is nullable, fill it with null value
const auto& tablet_column = _tablet_schema->column(missing_cids[i]);
if (tablet_column.has_default_value()) {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ suite("test_primary_key_partial_update_seq_col_delete", "p0") {
select * from ${tableName} order by id;
"""

sql "SET show_hidden_columns=true"

sql "sync"
qt_partial_update_without_seq_hidden_columns """
select * from ${tableName} order by id;
"""

sql "SET show_hidden_columns=false"
// provide the sequence column this time, should update according to the
// given sequence values
streamLoad {
Expand Down
Loading