-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Feature] Partial support of TDE in non-cloud-native rowset read/write #52179
base: main
Are you sure you want to change the base?
Conversation
const auto schema = _context.tablet_schema; | ||
auto segment_writer = std::make_unique<SegmentWriter>(std::move(wfile), _num_segment, schema, _writer_options); | ||
RETURN_IF_ERROR(segment_writer->init(column_indexes, is_key)); | ||
DCHECK(_segment_encryption_metas.size() == _num_segment); | ||
_segment_encryption_metas.emplace_back(_writer_options.encryption_meta); | ||
++_num_segment; | ||
return std::move(segment_writer); | ||
} |
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.
The most risky bug in this code is:
A potential race condition involving multiple threads accessing and modifying _segment_encryption_metas
.
You can modify the code like this:
StatusOr<RowsetSharedPtr> RowsetWriter::build() {
std::lock_guard<std::mutex> l(_lock); // Protect access to _segment_encryption_metas
_rowset_meta_pb->set_empty(_num_rows_written == 0);
_rowset_meta_pb->set_creation_time(time(nullptr));
_rowset_meta_pb->set_num_segments(_num_segment);
DCHECK(_segment_encryption_metas.size() == _num_segment);
for (auto& encryption_meta : _segment_encryption_metas) {
_rowset_meta_pb->add_segment_encryption_metas(encryption_meta);
}
// additional relevant code...
}
// Add similar locking mechanisms where other concurrent accesses are made,
// such as during the invocations of _flush_segment,
// _flush_delete_file, _flush_update_file, _create_segment_writer, etc.
This adjustment ensures thread safety by using a mutex to guard accesses to shared resources that may be modified concurrently, which helps prevent race conditions.
1b0c031
to
6490d24
Compare
Signed-off-by: Binglin Chang <decstery@gmail.com>
Quality Gate passedIssues Measures |
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[BE Incremental Coverage Report]✅ pass : 105 / 131 (80.15%) file detail
|
What I'm doing:
Some code in rowset read/write to support TDE in non-cloud-native
Fixes: #46223
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: