Skip to content

Commit e686da6

Browse files
obdevfootkagaopy3
authored andcommitted
[CP] Patch DDL optimization
Co-authored-by: footka <672528926@qq.com> Co-authored-by: gaopy3 <gao.panyu@qq.com>
1 parent e4fe183 commit e686da6

102 files changed

Lines changed: 8189 additions & 3793 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

deps/oblib/src/lib/mysqlclient/ob_mysql_proxy.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
using namespace oceanbase::common;
2424
using namespace oceanbase::common::sqlclient;
2525

26-
OB_SERIALIZE_MEMBER(ObSessionDDLInfo, ddl_info_);
26+
OB_SERIALIZE_MEMBER(ObSessionDDLInfo, ddl_info_.ddl_info_, // FARM COMPAT WHITELIST
27+
session_id_);
2728

2829
ObCommonSqlProxy::ObCommonSqlProxy() : pool_(NULL)
2930
{

deps/oblib/src/lib/mysqlclient/ob_mysql_proxy.h

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ class ObISQLConnection;
3232
class ObISQLConnectionPool;
3333
}
3434

35-
struct ObSessionDDLInfo final
35+
36+
struct InnerDDLInfo final
3637
{
3738
public:
38-
ObSessionDDLInfo()
39-
: is_ddl_(false), is_source_table_hidden_(false), is_dest_table_hidden_(false), is_heap_table_ddl_(false),
40-
is_ddl_check_default_value_bit_(false), is_mview_complete_refresh_(false), is_refreshing_mview_(false),
41-
is_retryable_ddl_(false), is_dummy_ddl_for_inner_visibility_(false), is_major_refreshing_mview_(false), reserved_bit_(0)
39+
InnerDDLInfo() : is_ddl_(false), is_source_table_hidden_(false), is_dest_table_hidden_(false), is_heap_table_ddl_(false),
40+
is_ddl_check_default_value_bit_(false), is_mview_complete_refresh_(false), is_refreshing_mview_(false),
41+
is_retryable_ddl_(false), is_dummy_ddl_for_inner_visibility_(false), is_major_refreshing_mview_(false), is_vec_tablet_rebuild_(false),
42+
is_partition_local_ddl_(false), reserved_bit_(0)
4243
{
4344
}
44-
~ObSessionDDLInfo() = default;
4545
void set_is_ddl(const bool is_ddl) { is_ddl_ = is_ddl; }
4646
bool is_ddl() const { return is_ddl_; }
4747
void set_source_table_hidden(const bool is_hidden) { is_source_table_hidden_ = is_hidden; }
@@ -62,6 +62,10 @@ struct ObSessionDDLInfo final
6262
bool is_dummy_ddl_for_inner_visibility() const { return is_dummy_ddl_for_inner_visibility_; }
6363
void set_major_refreshing_mview(const bool flag) { is_major_refreshing_mview_ = flag; }
6464
bool is_major_refreshing_mview() const { return is_major_refreshing_mview_; }
65+
void set_is_vec_tablet_rebuild(const bool flag) { is_vec_tablet_rebuild_ = flag; }
66+
bool is_vec_tablet_rebuild() const { return is_vec_tablet_rebuild_; }
67+
void set_is_partition_local_ddl(const bool flag) { is_partition_local_ddl_ = flag; }
68+
bool is_partition_local_ddl() const { return is_partition_local_ddl_; }
6569
inline void reset() { ddl_info_ = 0; }
6670
TO_STRING_KV(K_(ddl_info));
6771
OB_UNIS_VERSION(1);
@@ -74,8 +78,11 @@ struct ObSessionDDLInfo final
7478
static const int64_t IS_REFRESHING_MVIEW_BIT = 1;
7579
static const int64_t IS_RETRYABLE_DDL_BIT = 1;
7680
static const int64_t IS_DUMMY_DDL_FOR_INNER_VISIBILITY_BIT = 1;
81+
static const int64_t IS_VEC_TABLET_REBUILD_BIT = 1;
7782
static const int64_t IS_MAJOR_REFRESHING_MVIEW_BIT = 1;
78-
static const int64_t RESERVED_BIT = 64 - IS_DDL_BIT - 2 * IS_TABLE_HIDDEN_BIT - IS_HEAP_TABLE_DDL_BIT - IS_DDL_CHECK_DEFAULT_VALUE_BIT - IS_MVIEW_COMPLETE_REFRESH_BIT - IS_REFRESHING_MVIEW_BIT - IS_RETRYABLE_DDL_BIT - IS_DUMMY_DDL_FOR_INNER_VISIBILITY_BIT - IS_MAJOR_REFRESHING_MVIEW_BIT;
83+
static const int64_t IS_SEARCH_INDEX_DDL_BIT = 1;
84+
static const int64_t IS_PARTITION_LOCAL_DDL_BIT = 1;
85+
static const int64_t RESERVED_BIT = 64 - IS_DDL_BIT - 2 * IS_TABLE_HIDDEN_BIT - IS_HEAP_TABLE_DDL_BIT - IS_DDL_CHECK_DEFAULT_VALUE_BIT - IS_MVIEW_COMPLETE_REFRESH_BIT - IS_REFRESHING_MVIEW_BIT - IS_RETRYABLE_DDL_BIT - IS_DUMMY_DDL_FOR_INNER_VISIBILITY_BIT - IS_MAJOR_REFRESHING_MVIEW_BIT - IS_VEC_TABLET_REBUILD_BIT - IS_SEARCH_INDEX_DDL_BIT - IS_PARTITION_LOCAL_DDL_BIT;
7986
union {
8087
uint64_t ddl_info_;
8188
struct {
@@ -94,10 +101,62 @@ struct ObSessionDDLInfo final
94101
*/
95102
uint64_t is_dummy_ddl_for_inner_visibility_: IS_DUMMY_DDL_FOR_INNER_VISIBILITY_BIT;
96103
uint64_t is_major_refreshing_mview_ : IS_MAJOR_REFRESHING_MVIEW_BIT;
104+
uint64_t is_vec_tablet_rebuild_ : IS_VEC_TABLET_REBUILD_BIT;
105+
uint64_t is_search_index_ddl_ : IS_SEARCH_INDEX_DDL_BIT;
106+
uint64_t is_partition_local_ddl_ : IS_PARTITION_LOCAL_DDL_BIT;
97107
uint64_t reserved_bit_ : RESERVED_BIT;
98108
};
99109
};
100110
};
111+
struct ObSessionDDLInfo final
112+
{
113+
public:
114+
ObSessionDDLInfo()
115+
: ddl_info_(), session_id_(OB_INVALID_ID)
116+
{
117+
}
118+
~ObSessionDDLInfo() = default;
119+
inline int init (const InnerDDLInfo ddl_info,
120+
const uint64_t session_id) { ddl_info_ = ddl_info;
121+
session_id_ = session_id;
122+
return is_valid() ? OB_SUCCESS
123+
: OB_INVALID_ARGUMENT; }
124+
void set_is_ddl(const bool is_ddl) { ddl_info_.set_is_ddl(is_ddl); }
125+
void set_source_table_hidden(const bool is_hidden) { ddl_info_.set_source_table_hidden(is_hidden); }
126+
void set_dest_table_hidden(const bool is_hidden) { ddl_info_.set_dest_table_hidden(is_hidden); }
127+
void set_heap_table_ddl(const bool flag) { ddl_info_.set_heap_table_ddl(flag); }
128+
void set_ddl_check_default_value(const bool flag) { ddl_info_.set_ddl_check_default_value(flag); }
129+
void set_mview_complete_refresh(const bool flag) { ddl_info_.set_mview_complete_refresh(flag); }
130+
void set_refreshing_mview(const bool flag) { ddl_info_.set_refreshing_mview(flag); }
131+
void set_retryable_ddl(const bool flag) { ddl_info_.set_retryable_ddl(flag); }
132+
void set_is_dummy_ddl_for_inner_visibility(const bool flag) { ddl_info_.set_is_dummy_ddl_for_inner_visibility(flag); }
133+
void set_major_refreshing_mview(const bool flag) { ddl_info_.set_major_refreshing_mview(flag); }
134+
void set_is_vec_tablet_rebuild(const bool flag) { ddl_info_.set_is_vec_tablet_rebuild(flag); }
135+
void set_partition_local_ddl(const bool flag) { ddl_info_.set_is_partition_local_ddl(flag); }
136+
137+
bool is_ddl() const { return ddl_info_.is_ddl(); }
138+
bool is_source_table_hidden() const { return ddl_info_.is_source_table_hidden(); }
139+
bool is_dest_table_hidden() const { return ddl_info_.is_dest_table_hidden(); }
140+
bool is_heap_table_ddl() const { return ddl_info_.is_heap_table_ddl(); }
141+
bool is_ddl_check_default_value() const { return ddl_info_.is_ddl_check_default_value(); }
142+
bool is_mview_complete_refresh() const { return ddl_info_.is_mview_complete_refresh(); }
143+
bool is_refreshing_mview() const { return ddl_info_.is_refreshing_mview(); }
144+
bool is_retryable_ddl() const { return ddl_info_.is_retryable_ddl(); }
145+
bool is_dummy_ddl_for_inner_visibility() const { return ddl_info_.is_dummy_ddl_for_inner_visibility(); }
146+
bool is_major_refreshing_mview() const { return ddl_info_.is_major_refreshing_mview(); }
147+
bool is_vec_tablet_rebuild() const { return ddl_info_.is_vec_tablet_rebuild(); }
148+
bool is_partition_local_ddl() const { return ddl_info_.is_partition_local_ddl(); }
149+
inline uint64_t get_session_id() const { return session_id_;}
150+
inline void reset() { session_id_ = OB_INVALID_ID;
151+
ddl_info_.reset();}
152+
bool is_valid() { return !(is_ddl() && OB_INVALID_ID == session_id_); }
153+
InnerDDLInfo &get_inner_ddl_info() { return ddl_info_; }
154+
TO_STRING_KV(K_(ddl_info), K_(session_id));
155+
OB_UNIS_VERSION(1);
156+
private:
157+
InnerDDLInfo ddl_info_;
158+
uint64_t session_id_;
159+
};
101160

102161
struct ObSessionParam final
103162
{

deps/oblib/src/lib/ob_define.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,6 +2797,13 @@ OB_INLINE char* ob_get_origin_thread_name()
27972797
thread_local char ori_tname[oceanbase::OB_THREAD_NAME_BUF_LEN] = {0};
27982798
return ori_tname;
27992799
}
2800+
// used to control how to generate and get schema version
2801+
// relyed by ddl_helper
2802+
OB_INLINE bool& ob_batch_generate_schema_version()
2803+
{
2804+
thread_local bool batch_generate_schema_version = false;
2805+
return batch_generate_schema_version;
2806+
}
28002807

28012808
OB_INLINE char* ob_get_extended_thread_name()
28022809
{

deps/oblib/src/lib/ob_name_id_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ DEF_NAME(id, "id")
821821
DEF_NAME(generate_schemas, "generate_schemas")
822822
DEF_NAME(gen_task_id_and_versions, "gen_task_id_and_versions")
823823
DEF_NAME(create_schemas, "create_schemas")
824+
DEF_NAME(operate_schemas, "operate_schemas")
824825
DEF_NAME(create_tablets, "create_tablets")
825826
DEF_NAME(inc_schema_dict, "inc_schema_dict")
826827
DEF_NAME(wait_ddl_trans, "wait_ddl_trans")

deps/oblib/src/lib/stat/ob_latch_define.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LATCH_DEF_##enable(def, id, name, policy, max_spin_cnt, max_yield_cnt)
3333
#undef LATCH_DEF_true
3434
#undef LATCH_DEF_false
3535

36-
static_assert(ARRAYSIZEOF(OB_LATCHES) == 264, "DO NOT delete latch defination");
36+
static_assert(ARRAYSIZEOF(OB_LATCHES) == 265, "DO NOT delete latch defination");
3737
static_assert(ObLatchIds::LATCH_END == ARRAYSIZEOF(OB_LATCHES) - 1, "update id of LATCH_END before adding your defination");
3838

3939
}

deps/oblib/src/lib/stat/ob_latch_define.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ LATCH_DEF(STORAGE_CACHE_POLICY_MGR_LOCK, 353, "storage cache policy lock", LATCH
299299
LATCH_DEF(STORAGE_CACHE_POLICY_TASK_LOCK, 354, "storage cache policy task lock", LATCH_READ_PREFER, 2000, 0, true)
300300
LATCH_DEF(UNIQUE_CHECKING_CONTEXT_LOCK, 355, "unique checking context lock", LATCH_FIFO, 2000, 0, true)
301301
LATCH_DEF(TABLET_SPLIT_CONTEXT_LOCK, 356, "tablet split context lock", LATCH_FIFO, 2000, 0, true)
302-
303-
LATCH_DEF(LATCH_END, 357, "latch end", LATCH_FIFO, 2000, 0, true)
302+
LATCH_DEF(MAX_ID_CACHE_LOCK, 357, "max id cache", LATCH_FIFO, 2000, 0, true)
303+
LATCH_DEF(LATCH_END, 358, "latch end", LATCH_FIFO, 2000, 0, true)
304304

305305
#endif
306306

mittest/simple_server/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ ob_unittest_observer(test_all_virtual_proxy_partition_info_default_value rootser
123123
ob_unittest_observer(test_schema_service_sql_impl rootservice/test_schema_service_sql_impl.cpp)
124124
ob_unittest_observer(test_ob_parallel_migration_mode rootservice/test_ob_parallel_migration_mode.cpp)
125125
ob_unittest_observer(test_create_tenant_compare rootservice/test_create_tenant_compare.cpp)
126+
ob_unittest_observer(test_max_id_cache rootservice/test_max_id_cache.cpp)
126127
####### rootservice case #########
127128

128129

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/*
2+
* Copyright (c) 2025 OceanBase.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#define USING_LOG_PREFIX SHARE
18+
19+
#include <gtest/gtest.h>
20+
#include <gmock/gmock.h>
21+
#define private public
22+
#include "share/ob_max_id_cache.h"
23+
#include "rootserver/ob_root_service.h"
24+
#include "mittest/simple_server/env/ob_simple_cluster_test_base.h"
25+
#include "deps/oblib/src/common/ob_tablet_id.h"
26+
#include "share/ob_max_id_fetcher.h"
27+
28+
#define ASSERT_SUCCESS(x) ASSERT_EQ((x), OB_SUCCESS)
29+
30+
namespace oceanbase
31+
{
32+
namespace pl
33+
{
34+
int ObPLPackageManager::load_all_sys_package(common::ObMySQLProxy &sql_proxy)
35+
{
36+
return OB_SUCCESS;
37+
}
38+
}
39+
using namespace common;
40+
class TestMaxIdCache : public unittest::ObSimpleClusterTestBase
41+
{
42+
public:
43+
TestMaxIdCache() : unittest::ObSimpleClusterTestBase("test_max_id_cache") {}
44+
};
45+
// Test various max_id_cache interfaces.
46+
TEST_F(TestMaxIdCache, basic)
47+
{
48+
ASSERT_NE(GCTX.root_service_, nullptr);
49+
ASSERT_NE(GCTX.sql_proxy_, nullptr);
50+
while (!GCTX.root_service_->is_full_service()) {
51+
ob_usleep(1_s);
52+
}
53+
rootserver::ObSysStat sys_stat;
54+
ASSERT_SUCCESS(sys_stat.set_initial_values(OB_SYS_TENANT_ID));
55+
ObMaxIdFetcher id_fetcher(*GCTX.sql_proxy_);
56+
uint64_t id = OB_INVALID_ID;
57+
int64_t extended_tablet_init_id = sys_stat.ob_max_used_extended_rowid_table_tablet_id_.value_.get_int();
58+
uint64_t normal_tablet_init_id = sys_stat.ob_max_used_normal_rowid_table_tablet_id_.value_.get_int();
59+
uint64_t table_init_id = sys_stat.ob_max_used_object_id_.value_.get_int();
60+
61+
// This interface returns [id, id + size).
62+
id = OB_INVALID_ID;
63+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_EXTENDED_ROWID_TABLE_TABLET_ID_TYPE, id, 1));
64+
ASSERT_EQ(extended_tablet_init_id + 1, id);
65+
id = OB_INVALID_ID;
66+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_EXTENDED_ROWID_TABLE_TABLET_ID_TYPE, id, 2));
67+
ASSERT_EQ(extended_tablet_init_id + 2, id);
68+
id = OB_INVALID_ID;
69+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_EXTENDED_ROWID_TABLE_TABLET_ID_TYPE, id, 3));
70+
ASSERT_EQ(extended_tablet_init_id + 4, id);
71+
72+
// This interface returns [id, id + size).
73+
id = OB_INVALID_ID;
74+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_NORMAL_ROWID_TABLE_TABLET_ID_TYPE, id, 1));
75+
ASSERT_EQ(normal_tablet_init_id + 1, id);
76+
id = OB_INVALID_ID;
77+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_NORMAL_ROWID_TABLE_TABLET_ID_TYPE, id, 2));
78+
ASSERT_EQ(normal_tablet_init_id + 2, id);
79+
id = OB_INVALID_ID;
80+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_NORMAL_ROWID_TABLE_TABLET_ID_TYPE, id, 3));
81+
ASSERT_EQ(normal_tablet_init_id + 4, id);
82+
83+
// This interface returns (id - size, id].
84+
id = OB_INVALID_ID;
85+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_id(OB_SYS_TENANT_ID, OB_MAX_USED_TABLE_ID_TYPE, id, UINT64_MAX, 1));
86+
ASSERT_EQ(table_init_id + 1, id); // 1
87+
id = OB_INVALID_ID;
88+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_id(OB_SYS_TENANT_ID, OB_MAX_USED_TABLE_ID_TYPE, id, UINT64_MAX, 2));
89+
ASSERT_EQ(table_init_id + 3, id); // 2 3
90+
id = OB_INVALID_ID;
91+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_id(OB_SYS_TENANT_ID, OB_MAX_USED_TABLE_ID_TYPE, id, UINT64_MAX, 3));
92+
ASSERT_EQ(table_init_id + 6, id); // 4 5 6
93+
}
94+
95+
// Cached IDs are wasted after RS leader switch.
96+
TEST_F(TestMaxIdCache, rs_change)
97+
{
98+
ASSERT_NE(GCTX.root_service_, nullptr);
99+
ASSERT_SUCCESS(GCTX.root_service_->revoke_rs());
100+
while (!GCTX.root_service_->is_full_service()) {
101+
ob_usleep(1_s);
102+
}
103+
rootserver::ObSysStat sys_stat;
104+
ASSERT_SUCCESS(sys_stat.set_initial_values(OB_SYS_TENANT_ID));
105+
ObMaxIdFetcher id_fetcher(*GCTX.sql_proxy_);
106+
uint64_t id = OB_INVALID_ID;
107+
int64_t extended_tablet_init_id = sys_stat.ob_max_used_extended_rowid_table_tablet_id_.value_.get_int() + ObMaxIdCacheItem::CACHE_SIZE;
108+
uint64_t normal_tablet_init_id = sys_stat.ob_max_used_normal_rowid_table_tablet_id_.value_.get_int() + ObMaxIdCacheItem::CACHE_SIZE;
109+
uint64_t table_init_id = sys_stat.ob_max_used_object_id_.value_.get_int() + ObMaxIdCacheItem::CACHE_SIZE;
110+
111+
// This interface returns [id, id + size).
112+
id = OB_INVALID_ID;
113+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_EXTENDED_ROWID_TABLE_TABLET_ID_TYPE, id, 1));
114+
ASSERT_EQ(extended_tablet_init_id + 1, id);
115+
id = OB_INVALID_ID;
116+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_EXTENDED_ROWID_TABLE_TABLET_ID_TYPE, id, 2));
117+
ASSERT_EQ(extended_tablet_init_id + 2, id);
118+
id = OB_INVALID_ID;
119+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_EXTENDED_ROWID_TABLE_TABLET_ID_TYPE, id, 3));
120+
ASSERT_EQ(extended_tablet_init_id + 4, id);
121+
122+
// This interface returns [id, id + size).
123+
id = OB_INVALID_ID;
124+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_NORMAL_ROWID_TABLE_TABLET_ID_TYPE, id, 1));
125+
ASSERT_EQ(normal_tablet_init_id + 1, id);
126+
id = OB_INVALID_ID;
127+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_NORMAL_ROWID_TABLE_TABLET_ID_TYPE, id, 2));
128+
ASSERT_EQ(normal_tablet_init_id + 2, id);
129+
id = OB_INVALID_ID;
130+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_NORMAL_ROWID_TABLE_TABLET_ID_TYPE, id, 3));
131+
ASSERT_EQ(normal_tablet_init_id + 4, id);
132+
133+
// This interface returns (id - size, id].
134+
id = OB_INVALID_ID;
135+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_id(OB_SYS_TENANT_ID, OB_MAX_USED_TABLE_ID_TYPE, id, UINT64_MAX, 1));
136+
ASSERT_EQ(table_init_id + 1, id); // 1
137+
id = OB_INVALID_ID;
138+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_id(OB_SYS_TENANT_ID, OB_MAX_USED_TABLE_ID_TYPE, id, UINT64_MAX, 2));
139+
ASSERT_EQ(table_init_id + 3, id); // 2 3
140+
id = OB_INVALID_ID;
141+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_id(OB_SYS_TENANT_ID, OB_MAX_USED_TABLE_ID_TYPE, id, UINT64_MAX, 3));
142+
ASSERT_EQ(table_init_id + 6, id); // 4 5 6
143+
}
144+
145+
TEST_F(TestMaxIdCache, max_id)
146+
{
147+
ObMaxIdFetcher id_fetcher(*GCTX.sql_proxy_);
148+
uint64_t id = OB_INVALID_ID;
149+
ASSERT_NE(GCTX.root_service_, nullptr);
150+
ASSERT_NE(GCTX.sql_proxy_, nullptr);
151+
uint64_t current_id = OB_INVALID_ID;
152+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_EXTENDED_ROWID_TABLE_TABLET_ID_TYPE, current_id, 1));
153+
id = OB_INVALID_ID;
154+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_EXTENDED_ROWID_TABLE_TABLET_ID_TYPE,
155+
id, ObTabletID::MAX_USER_EXTENDED_ROWID_TABLE_TABLET_ID - 1 - current_id));
156+
id = OB_INVALID_ID;
157+
ASSERT_NE(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_EXTENDED_ROWID_TABLE_TABLET_ID_TYPE, current_id, 1),
158+
OB_SUCCESS) << current_id;
159+
160+
current_id = OB_INVALID_ID;
161+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_NORMAL_ROWID_TABLE_TABLET_ID_TYPE, current_id, 1));
162+
id = OB_INVALID_ID;
163+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_NORMAL_ROWID_TABLE_TABLET_ID_TYPE,
164+
id, ObTabletID::MAX_USER_NORMAL_ROWID_TABLE_TABLET_ID - 1 - current_id));
165+
id = OB_INVALID_ID;
166+
ASSERT_NE(id_fetcher.fetch_new_max_ids(OB_SYS_TENANT_ID, OB_MAX_USED_NORMAL_ROWID_TABLE_TABLET_ID_TYPE, current_id, 1),
167+
OB_SUCCESS) << current_id;
168+
169+
current_id = OB_INVALID_ID;
170+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_id(OB_SYS_TENANT_ID, OB_MAX_USED_TABLE_ID_TYPE, current_id, UINT64_MAX, 1));
171+
id = OB_INVALID_ID;
172+
ASSERT_SUCCESS(id_fetcher.fetch_new_max_id(OB_SYS_TENANT_ID, OB_MAX_USED_TABLE_ID_TYPE, id, UINT64_MAX, INT64_MAX - current_id));
173+
id = OB_INVALID_ID;
174+
ASSERT_NE(id_fetcher.fetch_new_max_id(OB_SYS_TENANT_ID, OB_MAX_USED_TABLE_ID_TYPE, current_id, UINT64_MAX, 1),
175+
OB_SUCCESS) << current_id;
176+
}
177+
}
178+
179+
int main(int argc, char **argv)
180+
{
181+
oceanbase::unittest::init_log_and_gtest(argc, argv);
182+
OB_LOGGER.set_log_level("INFO");
183+
::testing::InitGoogleTest(&argc, argv);
184+
return RUN_ALL_TESTS();
185+
}

src/observer/ob_srv_xlator_rootserver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ void oceanbase::observer::init_srv_xlator_for_rootserver(ObSrvRpcXlator *xlator)
8181
RPC_PROCESSOR(rootserver::ObRpcDropIndexOnFailedP, *gctx_.root_service_);
8282
RPC_PROCESSOR(rootserver::ObRpcCreateMLogP, *gctx_.root_service_);
8383
RPC_PROCESSOR(rootserver::ObRpcCreateTableLikeP, *gctx_.root_service_);
84+
RPC_PROCESSOR(rootserver::ObRpcParallelCreateTableLikeP, *gctx_.root_service_);
8485
RPC_PROCESSOR(rootserver::ObRpcRootMinorFreezeP, *gctx_.root_service_);
8586
RPC_PROCESSOR(rootserver::ObUpdateIndexTableStatusP, *gctx_.root_service_);
8687
RPC_PROCESSOR(rootserver::ObUpdateIndexStatusP, *gctx_.root_service_);

src/rootserver/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ ob_set_subtarget(ob_rootserver common
5858
ob_objpriv_mysql_ddl_operator.cpp
5959
ob_objpriv_mysql_ddl_service.cpp
6060
ob_objpriv_mysql_schema_history_recycler.cpp
61+
ob_create_index_on_empty_table_helper.cpp
6162
)
6263

6364
ob_set_subtarget(ob_rootserver ddl_task
@@ -92,6 +93,7 @@ ob_set_subtarget(ob_rootserver parallel_ddl
9293
parallel_ddl/ob_ddl_helper.cpp
9394
parallel_ddl/ob_create_table_helper.cpp
9495
parallel_ddl/ob_create_view_helper.cpp
96+
parallel_ddl/ob_create_materialized_view_helper.cpp
9597
parallel_ddl/ob_index_name_checker.cpp
9698
parallel_ddl/ob_set_comment_helper.cpp
9799
parallel_ddl/ob_create_index_helper.cpp
@@ -101,6 +103,8 @@ ob_set_subtarget(ob_rootserver parallel_ddl
101103
parallel_ddl/ob_set_kv_attribute_helper.cpp
102104
parallel_ddl/ob_create_tablegroup_helper.cpp
103105
parallel_ddl/ob_drop_tablegroup_helper.cpp
106+
parallel_ddl/ob_table_helper.cpp
107+
parallel_ddl/ob_create_table_like_helper.cpp
104108
)
105109

106110
ob_set_subtarget(ob_rootserver freeze

0 commit comments

Comments
 (0)