Skip to content

Commit 0964b6d

Browse files
branch-3.0: [Fix](Rowset Id) Use a randomly generated rowset ID to handle memory write failures #42949 (#43970)
Cherry-picked from #42949 Co-authored-by: abmdocrt <lianyukang@selectdb.com>
1 parent ae3f4fe commit 0964b6d

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

be/src/common/config.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,7 @@ DEFINE_mBool(enable_delete_bitmap_merge_on_compaction, "false");
13941394

13951395
// Enable validation to check the correctness of table size.
13961396
DEFINE_Bool(enable_table_size_correctness_check, "false");
1397+
DEFINE_Bool(force_regenerate_rowsetid_on_start_error, "false");
13971398

13981399
// clang-format off
13991400
#ifdef BE_TEST

be/src/common/config.h

+1
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,7 @@ DECLARE_mBool(enable_pipeline_task_leakage_detect);
14741474

14751475
// MB
14761476
DECLARE_Int32(query_cache_size);
1477+
DECLARE_Bool(force_regenerate_rowsetid_on_start_error);
14771478

14781479
DECLARE_mBool(enable_delete_bitmap_merge_on_compaction);
14791480

be/src/olap/olap_common.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <unordered_set>
3636
#include <utility>
3737

38+
#include "common/config.h"
3839
#include "io/io_common.h"
3940
#include "olap/olap_define.h"
4041
#include "olap/rowset/rowset_fwd.h"
@@ -394,6 +395,8 @@ using ColumnId = uint32_t;
394395
using UniqueIdSet = std::set<uint32_t>;
395396
// Column unique Id -> column id map
396397
using UniqueIdToColumnIdMap = std::map<ColumnId, ColumnId>;
398+
struct RowsetId;
399+
RowsetId next_rowset_id();
397400

398401
// 8 bit rowset id version
399402
// 56 bit, inc number from 1
@@ -412,7 +415,12 @@ struct RowsetId {
412415
auto [_, ec] = std::from_chars(rowset_id_str.data(),
413416
rowset_id_str.data() + rowset_id_str.length(), high);
414417
if (ec != std::errc {}) [[unlikely]] {
415-
LOG(FATAL) << "failed to init rowset id: " << rowset_id_str;
418+
if (config::force_regenerate_rowsetid_on_start_error) {
419+
LOG(WARNING) << "failed to init rowset id: " << rowset_id_str;
420+
high = next_rowset_id().hi;
421+
} else {
422+
LOG(FATAL) << "failed to init rowset id: " << rowset_id_str;
423+
}
416424
}
417425
init(1, high, 0, 0);
418426
} else {

be/src/olap/rowset/unique_rowset_id_generator.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@
1717

1818
#include "olap/rowset/unique_rowset_id_generator.h"
1919

20+
#include <atomic>
21+
22+
#include "olap/storage_engine.h"
23+
#include "runtime/exec_env.h"
24+
2025
namespace doris {
2126

27+
RowsetId next_rowset_id() {
28+
return ExecEnv::GetInstance()->storage_engine().next_rowset_id();
29+
}
30+
2231
UniqueRowsetIdGenerator::UniqueRowsetIdGenerator(const UniqueId& backend_uid)
2332
: _backend_uid(backend_uid), _inc_id(1) {}
2433

0 commit comments

Comments
 (0)