Skip to content

Commit ff37ab8

Browse files
dataroaringclaude
andcommitted
[feature](read-uncommitted) Add enable_uncommitted_rowset_registry config flag
Add mutable bool config `enable_uncommitted_rowset_registry` (default true) to control whether uncommitted rowsets are registered on BE. When disabled, the register calls in both local and cloud rowset builders are skipped, effectively turning off READ UNCOMMITTED visibility without restart. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d37bc8d commit ff37ab8

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

be/src/cloud/cloud_rowset_builder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "cloud/cloud_storage_engine.h"
2222
#include "cloud/cloud_tablet.h"
2323
#include "cloud/cloud_tablet_mgr.h"
24+
#include "common/config.h"
2425
#include "olap/storage_policy.h"
2526
#include "olap/uncommitted_rowset_registry.h"
2627

@@ -163,6 +164,9 @@ Status CloudRowsetBuilder::set_txn_related_delete_bitmap() {
163164
}
164165

165166
void CloudRowsetBuilder::register_uncommitted_rowset() {
167+
if (!config::enable_uncommitted_rowset_registry) {
168+
return;
169+
}
166170
auto* registry = _engine.uncommitted_rowset_registry();
167171
if (!registry || !_rowset) {
168172
return;

be/src/common/config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ DEFINE_mInt32(max_percentage_of_error_disk, "100");
373373
DEFINE_mInt32(default_num_rows_per_column_file_block, "1024");
374374
// pending data policy
375375
DEFINE_mInt32(pending_data_expire_time_sec, "1800");
376+
// Enable tracking uncommitted rowsets for READ UNCOMMITTED isolation level
377+
DEFINE_mBool(enable_uncommitted_rowset_registry, "true");
376378
// Expiration time for uncommitted rowsets tracked by READ UNCOMMITTED
377379
DEFINE_mInt32(uncommitted_rowset_expire_sec, "30");
378380
// inc_rowset snapshot rs sweep time interval

be/src/common/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ DECLARE_mInt32(max_percentage_of_error_disk);
414414
DECLARE_mInt32(default_num_rows_per_column_file_block);
415415
// pending data policy
416416
DECLARE_mInt32(pending_data_expire_time_sec);
417+
// Enable tracking uncommitted rowsets for READ UNCOMMITTED isolation level.
418+
// When false, register/unregister of uncommitted rowsets is skipped.
419+
DECLARE_mBool(enable_uncommitted_rowset_registry);
417420
// Expiration time for uncommitted rowsets tracked by READ UNCOMMITTED
418421
DECLARE_mInt32(uncommitted_rowset_expire_sec);
419422
// inc_rowset snapshot rs sweep time interval

be/src/olap/rowset_builder.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,19 @@ Status RowsetBuilder::commit_txn() {
350350

351351
// Register uncommitted rowset for READ UNCOMMITTED visibility.
352352
// For MoW tablets, capture the already-computed delete bitmap.
353-
if (auto* registry = _engine.uncommitted_rowset_registry()) {
354-
auto entry = std::make_shared<UncommittedRowsetEntry>();
355-
entry->rowset = _rowset;
356-
entry->transaction_id = _req.txn_id;
357-
entry->partition_id = _req.partition_id;
358-
entry->tablet_id = tablet()->tablet_id();
359-
entry->unique_key_merge_on_write = _tablet->enable_unique_key_merge_on_write();
360-
if (entry->unique_key_merge_on_write && _delete_bitmap) {
361-
entry->committed_delete_bitmap = std::make_shared<DeleteBitmap>(*_delete_bitmap);
353+
if (config::enable_uncommitted_rowset_registry) {
354+
if (auto* registry = _engine.uncommitted_rowset_registry()) {
355+
auto entry = std::make_shared<UncommittedRowsetEntry>();
356+
entry->rowset = _rowset;
357+
entry->transaction_id = _req.txn_id;
358+
entry->partition_id = _req.partition_id;
359+
entry->tablet_id = tablet()->tablet_id();
360+
entry->unique_key_merge_on_write = _tablet->enable_unique_key_merge_on_write();
361+
if (entry->unique_key_merge_on_write && _delete_bitmap) {
362+
entry->committed_delete_bitmap = std::make_shared<DeleteBitmap>(*_delete_bitmap);
363+
}
364+
registry->register_rowset(std::move(entry));
362365
}
363-
registry->register_rowset(std::move(entry));
364366
}
365367

366368
_is_committed = true;

0 commit comments

Comments
 (0)