[FEAT MERGE] Column Store Replica
Co-authored-by: LeonChaoHi <15201161716@163.com> Co-authored-by: zzg19950727 <1071026277@qq.com>
This commit is contained in:
parent
11d47a78ce
commit
81e39dc173
103
deps/oblib/src/common/ob_member.cpp
vendored
103
deps/oblib/src/common/ob_member.cpp
vendored
@ -86,6 +86,21 @@ void ObMember::reset_migrating()
|
||||
flag_ &= ~(1UL << MIGRATING_FLAG_BIT);
|
||||
}
|
||||
|
||||
bool ObMember::is_columnstore() const
|
||||
{
|
||||
return (flag_ >> COLUMNSTORE_FLAG_BIT) & 1U;
|
||||
}
|
||||
|
||||
void ObMember::set_columnstore()
|
||||
{
|
||||
flag_ |= (1UL << COLUMNSTORE_FLAG_BIT);
|
||||
}
|
||||
|
||||
void ObMember::reset_columnstore()
|
||||
{
|
||||
flag_ &= ~(1UL << COLUMNSTORE_FLAG_BIT);
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObMember, server_, timestamp_, flag_);
|
||||
|
||||
bool ObReplicaMember::is_readonly_replica() const
|
||||
@ -93,19 +108,63 @@ bool ObReplicaMember::is_readonly_replica() const
|
||||
return REPLICA_TYPE_READONLY == replica_type_;
|
||||
}
|
||||
|
||||
int ObReplicaMember::init(
|
||||
const common::ObAddr &server,
|
||||
const int64_t timestamp,
|
||||
const common::ObReplicaType replica_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
reset();
|
||||
if (OB_UNLIKELY(!server.is_valid()
|
||||
|| !ObReplicaTypeCheck::is_replica_type_valid(replica_type))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
COMMON_LOG(WARN, "invalid argument", K(ret), K(server), K(replica_type));
|
||||
} else {
|
||||
server_ = server;
|
||||
timestamp_ = timestamp;
|
||||
replica_type_ = replica_type;
|
||||
if (REPLICA_TYPE_COLUMNSTORE == replica_type) {
|
||||
ObMember::set_columnstore();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObReplicaMember::init(
|
||||
const ObMember &member,
|
||||
const common::ObReplicaType replica_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
reset();
|
||||
if (OB_UNLIKELY(!member.is_valid()
|
||||
|| !ObReplicaTypeCheck::is_replica_type_valid(replica_type))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
COMMON_LOG(WARN, "invalid argument", K(ret), K(member), K(replica_type));
|
||||
} else if (OB_FAIL(ObMember::assign(member))) {
|
||||
COMMON_LOG(WARN, "failed to assign member", K(ret), K(member));
|
||||
} else if (OB_FALSE_IT(replica_type_ = replica_type)) {
|
||||
// should never be here
|
||||
} else if (OB_UNLIKELY(! is_valid())) { // check flag_ and replica_type_ correct
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
COMMON_LOG(WARN, "invalid argument", K(ret), K(member), K(replica_type), KPC(this));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObReplicaMember::reset()
|
||||
{
|
||||
ObMember::reset();
|
||||
replica_type_ = REPLICA_TYPE_FULL;
|
||||
region_ = DEFAULT_REGION_NAME;
|
||||
memstore_percent_ = 100;
|
||||
}
|
||||
|
||||
bool ObReplicaMember::is_valid() const
|
||||
{
|
||||
// columnstore bit is 1 if and only if replica_type is C
|
||||
bool is_flag_valid = (is_columnstore() == (REPLICA_TYPE_COLUMNSTORE == replica_type_));
|
||||
return ObMember::is_valid()
|
||||
&& ObReplicaTypeCheck::is_replica_type_valid(replica_type_)
|
||||
&& !region_.is_empty()
|
||||
&& is_flag_valid
|
||||
&& memstore_percent_ <= 100
|
||||
&& memstore_percent_ >= 0;
|
||||
}
|
||||
@ -115,46 +174,6 @@ common::ObReplicaType ObReplicaMember::get_replica_type() const
|
||||
return replica_type_;
|
||||
}
|
||||
|
||||
int ObReplicaMember::set_replica_type(const common::ObReplicaType replica_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (!ObReplicaTypeCheck::is_replica_type_valid(replica_type)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
} else {
|
||||
replica_type_ = replica_type;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const common::ObRegion &ObReplicaMember::get_region() const
|
||||
{
|
||||
return region_;
|
||||
}
|
||||
|
||||
int ObReplicaMember::set_member(const ObMember &member)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
if (!member.is_valid()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
COMMON_LOG(WARN, "invalid args", K(ret), K(member));
|
||||
} else if (OB_FAIL(ObMember::assign(member))) {
|
||||
COMMON_LOG(WARN, "failed to assign member", K(ret), K(member));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObReplicaMember::set_region(const common::ObRegion ®ion)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (region.is_empty()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
} else {
|
||||
region_ = region;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ObReplicaMember &ObReplicaMember::operator=(const ObReplicaMember &rhs)
|
||||
{
|
||||
server_ = rhs.server_;
|
||||
|
68
deps/oblib/src/common/ob_member.h
vendored
68
deps/oblib/src/common/ob_member.h
vendored
@ -49,11 +49,16 @@ public:
|
||||
void set_migrating();
|
||||
void reset_migrating();
|
||||
|
||||
bool is_columnstore() const;
|
||||
void set_columnstore();
|
||||
void reset_columnstore();
|
||||
|
||||
TO_STRING_KV(K_(server), K_(timestamp), K_(flag));
|
||||
TO_YSON_KV(OB_Y_(server), OB_ID(t), timestamp_, OB_Y_(flag));
|
||||
OB_UNIS_VERSION(1);
|
||||
protected:
|
||||
static const int64_t MIGRATING_FLAG_BIT = 1;
|
||||
static const int64_t COLUMNSTORE_FLAG_BIT = 0;
|
||||
common::ObAddr server_;
|
||||
int64_t timestamp_;
|
||||
int64_t flag_;
|
||||
@ -90,61 +95,46 @@ inline int member_to_string(const common::ObMember &member, ObSqlString &member_
|
||||
class ObReplicaMember : public ObMember
|
||||
{
|
||||
public:
|
||||
// default constructor
|
||||
ObReplicaMember()
|
||||
: ObMember(),
|
||||
replica_type_(REPLICA_TYPE_FULL),
|
||||
region_(DEFAULT_REGION_NAME),
|
||||
memstore_percent_(100)
|
||||
{}
|
||||
// construct with only server and timestamp, when we don't know or care about replica_type
|
||||
// TODO(cangming.zl): remove this constructor when DRTask do not use it.
|
||||
ObReplicaMember(const common::ObAddr &server,
|
||||
const int64_t timestamp)
|
||||
: ObMember(server, timestamp),
|
||||
: ObMember(ObMember(server, timestamp)),
|
||||
replica_type_(REPLICA_TYPE_FULL),
|
||||
region_(DEFAULT_REGION_NAME),
|
||||
memstore_percent_(100)
|
||||
{}
|
||||
ObReplicaMember(const ObMember &member)
|
||||
: ObMember(member),
|
||||
replica_type_(REPLICA_TYPE_FULL),
|
||||
region_(DEFAULT_REGION_NAME),
|
||||
memstore_percent_(100)
|
||||
{}
|
||||
/* After the subsequent type conversion code is completed, remove the constructor */
|
||||
ObReplicaMember(const common::ObAddr &server,
|
||||
const int64_t timestamp,
|
||||
const common::ObReplicaType replica_type)
|
||||
: ObMember(server, timestamp),
|
||||
replica_type_(replica_type),
|
||||
region_(DEFAULT_REGION_NAME),
|
||||
memstore_percent_(100)
|
||||
{}
|
||||
// construct with server, timestamp and replica_type,
|
||||
// this func will set columnstore flag if replica_type is C.
|
||||
ObReplicaMember(const common::ObAddr &server,
|
||||
const int64_t timestamp,
|
||||
const common::ObReplicaType replica_type,
|
||||
const int64_t memstore_percent)
|
||||
: ObMember(server, timestamp),
|
||||
const int64_t memstore_percent = 100)
|
||||
: ObMember(ObMember(server, timestamp)),
|
||||
replica_type_(replica_type),
|
||||
region_(DEFAULT_REGION_NAME),
|
||||
memstore_percent_(memstore_percent)
|
||||
{}
|
||||
ObReplicaMember(const common::ObAddr &server,
|
||||
const int64_t timestamp,
|
||||
const common::ObReplicaType replica_type,
|
||||
const common::ObRegion ®ion,
|
||||
const int64_t memstore_percent)
|
||||
: ObMember(server, timestamp),
|
||||
replica_type_(replica_type),
|
||||
region_(region),
|
||||
memstore_percent_(memstore_percent)
|
||||
{}
|
||||
{
|
||||
if (REPLICA_TYPE_COLUMNSTORE == replica_type) {
|
||||
ObMember::set_columnstore();
|
||||
}
|
||||
}
|
||||
public:
|
||||
// init with server, timestamp, replica_type.
|
||||
// this func will set columnstore flag if replica_type is C.
|
||||
int init(const common::ObAddr &server,
|
||||
const int64_t timestamp,
|
||||
const common::ObReplicaType replica_type);
|
||||
// init with existing member whose flag_ may have been set.
|
||||
// this function will check whether flag_ is consistent with replica_type.
|
||||
int init(const ObMember &member,
|
||||
const common::ObReplicaType replica_type);
|
||||
common::ObReplicaType get_replica_type() const;
|
||||
int set_replica_type(const common::ObReplicaType replica_type);
|
||||
const common::ObRegion &get_region() const;
|
||||
int set_region(const common::ObRegion ®ion);
|
||||
int set_member(const ObMember &member);
|
||||
int64_t get_memstore_percent() const { return memstore_percent_; }
|
||||
void set_memstore_percent(const int64_t memstore_percent) { memstore_percent_ = memstore_percent; }
|
||||
virtual void reset();
|
||||
virtual bool is_valid() const;
|
||||
virtual bool is_readonly_replica() const;
|
||||
@ -154,8 +144,8 @@ public:
|
||||
OB_UNIS_VERSION(1);
|
||||
private:
|
||||
common::ObReplicaType replica_type_;
|
||||
common::ObRegion region_;
|
||||
int64_t memstore_percent_;
|
||||
int64_t memstore_percent_; // obsolate, only as placeholder
|
||||
common::ObRegion region_ = DEFAULT_REGION_NAME; // obsolate, only as placeholder
|
||||
};
|
||||
} // namespace common
|
||||
} // namespace oceanbase
|
||||
|
105
deps/oblib/src/lib/ob_define.h
vendored
105
deps/oblib/src/lib/ob_define.h
vendored
@ -2084,17 +2084,19 @@ enum ObFreezeStatus
|
||||
};
|
||||
|
||||
/*
|
||||
* |---- 2 bits ---|--- 4 bits ---|--- 2 bits ---|--- 2 bits ---| LSB
|
||||
* |-- encryption--|--- clog ---|-- SSStore ---|--- MemStore--| LSB
|
||||
* |---- 2 bits ---|---- 2 bits ---|--- 4 bits ---|--- 2 bits ---|--- 2 bits ---| LSB
|
||||
* |--column-store-|-- encryption--|--- clog ---|-- SSStore ---|--- MemStore--| LSB
|
||||
*/
|
||||
const int64_t MEMSTORE_BITS_SHIFT = 0;
|
||||
const int64_t SSSTORE_BITS_SHIFT = 2;
|
||||
const int64_t CLOG_BITS_SHIFT = 4;
|
||||
const int64_t ENCRYPTION_BITS_SHIFT = 8;
|
||||
const int64_t COLUMNSTORE_BITS_SHIFT = 10;
|
||||
const int64_t REPLICA_TYPE_MEMSTORE_MASK = (0x3UL << MEMSTORE_BITS_SHIFT);
|
||||
const int64_t REPLICA_TYPE_SSSTORE_MASK = (0x3UL << SSSTORE_BITS_SHIFT);
|
||||
const int64_t REPLICA_TYPE_CLOG_MASK = (0xFUL << CLOG_BITS_SHIFT);
|
||||
const int64_t REPLICA_TYPE_ENCRYPTION_MASK = (0x3UL << ENCRYPTION_BITS_SHIFT);
|
||||
const int64_t REPLICA_TYPE_COLUMNSTORE_MASK = (0x3UL << COLUMNSTORE_BITS_SHIFT);
|
||||
// replica type associated with memstore
|
||||
const int64_t WITH_MEMSTORE = 0;
|
||||
const int64_t WITHOUT_MEMSTORE = 1;
|
||||
@ -2107,16 +2109,22 @@ const int64_t ASYNC_CLOG = 1 << CLOG_BITS_SHIFT;
|
||||
// replica type associated with encryption
|
||||
const int64_t WITHOUT_ENCRYPTION = 0 << ENCRYPTION_BITS_SHIFT;
|
||||
const int64_t WITH_ENCRYPTION = 1 << ENCRYPTION_BITS_SHIFT;
|
||||
// replica type associated with columnstore
|
||||
const int64_t NOT_COLUMNSTORE = 0 << COLUMNSTORE_BITS_SHIFT;
|
||||
const int64_t COLUMNSTORE = 1 << COLUMNSTORE_BITS_SHIFT;
|
||||
|
||||
// tracepoint, refer to OB_MAX_CONFIG_xxx
|
||||
const int64_t OB_MAX_TRACEPOINT_NAME_LEN = 128;
|
||||
const int64_t OB_MAX_TRACEPOINT_DESCRIBE_LEN = 4096;
|
||||
|
||||
// Need to manually maintain the replica_type_to_str function in utility.cpp,
|
||||
// Currently there are only three types: REPLICA_TYPE_FULL, REPLICA_TYPE_READONLY, and REPLICA_TYPE_LOGONLY
|
||||
// Please modify the replica_type_to_string and string_to_replica_type function
|
||||
// in ob_share_util.cpp when adding new replica_type.
|
||||
enum ObReplicaType
|
||||
{
|
||||
// Almighty copy: is a member of paxos; has ssstore; has memstore
|
||||
// Invalid replica_type, value of which is -1.
|
||||
// Attention: Please DO use REPLICA_TYPE_INVALID as initial value. DO NOT use REPLICA_TYPE_MAX.
|
||||
REPLICA_TYPE_INVALID = -1,
|
||||
// Fully functional copy: is a member of paxos; has ssstore; has memstore
|
||||
REPLICA_TYPE_FULL = (SYNC_CLOG | WITH_SSSTORE | WITH_MEMSTORE), // 0
|
||||
// Backup copy: Paxos member; ssstore; no memstore
|
||||
REPLICA_TYPE_BACKUP = (SYNC_CLOG | WITH_SSSTORE | WITHOUT_MEMSTORE), // 1
|
||||
@ -2133,54 +2141,44 @@ enum ObReplicaType
|
||||
REPLICA_TYPE_ARBITRATION = (ASYNC_CLOG | WITHOUT_SSSTORE | WITHOUT_MEMSTORE), // 21
|
||||
// Encrypted log copy: encrypted; paxos member; no sstore; no memstore
|
||||
REPLICA_TYPE_ENCRYPTION_LOGONLY = (WITH_ENCRYPTION | SYNC_CLOG | WITHOUT_SSSTORE | WITHOUT_MEMSTORE), // 261
|
||||
// invalid value
|
||||
// Column-store copy: column-store, not a member of paxos; ssstore; memstore
|
||||
REPLICA_TYPE_COLUMNSTORE = (COLUMNSTORE | ASYNC_CLOG | WITH_SSSTORE | WITH_MEMSTORE), // 1040
|
||||
// max value
|
||||
REPLICA_TYPE_MAX,
|
||||
};
|
||||
|
||||
static inline int replica_type_to_string(const ObReplicaType replica_type, char *name_str, const int64_t str_len)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
switch(replica_type) {
|
||||
case REPLICA_TYPE_FULL: {
|
||||
strncpy(name_str ,"FULL", str_len);
|
||||
break;
|
||||
}
|
||||
case REPLICA_TYPE_BACKUP: {
|
||||
strncpy(name_str ,"BACKUP", str_len);
|
||||
break;
|
||||
}
|
||||
case REPLICA_TYPE_LOGONLY: {
|
||||
strncpy(name_str ,"LOGONLY", str_len);
|
||||
break;
|
||||
}
|
||||
case REPLICA_TYPE_READONLY: {
|
||||
strncpy(name_str ,"READONLY", str_len);
|
||||
break;
|
||||
}
|
||||
case REPLICA_TYPE_MEMONLY: {
|
||||
strncpy(name_str ,"MEMONLY", str_len);
|
||||
break;
|
||||
}
|
||||
case REPLICA_TYPE_ENCRYPTION_LOGONLY: {
|
||||
strncpy(name_str ,"ENCRYPTION_LOGONLY", str_len);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
strncpy(name_str ,"INVALID", str_len);
|
||||
break;
|
||||
} // default
|
||||
} // switch
|
||||
return ret;
|
||||
}
|
||||
// full replica
|
||||
const char *const FULL_REPLICA_STR = "FULL";
|
||||
const char *const F_REPLICA_STR = "F";
|
||||
// logonly replica
|
||||
const char *const LOGONLY_REPLICA_STR = "LOGONLY";
|
||||
const char *const L_REPLICA_STR = "L";
|
||||
// backup replica
|
||||
const char *const BACKUP_REPLICA_STR = "BACKUP";
|
||||
const char *const B_REPLICA_STR = "B";
|
||||
// readonly replica
|
||||
const char *const READONLY_REPLICA_STR = "READONLY";
|
||||
const char *const R_REPLICA_STR = "R";
|
||||
// memonly replica
|
||||
const char *const MEMONLY_REPLICA_STR = "MEMONLY";
|
||||
const char *const M_REPLICA_STR = "M";
|
||||
// encryption logonly replica
|
||||
const char *const ENCRYPTION_LOGONLY_REPLICA_STR = "ENCRYPTION_LOGONLY";
|
||||
const char *const E_REPLICA_STR = "E";
|
||||
// columnstore replica
|
||||
const char *const COLUMNSTORE_REPLICA_STR = "COLUMNSTORE";
|
||||
const char *const C_REPLICA_STR = "C";
|
||||
|
||||
class ObReplicaTypeCheck
|
||||
{
|
||||
public:
|
||||
// Currently only three types are valid,
|
||||
// including REPLICA_TYPE_FULL, REPLICA_TYPE_READONLY, and REPLICA_TYPE_COLUMNSTORE
|
||||
static bool is_replica_type_valid(const int32_t replica_type)
|
||||
{
|
||||
return REPLICA_TYPE_FULL == replica_type
|
||||
|| REPLICA_TYPE_READONLY == replica_type;
|
||||
|| REPLICA_TYPE_READONLY == replica_type
|
||||
|| REPLICA_TYPE_COLUMNSTORE == replica_type;
|
||||
}
|
||||
static bool is_can_elected_replica(const int32_t replica_type)
|
||||
{
|
||||
@ -2194,6 +2192,10 @@ public:
|
||||
{
|
||||
return (REPLICA_TYPE_READONLY == replica_type);
|
||||
}
|
||||
static bool is_columnstore_replica(const int32_t replica_type)
|
||||
{
|
||||
return (REPLICA_TYPE_COLUMNSTORE == replica_type);
|
||||
}
|
||||
static bool is_log_replica(const int32_t replica_type)
|
||||
{
|
||||
return (REPLICA_TYPE_LOGONLY == replica_type || REPLICA_TYPE_ENCRYPTION_LOGONLY == replica_type);
|
||||
@ -2208,13 +2210,18 @@ public:
|
||||
return (replica_type >= REPLICA_TYPE_FULL && replica_type <= REPLICA_TYPE_LOGONLY)
|
||||
|| (REPLICA_TYPE_ENCRYPTION_LOGONLY == replica_type);
|
||||
}
|
||||
static bool is_non_paxos_replica(const int32_t replica_type)
|
||||
{
|
||||
return (REPLICA_TYPE_READONLY == replica_type || REPLICA_TYPE_COLUMNSTORE == replica_type);
|
||||
}
|
||||
static bool is_writable_replica(const int32_t replica_type)
|
||||
{
|
||||
return (REPLICA_TYPE_FULL == replica_type);
|
||||
}
|
||||
static bool is_readable_replica(const int32_t replica_type)
|
||||
{
|
||||
return (REPLICA_TYPE_FULL == replica_type || REPLICA_TYPE_READONLY == replica_type);
|
||||
return (REPLICA_TYPE_FULL == replica_type || REPLICA_TYPE_READONLY == replica_type
|
||||
|| REPLICA_TYPE_COLUMNSTORE == replica_type);
|
||||
}
|
||||
static bool is_replica_with_memstore(const ObReplicaType replica_type)
|
||||
{
|
||||
@ -2228,15 +2235,11 @@ public:
|
||||
{
|
||||
return (REPLICA_TYPE_FULL == replica_type || REPLICA_TYPE_READONLY == replica_type);
|
||||
}
|
||||
static bool can_as_data_source(const int32_t dest_replica_type, const int32_t src_replica_type)
|
||||
{
|
||||
return (dest_replica_type == src_replica_type
|
||||
|| REPLICA_TYPE_FULL == src_replica_type); // TODO temporarily only supports the same type or F as the data source
|
||||
}
|
||||
//Currently only copies of F and R can be used for machine reading, not L
|
||||
static bool can_slave_read_replica(const int32_t replica_type)
|
||||
{
|
||||
return (REPLICA_TYPE_FULL == replica_type || REPLICA_TYPE_READONLY == replica_type);
|
||||
return (REPLICA_TYPE_FULL == replica_type || REPLICA_TYPE_READONLY == replica_type
|
||||
|| REPLICA_TYPE_COLUMNSTORE == replica_type);
|
||||
}
|
||||
|
||||
static bool change_replica_op_allow(const ObReplicaType source, const ObReplicaType target)
|
||||
@ -2245,6 +2248,8 @@ public:
|
||||
|
||||
if (REPLICA_TYPE_LOGONLY == source || REPLICA_TYPE_LOGONLY == target) {
|
||||
bool_ret = false;
|
||||
} else if (REPLICA_TYPE_COLUMNSTORE == source || REPLICA_TYPE_COLUMNSTORE == target) {
|
||||
bool_ret = false;
|
||||
} else if (REPLICA_TYPE_FULL == source) {
|
||||
bool_ret = true;
|
||||
} else if (REPLICA_TYPE_READONLY == source && REPLICA_TYPE_FULL == target) {
|
||||
|
27
deps/oblib/src/lib/utility/utility.cpp
vendored
27
deps/oblib/src/lib/utility/utility.cpp
vendored
@ -1658,33 +1658,6 @@ int long_to_str10(int64_t val,char *dst, const int64_t buf_len, const bool is_si
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
const char *replica_type_to_str(const ObReplicaType &type)
|
||||
{
|
||||
const char *str = "";
|
||||
|
||||
switch (type) {
|
||||
case REPLICA_TYPE_FULL:
|
||||
str = "REPLICA_TYPE_FULL";
|
||||
break;
|
||||
case REPLICA_TYPE_BACKUP:
|
||||
str = "REPLICA_TYPE_BACKUP";
|
||||
break;
|
||||
case REPLICA_TYPE_LOGONLY:
|
||||
str = "REPLICA_TYPE_LOGONLY";
|
||||
break;
|
||||
case REPLICA_TYPE_READONLY:
|
||||
str = "REPLICA_TYPE_READONLY";
|
||||
break;
|
||||
case REPLICA_TYPE_MEMONLY:
|
||||
str = "REPLICA_TYPE_MEMONLY";
|
||||
break;
|
||||
default:
|
||||
str = "REPLICA_TYPE_UNKNOWN";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
bool ez2ob_addr(ObAddr &addr, easy_addr_t& ez)
|
||||
{
|
||||
bool ret = false;
|
||||
|
2
deps/oblib/src/lib/utility/utility.h
vendored
2
deps/oblib/src/lib/utility/utility.h
vendored
@ -1273,8 +1273,6 @@ private:
|
||||
|
||||
void get_addr_by_proxy_sessid(const uint64_t session_id, ObAddr &addr);
|
||||
|
||||
const char *replica_type_to_str(const ObReplicaType &type);
|
||||
|
||||
int ob_atoll(const char *str, int64_t &res);
|
||||
int ob_strtoll(const char *str, char *&endptr, int64_t &res);
|
||||
int ob_strtoull(const char *str, char *&endptr, uint64_t &res);
|
||||
|
@ -253,7 +253,7 @@ TEST_F(TestLSMigrationParam, test_migrate_tablet_param)
|
||||
SCN scn;
|
||||
scn.convert_from_ts(ObTimeUtility::current_time());
|
||||
ret = src_handle.get_obj()->init_for_first_time_creation(allocator_, src_key.ls_id_, src_key.tablet_id_, src_key.tablet_id_,
|
||||
scn, 2022, create_tablet_schema, true/*need_create_empty_major_sstable*/, ls_handle.get_ls()->get_freezer());
|
||||
scn, 2022, create_tablet_schema, true/*need_create_empty_major_sstable*/, false/*need_generate_cs_replica_cg_array*/, ls_handle.get_ls()->get_freezer());
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
|
||||
share::SCN create_commit_scn;
|
||||
@ -334,7 +334,7 @@ TEST_F(TestLSMigrationParam, test_migration_param_compat)
|
||||
SCN scn;
|
||||
scn.convert_from_ts(ObTimeUtility::current_time());
|
||||
ret = src_handle.get_obj()->init_for_first_time_creation(allocator_, src_key.ls_id_, src_key.tablet_id_, src_key.tablet_id_,
|
||||
scn, 2022, create_tablet_schema, true/*need_create_empty_major_sstable*/, ls_handle.get_ls()->get_freezer());
|
||||
scn, 2022, create_tablet_schema, true/*need_create_empty_major_sstable*/, false/*need_generate_cs_replica_cg_array*/, ls_handle.get_ls()->get_freezer());
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
|
||||
share::SCN create_commit_scn;
|
||||
|
@ -170,7 +170,7 @@ void TestLSTabletInfoWR::fill_tablet_meta()
|
||||
SCN scn;
|
||||
scn.convert_from_ts(ObTimeUtility::current_time());
|
||||
ret = src_handle.get_obj()->init_for_first_time_creation(arena_allocator_, src_key.ls_id_, src_key.tablet_id_, src_key.tablet_id_,
|
||||
scn, 2022, create_tablet_schema, true/*need_create_empty_major_sstable*/, ls_handle.get_ls()->get_freezer());
|
||||
scn, 2022, create_tablet_schema, true/*need_create_empty_major_sstable*/, false/*need_generate_cs_replica_cg_array*/, ls_handle.get_ls()->get_freezer());
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
|
||||
share::SCN create_commit_scn;
|
||||
|
@ -141,6 +141,7 @@ void TestTableScanPureDataTable::insert_data_to_tablet(MockObAccessService *acce
|
||||
|
||||
share::schema::ObTableSchema table_schema;
|
||||
TestDmlCommon::build_data_table_schema(tenant_id_, table_schema);
|
||||
table_schema.set_tablet_id(tablet_id_);
|
||||
|
||||
ObSEArray<const ObTableSchema *, 4> index_schema_array;
|
||||
|
||||
@ -181,6 +182,7 @@ void TestTableScanPureDataTable::table_scan(
|
||||
// prepare table schema
|
||||
share::schema::ObTableSchema table_schema;
|
||||
TestDmlCommon::build_data_table_schema(tenant_id_, table_schema);
|
||||
table_schema.set_tablet_id(tablet_id_);
|
||||
|
||||
// 1. get tx desc
|
||||
transaction::ObTxDesc *tx_desc = nullptr;
|
||||
|
@ -718,7 +718,7 @@ TEST_F(TestTenantMetaMemMgr, test_wash_tablet)
|
||||
|
||||
ObTabletID empty_tablet_id;
|
||||
ret = tablet->init_for_first_time_creation(allocator_, ls_id_, tablet_id, tablet_id,
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema, true/*need_create_empty_major_sstable*/, &freezer);
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema, true/*need_create_empty_major_sstable*/, false/*need_generate_cs_replica_cg_array*/, &freezer);
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
ASSERT_EQ(1, tablet->get_ref());
|
||||
ObTabletPersister persister;
|
||||
@ -817,7 +817,7 @@ TEST_F(TestTenantMetaMemMgr, test_wash_inner_tablet)
|
||||
bool make_empty_co_sstable = true;
|
||||
ret = tablet->init_for_first_time_creation(allocator_, ls_id_, tablet_id, tablet_id,
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema,
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/, &freezer);
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/, false/*need_generate_cs_replica_cg_array*/, &freezer);
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
ASSERT_EQ(1, tablet->get_ref());
|
||||
|
||||
@ -927,7 +927,7 @@ TEST_F(TestTenantMetaMemMgr, test_wash_no_sstable_tablet)
|
||||
bool make_empty_co_sstable = false;
|
||||
ret = tablet->init_for_first_time_creation(allocator_, ls_id_, tablet_id, tablet_id,
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema,
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/, &freezer);
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/, false/*need_generate_cs_replica_cg_array*/, &freezer);
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
ASSERT_EQ(1, tablet->get_ref());
|
||||
|
||||
@ -1024,7 +1024,7 @@ TEST_F(TestTenantMetaMemMgr, test_get_tablet_with_allocator)
|
||||
bool make_empty_co_sstable = true;
|
||||
ret = tablet->init_for_first_time_creation(allocator_, ls_id_, tablet_id, tablet_id,
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema,
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/, &freezer);
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/, false/*need_generate_cs_replica_cg_array*/, &freezer);
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
ASSERT_EQ(1, tablet->get_ref());
|
||||
|
||||
@ -1152,7 +1152,7 @@ TEST_F(TestTenantMetaMemMgr, test_wash_mem_tablet)
|
||||
bool make_empty_co_sstable = false;
|
||||
ret = tablet->init_for_first_time_creation(allocator_, ls_id_, tablet_id, tablet_id,
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema,
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/, &freezer);
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/, false/*need_generate_cs_replica_cg_array*/, &freezer);
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
ASSERT_EQ(1, tablet->get_ref());
|
||||
|
||||
|
@ -727,6 +727,7 @@ void TestTxDataTable::fake_ls_(ObLS &ls)
|
||||
ls.ls_meta_.migration_status_ = ObMigrationStatus::OB_MIGRATION_STATUS_NONE;
|
||||
ls.ls_meta_.restore_status_ = ObLSRestoreStatus::NONE;
|
||||
ls.ls_meta_.rebuild_seq_ = 0;
|
||||
ls.ls_meta_.store_format_ = common::ObLSStoreType::OB_LS_STORE_NORMAL;
|
||||
}
|
||||
|
||||
void TestTxDataTable::do_print_leak_slice_test()
|
||||
|
@ -267,6 +267,7 @@ TEST_F(ObLSBeforeRestartTest, create_unfinished_ls_without_disk)
|
||||
migration_status,
|
||||
ObLSRestoreStatus(ObLSRestoreStatus::NONE),
|
||||
arg.get_create_scn(),
|
||||
ObLSStoreFormat(ObLSStoreType::OB_LS_STORE_NORMAL),
|
||||
ls));
|
||||
ObLSLockGuard lock_ls(ls);
|
||||
const ObLSMeta &ls_meta = ls->get_ls_meta();
|
||||
@ -295,6 +296,7 @@ TEST_F(ObLSBeforeRestartTest, create_unfinished_ls_with_disk)
|
||||
migration_status,
|
||||
ObLSRestoreStatus(ObLSRestoreStatus::NONE),
|
||||
arg.get_create_scn(),
|
||||
ObLSStoreFormat(ObLSStoreType::OB_LS_STORE_NORMAL),
|
||||
ls));
|
||||
const bool unused_allow_log_sync = true;
|
||||
prepare_palf_base_info(arg, palf_base_info);
|
||||
@ -329,6 +331,7 @@ TEST_F(ObLSBeforeRestartTest, create_unfinished_ls_with_inner_tablet)
|
||||
migration_status,
|
||||
ObLSRestoreStatus(ObLSRestoreStatus::NONE),
|
||||
arg.get_create_scn(),
|
||||
ObLSStoreFormat(ObLSStoreType::OB_LS_STORE_NORMAL),
|
||||
ls));
|
||||
const bool unused_allow_log_sync = true;
|
||||
prepare_palf_base_info(arg, palf_base_info);
|
||||
@ -365,6 +368,7 @@ TEST_F(ObLSBeforeRestartTest, create_unfinished_ls_with_commit_slog)
|
||||
migration_status,
|
||||
ObLSRestoreStatus(ObLSRestoreStatus::NONE),
|
||||
arg.get_create_scn(),
|
||||
ObLSStoreFormat(ObLSStoreType::OB_LS_STORE_NORMAL),
|
||||
ls));
|
||||
const bool unused_allow_log_sync = true;
|
||||
prepare_palf_base_info(arg, palf_base_info);
|
||||
@ -404,6 +408,7 @@ TEST_F(ObLSBeforeRestartTest, create_restore_ls)
|
||||
migration_status,
|
||||
ObLSRestoreStatus(ObLSRestoreStatus::RESTORE_START),
|
||||
arg.get_create_scn(),
|
||||
ObLSStoreFormat(ObLSStoreType::OB_LS_STORE_NORMAL),
|
||||
ls));
|
||||
const bool unused_allow_log_sync = true;
|
||||
prepare_palf_base_info(arg, palf_base_info);
|
||||
@ -448,6 +453,7 @@ TEST_F(ObLSBeforeRestartTest, create_rebuild_ls)
|
||||
migration_status,
|
||||
ObLSRestoreStatus(ObLSRestoreStatus::NONE),
|
||||
arg.get_create_scn(),
|
||||
ObLSStoreFormat(ObLSStoreType::OB_LS_STORE_NORMAL),
|
||||
ls));
|
||||
const bool unused_allow_log_sync = true;
|
||||
prepare_palf_base_info(arg, palf_base_info);
|
||||
|
@ -5435,10 +5435,8 @@ void PalfHandleImpl::report_switch_learner_to_acceptor_(const common::ObMember &
|
||||
"member", member_buf,
|
||||
"curr_member_list", member_list_buf,
|
||||
"curr_replica_num", curr_replica_num);
|
||||
char replica_readonly_name_[common::MAX_REPLICA_TYPE_LENGTH];
|
||||
char replica_full_name_[common::MAX_REPLICA_TYPE_LENGTH];
|
||||
replica_type_to_string(ObReplicaType::REPLICA_TYPE_READONLY, replica_readonly_name_, sizeof(replica_readonly_name_));
|
||||
replica_type_to_string(ObReplicaType::REPLICA_TYPE_FULL, replica_full_name_, sizeof(replica_full_name_));
|
||||
const char *replica_readonly_name_ = ObShareUtil::replica_type_to_string(ObReplicaType::REPLICA_TYPE_READONLY);
|
||||
const char *replica_full_name_ = ObShareUtil::replica_type_to_string(ObReplicaType::REPLICA_TYPE_FULL);
|
||||
plugins_.record_replica_type_change_event(palf_id_, config_version, replica_readonly_name_, replica_full_name_, EXTRA_INFOS);
|
||||
}
|
||||
|
||||
@ -5457,10 +5455,8 @@ void PalfHandleImpl::report_switch_acceptor_to_learner_(const common::ObMember &
|
||||
"member", member_buf,
|
||||
"curr_member_list", member_list_buf,
|
||||
"curr_replica_num", curr_replica_num);
|
||||
char replica_readonly_name_[common::MAX_REPLICA_TYPE_LENGTH];
|
||||
char replica_full_name_[common::MAX_REPLICA_TYPE_LENGTH];
|
||||
replica_type_to_string(ObReplicaType::REPLICA_TYPE_READONLY, replica_readonly_name_, sizeof(replica_readonly_name_));
|
||||
replica_type_to_string(ObReplicaType::REPLICA_TYPE_FULL, replica_full_name_, sizeof(replica_full_name_));
|
||||
const char *replica_readonly_name_ = ObShareUtil::replica_type_to_string(ObReplicaType::REPLICA_TYPE_READONLY);
|
||||
const char *replica_full_name_ = ObShareUtil::replica_type_to_string(ObReplicaType::REPLICA_TYPE_FULL);
|
||||
plugins_.record_replica_type_change_event(palf_id_, config_version, replica_full_name_, replica_readonly_name_, EXTRA_INFOS);
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,8 @@
|
||||
#include "share/ob_heartbeat_handler.h"
|
||||
#include "storage/slog/ob_storage_logger_manager.h"
|
||||
#include "storage/high_availability/ob_transfer_lock_utils.h"
|
||||
#include "storage/column_store/ob_column_store_replica_util.h"
|
||||
#include "common/ob_store_format.h" // ObLSStoreFormat
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -2704,7 +2706,17 @@ int ObService::inner_fill_tablet_info_(
|
||||
int64_t data_size = 0;
|
||||
int64_t required_size = 0;
|
||||
ObArray<int64_t> column_checksums;
|
||||
if (OB_FAIL(tablet_handle.get_obj()->get_tablet_report_info(snapshot_version, column_checksums,
|
||||
ObTablet *tablet = tablet_handle.get_obj();
|
||||
bool need_wait_major_convert_in_cs_replica = false;
|
||||
if (OB_ISNULL(tablet)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("tablet is unexpected nullptr", K(ret), K(tenant_id), K(tablet_id), K(tablet_handle));
|
||||
} else if (OB_FAIL(ObCSReplicaUtil::check_need_wait_major_convert(*ls, tablet_id, *tablet, need_wait_major_convert_in_cs_replica))) {
|
||||
LOG_WARN("fail to check need wait major convert in cs replica", K(ret), KPC(ls), K(tablet));
|
||||
} else if (need_wait_major_convert_in_cs_replica) {
|
||||
ret = OB_EAGAIN;
|
||||
LOG_WARN("need wait major convert for cs replica", K(ret), K(tablet_id));
|
||||
} else if (OB_FAIL(tablet->get_tablet_report_info(snapshot_version, column_checksums,
|
||||
data_size, required_size, need_checksum))) {
|
||||
LOG_WARN("fail to get tablet report info from tablet", KR(ret), K(tenant_id), K(tablet_id));
|
||||
} else if (OB_FAIL(tablet_replica.init(
|
||||
@ -2788,118 +2800,27 @@ int ObService::fill_tablet_report_info(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObService::get_role_from_palf_(
|
||||
logservice::ObLogService &log_service,
|
||||
const share::ObLSID &ls_id,
|
||||
common::ObRole &role,
|
||||
int64_t &proposal_id)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
role = FOLLOWER;
|
||||
proposal_id = 0;
|
||||
palf::PalfHandleGuard palf_handle_guard;
|
||||
if (OB_FAIL(log_service.open_palf(ls_id, palf_handle_guard))) {
|
||||
LOG_WARN("open palf failed", KR(ret), K(ls_id));
|
||||
} else if (OB_FAIL(palf_handle_guard.get_role(role, proposal_id))) {
|
||||
LOG_WARN("get role failed", KR(ret), K(ls_id));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObService::fill_ls_replica(
|
||||
const uint64_t tenant_id,
|
||||
const ObLSID &ls_id,
|
||||
share::ObLSReplica &replica)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
uint64_t unit_id = common::OB_INVALID_ID;
|
||||
replica.reset();
|
||||
if (OB_UNLIKELY(!inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("service not inited", KR(ret));
|
||||
} else if (!ls_id.is_valid()
|
||||
|| OB_INVALID_TENANT_ID == tenant_id
|
||||
|| OB_ISNULL(gctx_.config_)) {
|
||||
} else if (!ls_id.is_valid() || OB_INVALID_TENANT_ID == tenant_id) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id), K(ls_id));
|
||||
} else if (OB_FAIL(GCTX.omt_->get_unit_id(tenant_id, unit_id))) {
|
||||
LOG_WARN("get tenant unit id failed", KR(ret), K(tenant_id), K(ls_id));
|
||||
} else {
|
||||
MTL_SWITCH(tenant_id) {
|
||||
ObLSHandle ls_handle;
|
||||
ObLSService *ls_svr = nullptr;
|
||||
logservice::ObLogService *log_service = nullptr;
|
||||
common::ObRole role = FOLLOWER;
|
||||
ObMemberList ob_member_list;
|
||||
ObLSReplica::MemberList member_list;
|
||||
GlobalLearnerList learner_list;
|
||||
int64_t proposal_id = 0;
|
||||
int64_t paxos_replica_number = 0;
|
||||
ObLSRestoreStatus restore_status;
|
||||
ObReplicaStatus replica_status = REPLICA_STATUS_NORMAL;
|
||||
ObReplicaType replica_type = REPLICA_TYPE_FULL;
|
||||
bool is_compatible_with_readonly_replica = false;
|
||||
ObMigrationStatus migration_status = OB_MIGRATION_STATUS_MAX;
|
||||
if (OB_ISNULL(ls_svr = MTL(ObLSService*))) {
|
||||
ObLSService *ls_svr = MTL(ObLSService*);
|
||||
if (OB_ISNULL(ls_svr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("MTL ObLSService is null", KR(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(ls_svr->get_ls(
|
||||
ObLSID(ls_id),
|
||||
ls_handle, ObLSGetMod::OBSERVER_MOD))) {
|
||||
LOG_WARN("get ls handle failed", KR(ret));
|
||||
} else if (OB_FAIL(ls_handle.get_ls()->get_paxos_member_list_and_learner_list(ob_member_list, paxos_replica_number, learner_list))) {
|
||||
LOG_WARN("get member list and learner list from ObLS failed", KR(ret));
|
||||
} else if (OB_FAIL(ls_handle.get_ls()->get_restore_status(restore_status))) {
|
||||
LOG_WARN("get restore status failed", KR(ret));
|
||||
} else if (OB_FAIL(ls_handle.get_ls()->get_migration_status(migration_status))) {
|
||||
LOG_WARN("get migration status failed", KR(ret));
|
||||
} else if (OB_FAIL(ls_handle.get_ls()->get_replica_status(replica_status))) {
|
||||
LOG_WARN("get replica status failed", KR(ret));
|
||||
} else if (OB_ISNULL(log_service = MTL(logservice::ObLogService*))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("MTL ObLogService is null", KR(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(get_role_from_palf_(*log_service, ls_id, role, proposal_id))) {
|
||||
LOG_WARN("failed to get role from palf", KR(ret), K(tenant_id), K(ls_id));
|
||||
} else if (OB_SUCCESS != (tmp_ret = ObShareUtil::check_compat_version_for_readonly_replica(
|
||||
tenant_id, is_compatible_with_readonly_replica))) {
|
||||
LOG_WARN("fail to check data version for read-only replica", KR(ret), K(tenant_id));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (!is_compatible_with_readonly_replica) {
|
||||
replica_type = REPLICA_TYPE_FULL;
|
||||
} else if (learner_list.contains(gctx_.self_addr())) {
|
||||
// if replica exists in learner_list, report it as R-replica.
|
||||
// Otherwise, report as F-replica
|
||||
replica_type = REPLICA_TYPE_READONLY;
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(ObLSReplica::transform_ob_member_list(ob_member_list, member_list))) {
|
||||
LOG_WARN("fail to transfrom ob_member_list into member_list", KR(ret), K(ob_member_list));
|
||||
} else if (OB_FAIL(replica.init(
|
||||
0, /*create_time_us*/
|
||||
0, /*modify_time_us*/
|
||||
tenant_id, /*tenant_id*/
|
||||
ls_id, /*ls_id*/
|
||||
gctx_.self_addr(), /*server*/
|
||||
gctx_.config_->mysql_port, /*sql_port*/
|
||||
role, /*role*/
|
||||
replica_type, /*replica_type*/
|
||||
proposal_id, /*proposal_id*/
|
||||
is_strong_leader(role) ? REPLICA_STATUS_NORMAL : replica_status,/*replica_status*/
|
||||
restore_status, /*restore_status*/
|
||||
100, /*memstore_percent*/
|
||||
unit_id, /*unit_id*/
|
||||
gctx_.config_->zone.str(), /*zone*/
|
||||
paxos_replica_number, /*paxos_replica_number*/
|
||||
0, /*data_size*/
|
||||
0, /*required_size*/
|
||||
member_list,
|
||||
learner_list,
|
||||
OB_MIGRATION_STATUS_REBUILD == migration_status /*is_rebuild*/))) {
|
||||
LOG_WARN("fail to init a ls replica", KR(ret), K(tenant_id), K(ls_id), K(role),
|
||||
K(proposal_id), K(unit_id), K(paxos_replica_number), K(member_list), K(learner_list));
|
||||
LOG_WARN("ObLSService is null", KR(ret));
|
||||
} else if (OB_FAIL(ls_svr->get_ls_replica(ls_id, ObLSGetMod::OBSERVER_MOD, replica))) {
|
||||
LOG_WARN("fail to get_ls_replica", KR(ret), K(ls_id));
|
||||
} else {
|
||||
LOG_TRACE("finish fill ls replica", KR(ret), K(tenant_id), K(ls_id), K(replica));
|
||||
}
|
||||
|
@ -269,11 +269,6 @@ public:
|
||||
int check_server_empty(bool &server_empty);
|
||||
|
||||
private:
|
||||
int get_role_from_palf_(
|
||||
logservice::ObLogService &log_service,
|
||||
const share::ObLSID &ls_id,
|
||||
common::ObRole &role,
|
||||
int64_t &proposal_id);
|
||||
int inner_fill_tablet_info_(
|
||||
const int64_t tenant_id,
|
||||
const ObTabletID &tablet_id,
|
||||
|
@ -688,6 +688,7 @@ int ObTableLocCgService::generate_table_loc_meta(const ObTableCtx &ctx,
|
||||
bool is_lookup)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t route_policy = 0;
|
||||
const ObTableSchema *table_schema = ctx.get_table_schema();
|
||||
const ObTableSchema *index_schema = ctx.get_index_schema();
|
||||
|
||||
@ -697,8 +698,11 @@ int ObTableLocCgService::generate_table_loc_meta(const ObTableCtx &ctx,
|
||||
} else if (ctx.is_index_scan() && OB_ISNULL(index_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("index schema is null", K(ret));
|
||||
} else if (OB_FAIL(ctx.get_session_info().get_sys_variable(SYS_VAR_OB_ROUTE_POLICY, route_policy))) {
|
||||
LOG_WARN("fail to get route policy from session", K(ret));
|
||||
} else {
|
||||
loc_meta.reset();
|
||||
loc_meta.route_policy_ = route_policy;
|
||||
// is_lookup 有什么用?好像都是 false
|
||||
loc_meta.ref_table_id_ = is_lookup ? ctx.get_ref_table_id() : ctx.get_index_table_id();
|
||||
loc_meta.table_loc_id_ = ctx.get_ref_table_id();
|
||||
@ -2541,7 +2545,8 @@ int ObTableTscCgService::generate_das_result_output(ObDASScanCtDef &das_tsc_ctde
|
||||
// 主表/索引回表/索引扫描不需要回表: select column ids
|
||||
// 索引表: rowkey column ids
|
||||
int ObTableTscCgService::generate_table_param(const ObTableCtx &ctx,
|
||||
ObDASScanCtDef &das_tsc_ctdef)
|
||||
ObDASScanCtDef &das_tsc_ctdef,
|
||||
const bool query_cs_replica /*=false*/)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSEArray<uint64_t, 64> tsc_out_cols;
|
||||
@ -2595,7 +2600,9 @@ int ObTableTscCgService::generate_table_param(const ObTableCtx &ctx,
|
||||
} else if (OB_FAIL(das_tsc_ctdef.table_param_.convert(*table_schema,
|
||||
das_tsc_ctdef.access_column_ids_,
|
||||
das_tsc_ctdef.pd_expr_spec_.pd_storage_flag_,
|
||||
&tsc_out_cols))) {
|
||||
&tsc_out_cols,
|
||||
false /*force_mysql_mode*/,
|
||||
query_cs_replica))) {
|
||||
LOG_WARN("fail to convert schema", K(ret), K(*table_schema));
|
||||
} else if (OB_FAIL(generate_das_result_output(das_tsc_ctdef, tsc_out_cols))) {
|
||||
LOG_WARN("fail to generate das result outpur", K(ret), K(tsc_out_cols));
|
||||
@ -2606,7 +2613,8 @@ int ObTableTscCgService::generate_table_param(const ObTableCtx &ctx,
|
||||
|
||||
int ObTableTscCgService::generate_das_tsc_ctdef(const ObTableCtx &ctx,
|
||||
ObIAllocator &allocator,
|
||||
ObDASScanCtDef &das_tsc_ctdef)
|
||||
ObDASScanCtDef &das_tsc_ctdef,
|
||||
const bool query_cs_replica /*=false*/)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSchemaGetterGuard &schema_guard = (const_cast<ObTableCtx&>(ctx)).get_schema_guard();
|
||||
@ -2616,7 +2624,7 @@ int ObTableTscCgService::generate_das_tsc_ctdef(const ObTableCtx &ctx,
|
||||
|
||||
if (OB_FAIL(generate_access_ctdef(ctx, allocator, das_tsc_ctdef))) { // init access_column_ids_,pd_expr_spec_.access_exprs_
|
||||
LOG_WARN("fail to generate asccess ctdef", K(ret));
|
||||
} else if (OB_FAIL(generate_table_param(ctx, das_tsc_ctdef))) { // init table_param_, result_output_
|
||||
} else if (OB_FAIL(generate_table_param(ctx, das_tsc_ctdef, query_cs_replica))) { // init table_param_, result_output_
|
||||
LOG_WARN("fail to generate table param", K(ret));
|
||||
}
|
||||
|
||||
@ -2663,7 +2671,7 @@ int ObTableTscCgService::generate_tsc_ctdef(const ObTableCtx &ctx,
|
||||
int ret = OB_SUCCESS;
|
||||
ObStaticEngineCG cg(ctx.get_cur_cluster_version());
|
||||
const int64_t filter_exprs_cnt = ctx.get_filter_exprs().count();
|
||||
|
||||
bool query_cs_replica = false;
|
||||
// init scan_ctdef_.ref_table_id_
|
||||
tsc_ctdef.scan_ctdef_.ref_table_id_ = ctx.get_index_table_id();
|
||||
if (OB_FAIL(tsc_ctdef.output_exprs_.init(ctx.get_select_exprs().count()))) {
|
||||
@ -2674,7 +2682,9 @@ int ObTableTscCgService::generate_tsc_ctdef(const ObTableCtx &ctx,
|
||||
LOG_WARN("fail to generate output exprs", K(ret));
|
||||
} else if (OB_FAIL(cg.generate_rt_exprs(ctx.get_filter_exprs(), tsc_ctdef.filter_exprs_))) {
|
||||
LOG_WARN("fail to generate filter rt exprs ", K(ret));
|
||||
} else if (OB_FAIL(generate_das_tsc_ctdef(ctx, allocator, tsc_ctdef.scan_ctdef_))) { // init scan_ctdef_
|
||||
} else if (OB_FAIL(ctx.check_is_cs_replica_query(query_cs_replica))) {
|
||||
LOG_WARN("fail to check is cs replica query", K(ret));
|
||||
} else if (OB_FAIL(generate_das_tsc_ctdef(ctx, allocator, tsc_ctdef.scan_ctdef_, query_cs_replica))) { // init scan_ctdef_
|
||||
LOG_WARN("fail to generate das scan ctdef", K(ret));
|
||||
} else if (ctx.is_index_back()) {
|
||||
// init lookup_ctdef_,lookup_loc_meta_
|
||||
|
@ -362,7 +362,8 @@ public:
|
||||
private:
|
||||
static int generate_das_tsc_ctdef(const ObTableCtx &ctx,
|
||||
ObIAllocator &allocator,
|
||||
sql::ObDASScanCtDef &das_tsc_ctdef);
|
||||
sql::ObDASScanCtDef &das_tsc_ctdef,
|
||||
const bool query_cs_replica = false);
|
||||
static int replace_gen_col_exprs(const ObTableCtx &ctx,
|
||||
common::ObIArray<sql::ObRawExpr*> &access_exprs);
|
||||
static int generate_output_exprs(const ObTableCtx &ctx,
|
||||
@ -371,7 +372,8 @@ private:
|
||||
ObIAllocator &allocator,
|
||||
sql::ObDASScanCtDef &das_tsc_ctdef);
|
||||
static int generate_table_param(const ObTableCtx &ctx,
|
||||
sql::ObDASScanCtDef &das_tsc_ctdef);
|
||||
sql::ObDASScanCtDef &das_tsc_ctdef,
|
||||
const bool query_cs_replica = false);
|
||||
static OB_INLINE bool is_in_array(const common::ObIArray<sql::ObRawExpr*> &array,
|
||||
const sql::ObRawExpr *expr)
|
||||
{
|
||||
|
@ -784,6 +784,20 @@ int ObTableCtx::adjust_entity()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableCtx::check_is_cs_replica_query(bool &is_cs_replica_query) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_cs_replica_query = false;
|
||||
if (ObRoutePolicyType::INVALID_POLICY == loc_meta_.route_policy_) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid route policy", K(ret));
|
||||
} else {
|
||||
is_cs_replica_query = ObRoutePolicyType::COLUMN_STORE_ONLY == loc_meta_.route_policy_;
|
||||
}
|
||||
LOG_TRACE("[CS-Replica] check cs replica query", K(ret), K(is_cs_replica_query), K_(loc_meta));
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ObTableCtx::has_exist_in_columns(const ObIArray<ObString> &columns,
|
||||
const ObString &name,
|
||||
int64_t *idx /* =nullptr */) const
|
||||
|
@ -413,6 +413,9 @@ public:
|
||||
// read lob的allocator需要保证obj序列化到rpc buffer后才能析构
|
||||
static int read_real_lob(common::ObIAllocator &allocator, ObObj &obj);
|
||||
int adjust_entity();
|
||||
public:
|
||||
// for column store replica query
|
||||
int check_is_cs_replica_query(bool &is_cs_replica_query) const;
|
||||
private:
|
||||
// for common
|
||||
int get_tablet_by_rowkey(const common::ObRowkey &rowkey,
|
||||
|
@ -130,15 +130,8 @@ int ObAllVirtualLSInfo::process_curr_tenant(ObNewRow *&row)
|
||||
break;
|
||||
case OB_APP_MIN_COLUMN_ID + 4: {
|
||||
// replica_type
|
||||
if (OB_FAIL(replica_type_to_string(ls_info.replica_type_,
|
||||
replica_type_name_,
|
||||
sizeof(replica_type_name_)))) {
|
||||
SERVER_LOG(WARN, "get replica type name failed", K(ret), K(ls_info.replica_type_));
|
||||
} else {
|
||||
replica_type_name_[MAX_REPLICA_TYPE_LENGTH - 1] = '\0';
|
||||
cur_row_.cells_[i].set_varchar(replica_type_name_);
|
||||
cur_row_.cells_[i].set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
}
|
||||
cur_row_.cells_[i].set_varchar(ObShareUtil::replica_type_to_string(ls_info.replica_type_));
|
||||
cur_row_.cells_[i].set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
break;
|
||||
}
|
||||
case OB_APP_MIN_COLUMN_ID + 5: {
|
||||
|
@ -48,7 +48,6 @@ private:
|
||||
common::ObAddr addr_;
|
||||
char ip_buf_[common::OB_IP_STR_BUFF];
|
||||
char state_name_[common::MAX_LS_STATE_LENGTH];
|
||||
char replica_type_name_[common::MAX_REPLICA_TYPE_LENGTH];
|
||||
/* 跨租户访问的资源必须由ObMultiTenantOperator来处理释放*/
|
||||
int64_t ls_id_;
|
||||
ObSharedGuard<storage::ObLSIterator> ls_iter_guard_;
|
||||
|
@ -931,6 +931,43 @@ int ObAllVirtualProxySchema::get_next_tenant_server_(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObAllVirtualProxySchema::get_replica_type_from_locality_(
|
||||
const ZoneLocalityIArray &zone_locality_array,
|
||||
const ObZone &zone,
|
||||
ObReplicaType &replica_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
replica_type = REPLICA_TYPE_FULL;
|
||||
if (OB_UNLIKELY(zone_locality_array.empty() || zone.is_empty())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(zone_locality_array), K(zone));
|
||||
} else {
|
||||
bool zone_found = false;
|
||||
FOREACH_CNT_X(zone_locality, zone_locality_array, !zone_found && OB_SUCCESS == ret) {
|
||||
if (zone_locality->get_zone_set().at(0) == zone) {
|
||||
zone_found = true;
|
||||
if (zone_locality->get_readonly_replica_num() > 0) {
|
||||
replica_type = REPLICA_TYPE_READONLY;
|
||||
} else if (zone_locality->get_columnstore_replica_num() > 0) {
|
||||
replica_type = REPLICA_TYPE_COLUMNSTORE;
|
||||
} else if (zone_locality->get_full_replica_num() > 0) {
|
||||
replica_type = REPLICA_TYPE_FULL;
|
||||
} else {
|
||||
// unrecognized replica_type
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
replica_type = REPLICA_TYPE_INVALID;
|
||||
LOG_WARN("unrecognized replica type", KR(ret), KPC(zone_locality));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!zone_found) {
|
||||
// tenant locality does not include this zone, regard as FULL
|
||||
replica_type = REPLICA_TYPE_FULL;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObAllVirtualProxySchema::fill_tenant_servers_(
|
||||
const uint64_t tenant_id,
|
||||
ObMySQLResult &result,
|
||||
@ -952,6 +989,17 @@ int ObAllVirtualProxySchema::fill_tenant_servers_(
|
||||
int64_t svr_idx = 0;
|
||||
first_idx_in_zone.reset();
|
||||
tenant_servers_.reset();
|
||||
const ObTenantSchema *tenant_schema = NULL;
|
||||
ObArray<share::ObZoneReplicaNumSet> zone_locality;
|
||||
|
||||
if (OB_FAIL(schema_guard_.get_tenant_info(tenant_id, tenant_schema))) {
|
||||
LOG_WARN("fail to get tenant info", KR(ret), K(tenant_id));
|
||||
} else if (OB_ISNULL(tenant_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("tenant not exist", KR(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(tenant_schema->get_zone_replica_attr_array(zone_locality))) {
|
||||
LOG_WARN("fail to get zone_locality_array");
|
||||
}
|
||||
|
||||
while (OB_SUCC(ret) && OB_SUCC(result.next())) {
|
||||
tenant_server.reset();
|
||||
@ -960,7 +1008,9 @@ int ObAllVirtualProxySchema::fill_tenant_servers_(
|
||||
EXTRACT_VARCHAR_FIELD_MYSQL(result, "svr_ip", svr_ip);
|
||||
EXTRACT_INT_FIELD_MYSQL(result, "inner_port", sql_port, int64_t);
|
||||
EXTRACT_VARCHAR_FIELD_MYSQL(result, "zone", zone);
|
||||
if (OB_UNLIKELY(!server.set_ip_addr(svr_ip, svr_port))) {
|
||||
if (FAILEDx(get_replica_type_from_locality_(zone_locality, zone, replica_type))) {
|
||||
LOG_WARN("failed to get replica_type", KR(ret), K(zone_locality), K(zone));
|
||||
} else if (OB_UNLIKELY(!server.set_ip_addr(svr_ip, svr_port))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to set_ip_addr", KR(ret), K(svr_ip), K(svr_port));
|
||||
} else if (OB_FAIL(replica_location.init(
|
||||
|
@ -144,6 +144,10 @@ private:
|
||||
int get_next_tenant_server_(const common::ObString &table_name,
|
||||
const share::schema::ObTableSchema *table_schema);
|
||||
int get_tenant_servers_(const uint64_t tenant_id);
|
||||
int get_replica_type_from_locality_(
|
||||
const share::schema::ZoneLocalityIArray &zone_locality_array,
|
||||
const ObZone &zone,
|
||||
ObReplicaType &replica_type);
|
||||
int fill_tenant_servers_(
|
||||
const uint64_t tenant_id,
|
||||
common::sqlclient::ObMySQLResult &result,
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "share/ob_zone_merge_info.h"
|
||||
#include "share/ob_freeze_info_manager.h"
|
||||
#include "rootserver/freeze/ob_fts_checksum_validate_util.h"
|
||||
#include "storage/compaction/ob_medium_compaction_func.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -422,42 +423,9 @@ int ObChecksumValidator::verify_tablet_replica_checksum()
|
||||
if (OB_UNLIKELY(replica_ckm_items_.empty())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(replica_ckm_items_));
|
||||
} else {
|
||||
const ObTabletReplicaChecksumItem *prev_item = nullptr;
|
||||
ObSEArray<ObTabletLSPair, 64> error_pairs;
|
||||
error_pairs.set_attr(ObMemAttr(tenant_id_, "CkmErrPairs"));
|
||||
ObLSID prev_error_ls_id;
|
||||
ObTabletID prev_error_table_id;
|
||||
int64_t affected_rows = 0;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && (i < replica_ckm_items_.count()); ++i) {
|
||||
const ObTabletReplicaChecksumItem &curr_item = replica_ckm_items_.at(i);
|
||||
if (OB_NOT_NULL(prev_item)
|
||||
&& curr_item.is_same_tablet(*prev_item)) { // same tablet
|
||||
if (OB_FAIL(curr_item.verify_checksum(*prev_item))) {
|
||||
if (OB_CHECKSUM_ERROR == ret) {
|
||||
LOG_DBA_ERROR(OB_CHECKSUM_ERROR, "msg", "checksum error in tablet replica checksum", KR(ret),
|
||||
K(curr_item), KPC(prev_item));
|
||||
if (curr_item.ls_id_ != prev_error_ls_id || curr_item.tablet_id_ != prev_error_table_id) {
|
||||
prev_error_ls_id = curr_item.ls_id_;
|
||||
prev_error_table_id = curr_item.tablet_id_;
|
||||
if (OB_TMP_FAIL(error_pairs.push_back(ObTabletLSPair(curr_item.tablet_id_, curr_item.ls_id_)))) {
|
||||
LOG_WARN("fail to push back error pair", K(tmp_ret), "tablet_id", curr_item.tablet_id_, "ls_id", curr_item.ls_id_);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG_WARN("unexpected error in tablet replica checksum", KR(ret), K(curr_item), KPC(prev_item));
|
||||
}
|
||||
}
|
||||
}
|
||||
prev_item = &curr_item;
|
||||
}
|
||||
if (!error_pairs.empty()) {
|
||||
if (OB_TMP_FAIL(ObTabletMetaTableCompactionOperator::batch_set_info_status(MTL_ID(), error_pairs, affected_rows))) {
|
||||
LOG_WARN("fail to batch set info status", KR(tmp_ret));
|
||||
} else {
|
||||
LOG_INFO("succ to batch set info status", K(tmp_ret), K(affected_rows), K(error_pairs));
|
||||
}
|
||||
}
|
||||
} else if (OB_FAIL(ObMediumCompactionScheduleFunc::check_replica_checksum_items(
|
||||
replica_ckm_items_.array_, ls_locality_cache_.get_cs_replica_cache(), false /*is_medium_checker*/))) {
|
||||
LOG_WARN("failed to verify tablet replica checksum", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -67,7 +67,8 @@ public:
|
||||
ObArray<share::ObTabletLSPair> &finish_tablet_ls_pair_array,
|
||||
ObArray<share::ObTabletChecksumItem> &finish_tablet_ckm_array,
|
||||
compaction::ObUncompactInfo &uncompact_info,
|
||||
ObFTSGroupArray &fts_group_array)
|
||||
ObFTSGroupArray &fts_group_array,
|
||||
share::ObCompactionLocalityCache &ls_locality_cache)
|
||||
: is_inited_(false),
|
||||
is_primary_service_(false),
|
||||
need_validate_index_ckm_(false),
|
||||
@ -93,7 +94,8 @@ public:
|
||||
simple_schema_(nullptr),
|
||||
table_compaction_info_(),
|
||||
replica_ckm_items_(),
|
||||
last_table_ckm_items_(tenant_id)
|
||||
last_table_ckm_items_(tenant_id),
|
||||
ls_locality_cache_(ls_locality_cache)
|
||||
{}
|
||||
~ObChecksumValidator() {}
|
||||
int init(
|
||||
@ -198,6 +200,7 @@ private:
|
||||
ObArray<share::ObTabletLSPair> cur_tablet_ls_pair_array_;
|
||||
ObReplicaCkmItems replica_ckm_items_;
|
||||
compaction::ObTableCkmItems last_table_ckm_items_; // only cached last data table with index
|
||||
share::ObCompactionLocalityCache &ls_locality_cache_;
|
||||
};
|
||||
|
||||
} // end namespace rootserver
|
||||
|
@ -50,11 +50,11 @@ ObMajorMergeProgressChecker::ObMajorMergeProgressChecker(
|
||||
loop_cnt_(0), last_errno_(OB_SUCCESS), tenant_id_(tenant_id),
|
||||
compaction_scn_(), expected_epoch_(OB_INVALID_ID), sql_proxy_(nullptr),
|
||||
schema_service_(nullptr), server_trace_(nullptr), progress_(),
|
||||
tablet_status_map_(), table_compaction_map_(), fts_group_array_(),
|
||||
tablet_status_map_(), table_compaction_map_(), fts_group_array_(), ls_locality_cache_(),
|
||||
ckm_validator_(tenant_id, stop_, tablet_ls_pair_cache_, tablet_status_map_,
|
||||
table_compaction_map_, idx_ckm_validate_array_, validator_statistics_,
|
||||
finish_tablet_ls_pair_array_, finish_tablet_ckm_array_, uncompact_info_, fts_group_array_),
|
||||
uncompact_info_(), ls_locality_cache_(), total_time_guard_(), validator_statistics_(), batch_size_mgr_() {}
|
||||
finish_tablet_ls_pair_array_, finish_tablet_ckm_array_, uncompact_info_, fts_group_array_, ls_locality_cache_),
|
||||
uncompact_info_(), total_time_guard_(), validator_statistics_(), batch_size_mgr_() {}
|
||||
|
||||
int ObMajorMergeProgressChecker::init(
|
||||
const bool is_primary_service,
|
||||
@ -437,13 +437,11 @@ int ObMajorMergeProgressChecker::prepare_check_progress(
|
||||
bool &exist_uncompacted_table)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
exist_uncompacted_table = true;
|
||||
table_ids_.start_looping();
|
||||
if (OB_TMP_FAIL(ls_locality_cache_.refresh_ls_locality(first_loop_in_cur_round_ /*force_refresh*/))) {
|
||||
LOG_WARN("failed to refresh ls locality", K(tmp_ret));
|
||||
}
|
||||
if (first_loop_in_cur_round_) {
|
||||
if (OB_FAIL(ls_locality_cache_.refresh_ls_locality(first_loop_in_cur_round_ /*force_refresh*/))) {
|
||||
LOG_WARN("failed to refresh ls locality", K(ret));
|
||||
} else if (first_loop_in_cur_round_) {
|
||||
total_time_guard_.reuse();
|
||||
if (OB_FAIL(prepare_unfinish_table_ids())) {
|
||||
LOG_WARN("fail to prepare table_id_map", KR(ret), K_(tenant_id));
|
||||
|
@ -149,10 +149,10 @@ private:
|
||||
// record each table compaction/verify status
|
||||
compaction::ObTableCompactionInfoMap table_compaction_map_; // <table_id, compaction_info>
|
||||
ObFTSGroupArray fts_group_array_;
|
||||
share::ObCompactionLocalityCache ls_locality_cache_;
|
||||
ObChecksumValidator ckm_validator_;
|
||||
compaction::ObUncompactInfo uncompact_info_;
|
||||
// cache of ls_infos in __all_ls_meta_table
|
||||
share::ObCompactionLocalityCache ls_locality_cache_;
|
||||
// statistics section
|
||||
compaction::ObRSCompactionTimeGuard total_time_guard_;
|
||||
compaction::ObCkmValidatorStatistics validator_statistics_;
|
||||
|
@ -13,7 +13,6 @@
|
||||
#define USING_LOG_PREFIX RS
|
||||
#include "ob_admin_drtask_util.h"
|
||||
#include "logservice/ob_log_service.h" // for ObLogService
|
||||
#include "share/ob_locality_parser.h" // for ObLocalityParser
|
||||
#include "storage/tx_storage/ob_ls_service.h" // for ObLSService
|
||||
#include "storage/ls/ob_ls.h" // for ObLS
|
||||
#include "observer/ob_server_event_history_table_operator.h" // for SERVER_EVENT_ADD
|
||||
@ -146,8 +145,8 @@ int ObAdminDRTaskUtil::construct_arg_for_add_command_(
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
ret_comment = ObAdminDRTaskRetComment::TENANT_ID_OR_LS_ID_NOT_VALID;
|
||||
LOG_WARN("invalid tenant_id or ls_id", KR(ret), K(command_arg), K(tenant_id), K(ls_id));
|
||||
} else if (OB_UNLIKELY(!target_server.is_valid())
|
||||
|| OB_UNLIKELY(REPLICA_TYPE_FULL != replica_type && REPLICA_TYPE_READONLY != replica_type)) {
|
||||
} else if (OB_UNLIKELY(!target_server.is_valid()
|
||||
|| !ObReplicaTypeCheck::is_replica_type_valid(replica_type))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(replica_type), K(target_server));
|
||||
// STEP 2: construct orig_paxos_replica_number and leader_server if not specified by ob_admin command
|
||||
@ -164,8 +163,8 @@ int ObAdminDRTaskUtil::construct_arg_for_add_command_(
|
||||
new_paxos_replica_number = 0 == new_paxos_replica_number
|
||||
? orig_paxos_replica_number
|
||||
: new_paxos_replica_number;
|
||||
ObReplicaMember data_source_member(leader_server, 0/*timstamp*/);
|
||||
ObReplicaMember force_data_source_member(force_data_source_server, 0/*timstamp*/);
|
||||
ObReplicaMember data_source_member(leader_server, 0/*timstamp*/, REPLICA_TYPE_FULL/*dummy_replica_type*/);
|
||||
ObReplicaMember force_data_source_member(force_data_source_server, 0/*timstamp*/, REPLICA_TYPE_FULL/*dummy_replica_type*/);
|
||||
ObReplicaMember add_member(target_server, ObTimeUtility::current_time(), replica_type);
|
||||
// STEP 3: construct arg
|
||||
if (OB_ISNULL(ObCurTraceId::get_trace_id())) {
|
||||
@ -292,8 +291,8 @@ int ObAdminDRTaskUtil::handle_remove_command_(
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
ret_comment = ObAdminDRTaskRetComment::TENANT_ID_OR_LS_ID_NOT_VALID;
|
||||
LOG_WARN("invalid tenant_id or ls_id", KR(ret), K(command_arg), K(tenant_id), K(ls_id));
|
||||
} else if (OB_UNLIKELY(!target_server.is_valid())
|
||||
|| OB_UNLIKELY(REPLICA_TYPE_FULL != replica_type && REPLICA_TYPE_READONLY != replica_type)) {
|
||||
} else if (OB_UNLIKELY(!target_server.is_valid()
|
||||
|| !ObReplicaTypeCheck::is_replica_type_valid(replica_type))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(replica_type), K(target_server));
|
||||
} else {
|
||||
@ -311,10 +310,10 @@ int ObAdminDRTaskUtil::handle_remove_command_(
|
||||
} else {
|
||||
ret_comment = SUCCEED_TO_SEND_COMMAND;
|
||||
}
|
||||
} else if (REPLICA_TYPE_READONLY == replica_type) {
|
||||
} else if (ObReplicaTypeCheck::is_non_paxos_replica(replica_type)) {
|
||||
ObLSDropNonPaxosReplicaArg remove_nonpaxos_arg;
|
||||
if (OB_FAIL(construct_remove_nonpaxos_task_arg_(
|
||||
tenant_id, ls_id, target_server, ret_comment, remove_nonpaxos_arg))) {
|
||||
tenant_id, ls_id, target_server, replica_type, ret_comment, remove_nonpaxos_arg))) {
|
||||
LOG_WARN("fail to construct remove non-paxos replica task arg", KR(ret), K(tenant_id),
|
||||
K(ls_id), K(target_server), K(ret_comment), K(remove_nonpaxos_arg));
|
||||
} else if (OB_FAIL(execute_remove_nonpaxos_task_(command_arg, remove_nonpaxos_arg))) {
|
||||
@ -359,20 +358,17 @@ int ObAdminDRTaskUtil::construct_remove_paxos_task_arg_(
|
||||
LOG_WARN("replica not found in member_list", KR(ret), K(target_server), K(palf_stat));
|
||||
} else if (OB_FAIL(palf_stat.paxos_member_list_.get_member_by_addr(target_server, member))) {
|
||||
LOG_WARN("fail to get member from paxos_member_list", KR(ret), K(palf_stat), K(target_server));
|
||||
} else if (OB_FAIL(member_to_remove.init(member, REPLICA_TYPE_FULL))) {
|
||||
LOG_WARN("fail to init member_to_remove", KR(ret), K(member));
|
||||
} else {
|
||||
member_to_remove = ObReplicaMember(member);
|
||||
if (OB_FAIL(member_to_remove.set_replica_type(REPLICA_TYPE_FULL))) {
|
||||
LOG_WARN("fail to set replica type for member to remove", KR(ret));
|
||||
} else {
|
||||
// If [orig_paxos_replica_number] not specified in obadmin command,
|
||||
// use leader replica's info as default
|
||||
orig_paxos_replica_number = 0 == orig_paxos_replica_number
|
||||
? palf_stat.paxos_replica_num_
|
||||
: orig_paxos_replica_number;
|
||||
new_paxos_replica_number = 0 == new_paxos_replica_number
|
||||
? orig_paxos_replica_number
|
||||
: new_paxos_replica_number;
|
||||
}
|
||||
// If [orig_paxos_replica_number] not specified in obadmin command,
|
||||
// use leader replica's info as default
|
||||
orig_paxos_replica_number = 0 == orig_paxos_replica_number
|
||||
? palf_stat.paxos_replica_num_
|
||||
: orig_paxos_replica_number;
|
||||
new_paxos_replica_number = 0 == new_paxos_replica_number
|
||||
? orig_paxos_replica_number
|
||||
: new_paxos_replica_number;
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_ISNULL(ObCurTraceId::get_trace_id())) {
|
||||
@ -391,6 +387,7 @@ int ObAdminDRTaskUtil::construct_remove_nonpaxos_task_arg_(
|
||||
const uint64_t &tenant_id,
|
||||
const share::ObLSID &ls_id,
|
||||
const common::ObAddr &target_server,
|
||||
const ObReplicaType &replica_type,
|
||||
ObAdminDRTaskRetComment &ret_comment,
|
||||
ObLSDropNonPaxosReplicaArg &remove_nonpaxos_arg)
|
||||
{
|
||||
@ -401,9 +398,11 @@ int ObAdminDRTaskUtil::construct_remove_nonpaxos_task_arg_(
|
||||
palf::PalfStat palf_stat;
|
||||
|
||||
if (OB_UNLIKELY(!ls_id.is_valid_with_tenant(tenant_id))
|
||||
|| OB_UNLIKELY(!target_server.is_valid())) {
|
||||
|| OB_UNLIKELY(!target_server.is_valid())
|
||||
|| OB_UNLIKELY(!ObReplicaTypeCheck::is_non_paxos_replica(replica_type))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid tenant_id or ls_id", KR(ret), K(tenant_id), K(ls_id), K(target_server));
|
||||
LOG_WARN("invalid arguments for remove_non_paxos_task", KR(ret), K(tenant_id), K(ls_id),
|
||||
K(target_server), K(replica_type));
|
||||
} else if (OB_FAIL(get_local_palf_stat_(tenant_id, ls_id, palf_stat, ret_comment))) {
|
||||
LOG_WARN("fail to get local palf stat", KR(ret), K(tenant_id), K(ls_id));
|
||||
} else if (OB_UNLIKELY(!palf_stat.is_valid())) {
|
||||
@ -414,18 +413,15 @@ int ObAdminDRTaskUtil::construct_remove_nonpaxos_task_arg_(
|
||||
LOG_WARN("replica not found in learner_list", KR(ret), K(target_server), K(palf_stat));
|
||||
} else if (OB_FAIL(palf_stat.learner_list_.get_learner_by_addr(target_server, member))) {
|
||||
LOG_WARN("fail to get member from learner_list", KR(ret), K(palf_stat), K(target_server));
|
||||
} else {
|
||||
member_to_remove = ObReplicaMember(member);
|
||||
if (OB_FAIL(member_to_remove.set_replica_type(REPLICA_TYPE_READONLY))) {
|
||||
LOG_WARN("fail to set replica type for member to remove", KR(ret));
|
||||
} else if (OB_ISNULL(ObCurTraceId::get_trace_id())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret));
|
||||
} else if (OB_FAIL(remove_nonpaxos_arg.init(
|
||||
*ObCurTraceId::get_trace_id()/*task_id*/, tenant_id,
|
||||
ls_id, member_to_remove))) {
|
||||
LOG_WARN("fail to init arg", KR(ret), K(tenant_id), K(ls_id), K(member_to_remove));
|
||||
}
|
||||
} else if (OB_FAIL(member_to_remove.init(member, replica_type))) {
|
||||
LOG_WARN("fail to init member_to_remove", KR(ret), K(member), K(replica_type));
|
||||
} else if (OB_ISNULL(ObCurTraceId::get_trace_id())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret));
|
||||
} else if (OB_FAIL(remove_nonpaxos_arg.init(
|
||||
*ObCurTraceId::get_trace_id()/*task_id*/, tenant_id,
|
||||
ls_id, member_to_remove))) {
|
||||
LOG_WARN("fail to init arg", KR(ret), K(tenant_id), K(ls_id), K(member_to_remove));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -594,11 +590,10 @@ int ObAdminDRTaskUtil::parse_params_from_obadmin_command_arg(
|
||||
ls_id = share::ObLSID(ls_id_to_set);
|
||||
}
|
||||
} else if (0 == param_name.string().case_compare("replica_type")) {
|
||||
if (OB_FAIL(share::ObLocalityParser::parse_type(
|
||||
param_value.ptr(),
|
||||
param_value.length(),
|
||||
replica_type))) {
|
||||
LOG_WARN("fail to parse replica type", KR(ret), K(param_name_with_value), K(replica_type));
|
||||
replica_type = share::ObShareUtil::string_to_replica_type(param_value.ptr());
|
||||
if (! ObReplicaTypeCheck::is_replica_type_valid(replica_type)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid replica_type", KR(ret), K(param_name_with_value), K(replica_type));
|
||||
}
|
||||
} else if (0 == param_name.string().case_compare("orig_paxos_replica_number")) {
|
||||
if (OB_FAIL(extract_int(param_value.string(), 0, pos, orig_paxos_replica_number))) {
|
||||
|
@ -89,12 +89,14 @@ private:
|
||||
// params[in] tenant_id, specified tenant_id
|
||||
// params[in] ls_id, specified ls_id
|
||||
// params[in] target_server, the replica to remove on which server
|
||||
// params[in] replica_type, the replica type to remove, could be R or C
|
||||
// params[out] ret_comment, failed reason
|
||||
// params[out] remove_non_paxos_arg, arg for remove-R task
|
||||
static int construct_remove_nonpaxos_task_arg_(
|
||||
const uint64_t &tenant_id,
|
||||
const share::ObLSID &ls_id,
|
||||
const common::ObAddr &target_server,
|
||||
const ObReplicaType &replica_type,
|
||||
ObAdminDRTaskRetComment &ret_comment,
|
||||
ObLSDropNonPaxosReplicaArg &remove_nonpaxos_arg);
|
||||
|
||||
|
@ -44,19 +44,6 @@ class ObUnitManager;
|
||||
|
||||
class ObZoneManager;
|
||||
|
||||
class ObDataSourceCandidateChecker
|
||||
{
|
||||
public:
|
||||
ObDataSourceCandidateChecker(common::ObReplicaType type) : this_type_(type) {}
|
||||
inline bool is_candidate(common::ObReplicaType other_type) const
|
||||
{
|
||||
// TODO: Use a more refined way, such as this_type_ = F, you can have other_type = R
|
||||
return common::ObReplicaTypeCheck::can_as_data_source(this_type_, other_type);
|
||||
}
|
||||
private:
|
||||
common::ObReplicaType this_type_;
|
||||
};
|
||||
|
||||
class ObStatisticsCalculator
|
||||
{
|
||||
public:
|
||||
|
@ -3413,15 +3413,22 @@ int ObDDLService::set_raw_table_options(
|
||||
}
|
||||
|
||||
int ObDDLService::check_locality_compatible_(
|
||||
ObTenantSchema &schema)
|
||||
ObTenantSchema &schema,
|
||||
const bool for_create_tenant)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
common::ObArray<share::ObZoneReplicaAttrSet> zone_locality;
|
||||
const uint64_t tenant_id = for_create_tenant ? OB_SYS_TENANT_ID : schema.get_tenant_id();
|
||||
bool is_compatible_with_readonly_replica = false;
|
||||
bool is_compatible_with_columnstore_replica = false;
|
||||
if (OB_FAIL(ObShareUtil::check_compat_version_for_readonly_replica(
|
||||
schema.get_tenant_id(), is_compatible_with_readonly_replica))) {
|
||||
tenant_id, is_compatible_with_readonly_replica))) {
|
||||
LOG_WARN("fail to check compatible with readonly replica", KR(ret), K(schema));
|
||||
} else if (is_compatible_with_readonly_replica) {
|
||||
} else if (OB_FAIL(ObShareUtil::check_compat_version_for_columnstore_replica(
|
||||
tenant_id, is_compatible_with_columnstore_replica))) {
|
||||
LOG_WARN("fail to check compatible with columnstore replica", KR(ret), K(schema));
|
||||
} else if (is_compatible_with_readonly_replica && is_compatible_with_columnstore_replica) {
|
||||
// check pass
|
||||
} else if (OB_FAIL(schema.get_zone_replica_attr_array(zone_locality))) {
|
||||
LOG_WARN("fail to get locality from schema", K(ret), K(schema));
|
||||
} else {
|
||||
@ -3430,10 +3437,16 @@ int ObDDLService::check_locality_compatible_(
|
||||
if (this_set.zone_set_.count() <= 0) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("zone set count unexpected", K(ret), "zone_set_cnt", this_set.zone_set_.count());
|
||||
} else if (0 != this_set.get_readonly_replica_num()) {
|
||||
} else if (! is_compatible_with_readonly_replica
|
||||
&& 0 != this_set.get_readonly_replica_num()) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("can not create tenant with read-only replica below data version 4.2", KR(ret));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "Create tenant with R-replica in locality below data version 4.2");
|
||||
} else if (! is_compatible_with_columnstore_replica
|
||||
&& 0 != this_set.get_columnstore_replica_num()) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("can not create tenant with column-store replica below data version 4.3.3", KR(ret));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "Create tenant with C-replica in locality below data version 4.3.3");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -27298,7 +27311,7 @@ int ObDDLService::set_new_tenant_options(
|
||||
} else if (OB_FAIL(parse_and_set_create_tenant_new_locality_options(
|
||||
schema_guard, new_tenant_schema, resource_pool_names, zones_in_pool, zone_region_list))) {
|
||||
LOG_WARN("fail to parse and set new locality option", K(ret));
|
||||
} else if (OB_FAIL(check_locality_compatible_(new_tenant_schema))) {
|
||||
} else if (OB_FAIL(check_locality_compatible_(new_tenant_schema, false /*for_create_tenant*/))) {
|
||||
LOG_WARN("fail to check locality with data version", KR(ret), K(new_tenant_schema));
|
||||
} else if (OB_FAIL(check_alter_tenant_locality_type(
|
||||
schema_guard, orig_tenant_schema, new_tenant_schema, alter_locality_type))) {
|
||||
@ -30301,6 +30314,8 @@ int ObDDLService::check_create_tenant_locality(
|
||||
} else if (OB_FAIL(parse_and_set_create_tenant_new_locality_options(
|
||||
schema_guard, tenant_schema, pools, pool_zones, zone_region_list))) {
|
||||
LOG_WARN("fail to parse and set new locality option", K(ret));
|
||||
} else if (OB_FAIL(check_locality_compatible_(tenant_schema, true /*for_create_tenant*/))) {
|
||||
LOG_WARN("fail to check locality with data version", KR(ret), K(tenant_schema));
|
||||
} else if (OB_FAIL(check_pools_unit_num_enough_for_schema_locality(
|
||||
pools, schema_guard, tenant_schema))) {
|
||||
LOG_WARN("pools unit num is not enough for locality", K(ret));
|
||||
|
@ -2753,7 +2753,7 @@ private:
|
||||
common::ObIArray<common::ObConfigPairs> &init_configs);
|
||||
|
||||
private:
|
||||
int check_locality_compatible_(ObTenantSchema &schema);
|
||||
int check_locality_compatible_(ObTenantSchema &schema, const bool for_create_tenant);
|
||||
|
||||
int pre_rename_mysql_columns_online(const ObTableSchema &origin_table_schema,
|
||||
const AlterTableSchema &alter_table_schema,
|
||||
|
@ -254,34 +254,6 @@ const char *ob_disaster_recovery_task_type_strs(const rootserver::ObDRTaskType t
|
||||
return str;
|
||||
}
|
||||
|
||||
const char *ob_replica_type_strs(const ObReplicaType type)
|
||||
{
|
||||
const char *str = NULL;
|
||||
switch (type) {
|
||||
case ObReplicaType::REPLICA_TYPE_FULL: {
|
||||
str = "FULL";
|
||||
break;
|
||||
}
|
||||
case ObReplicaType::REPLICA_TYPE_LOGONLY: {
|
||||
str = "LOGONLY";
|
||||
break;
|
||||
}
|
||||
case ObReplicaType::REPLICA_TYPE_READONLY: {
|
||||
str = "READONLY";
|
||||
break;
|
||||
}
|
||||
case ObReplicaType::REPLICA_TYPE_ENCRYPTION_LOGONLY: {
|
||||
str = "ENCRYPTION_LOGONLY";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
LOG_WARN_RET(OB_ERR_UNEXPECTED, "invalid replica type", K(type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
bool ObDRTaskKey::is_valid() const
|
||||
{
|
||||
return key_type_ > ObDRTaskKeyType::INVALID
|
||||
@ -558,8 +530,7 @@ int ObMigrateLSReplicaTask::get_execute_transmit_size(
|
||||
int ret = OB_SUCCESS;
|
||||
execute_transmit_size = 0;
|
||||
ObReplicaType dst_replica_type = dst_replica_.get_replica_type();
|
||||
if (REPLICA_TYPE_FULL == dst_replica_type
|
||||
|| REPLICA_TYPE_READONLY == dst_replica_type) {
|
||||
if (ObReplicaTypeCheck::is_replica_type_valid(dst_replica_type)) {
|
||||
execute_transmit_size = transmit_data_size_;
|
||||
} else if (REPLICA_TYPE_LOGONLY == dst_replica_type
|
||||
|| REPLICA_TYPE_ENCRYPTION_LOGONLY == dst_replica_type) {
|
||||
@ -717,11 +688,11 @@ int ObMigrateLSReplicaTask::fill_dml_splicer(
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_svr_ip", dest_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_svr_port", get_dst_server().get_port()))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_paxos_replica_number", get_paxos_replica_number()))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_type", ob_replica_type_strs(get_dst_replica().get_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_type", ObShareUtil::replica_type_to_string(get_dst_replica().get_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_svr_ip", src_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_svr_port", get_src_member().get_server().get_port()))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_paxos_replica_number", get_paxos_replica_number()))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_type", ob_replica_type_strs(get_src_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_type", ObShareUtil::replica_type_to_string(get_src_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("task_exec_svr_ip", dest_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("task_exec_svr_port", get_dst_server().get_port()))) {
|
||||
LOG_WARN("add column failed", KR(ret));
|
||||
@ -991,6 +962,7 @@ int ObMigrateLSReplicaTask::build_task_from_sql_result(
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "target_replica_svr_port", dest_port);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "source_paxos_replica_number", src_paxos_replica_number);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_varchar, "comment", comment);
|
||||
// TODO(cangming.zl): get src_replica_type and dest_replica_type from result
|
||||
EXTRACT_INT_FIELD_MYSQL_WITH_DEFAULT_VALUE(res, "data_source_svr_port", data_source_port,
|
||||
int64_t, true/*skip null error*/, true/*skip column error*/, 0);
|
||||
EXTRACT_VARCHAR_FIELD_MYSQL_WITH_DEFAULT_VALUE(res, "data_source_svr_ip", data_source_ip,
|
||||
@ -1081,8 +1053,7 @@ int ObAddLSReplicaTask::get_execute_transmit_size(
|
||||
int ret = OB_SUCCESS;
|
||||
execute_transmit_size = 0;
|
||||
ObReplicaType dst_replica_type = dst_replica_.get_replica_type();
|
||||
if (REPLICA_TYPE_FULL == dst_replica_type
|
||||
|| REPLICA_TYPE_READONLY == dst_replica_type) {
|
||||
if (ObReplicaTypeCheck::is_replica_type_valid(dst_replica_type)) {
|
||||
execute_transmit_size = transmit_data_size_;
|
||||
} else if (REPLICA_TYPE_LOGONLY == dst_replica_type
|
||||
|| REPLICA_TYPE_ENCRYPTION_LOGONLY == dst_replica_type) {
|
||||
@ -1224,11 +1195,11 @@ int ObAddLSReplicaTask::fill_dml_splicer(
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_svr_ip", dest_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_svr_port", get_dst_server().get_port()))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_paxos_replica_number", get_paxos_replica_number()))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_type", ob_replica_type_strs(get_dst_replica().get_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_type", ObShareUtil::replica_type_to_string(get_dst_replica().get_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_svr_ip", src_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_svr_port", get_data_src_member().get_server().get_port()))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_paxos_replica_number", get_orig_paxos_replica_number()))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_type", ob_replica_type_strs(get_dst_replica().get_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_type", ObShareUtil::replica_type_to_string(get_dst_replica().get_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("task_exec_svr_ip", dest_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("task_exec_svr_port", get_dst_server().get_port()))) {
|
||||
LOG_WARN("add column failed", KR(ret));
|
||||
@ -1505,6 +1476,7 @@ int ObAddLSReplicaTask::build_task_from_sql_result(
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "source_paxos_replica_number", src_paxos_replica_number);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "target_paxos_replica_number", dest_paxos_replica_number);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_varchar, "comment", comment);
|
||||
// TODO(cangming.zl): get src_replica_type and dest_replica_type from result
|
||||
EXTRACT_INT_FIELD_MYSQL_WITH_DEFAULT_VALUE(res, "data_source_svr_port", data_source_port,
|
||||
int64_t, true/*skip null error*/, true/*skip column error*/, 0);
|
||||
EXTRACT_VARCHAR_FIELD_MYSQL_WITH_DEFAULT_VALUE(res, "data_source_svr_ip", data_source_ip,
|
||||
@ -1751,11 +1723,11 @@ int ObLSTypeTransformTask::fill_dml_splicer(
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_svr_ip", dest_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_svr_port", get_dst_server().get_port()))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_paxos_replica_number", get_paxos_replica_number()))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_type", ob_replica_type_strs(get_dst_replica().get_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_type", ObShareUtil::replica_type_to_string(get_dst_replica().get_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_svr_ip", src_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_svr_port", get_src_member().get_server().get_port()))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_paxos_replica_number", get_orig_paxos_replica_number()))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_type", ob_replica_type_strs(get_src_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_type", ObShareUtil::replica_type_to_string(get_src_member().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("task_exec_svr_ip", dest_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("task_exec_svr_port", get_dst_server().get_port()))) {
|
||||
LOG_WARN("add column failed", KR(ret));
|
||||
@ -1985,8 +1957,8 @@ int ObLSTypeTransformTask::build_task_from_sql_result(
|
||||
int64_t transmit_data_size = 0;
|
||||
int64_t src_paxos_replica_number = OB_INVALID_COUNT;
|
||||
int64_t dest_paxos_replica_number = OB_INVALID_COUNT;
|
||||
common::ObString src_type;
|
||||
common::ObString dest_type;
|
||||
common::ObString src_type_str;
|
||||
common::ObString dest_type_str;
|
||||
int64_t schedule_time_us = 0;
|
||||
int64_t generate_time_us = 0;
|
||||
common::ObString comment;
|
||||
@ -2010,8 +1982,8 @@ int ObLSTypeTransformTask::build_task_from_sql_result(
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "target_replica_svr_port", dest_port);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "source_paxos_replica_number", src_paxos_replica_number);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "target_paxos_replica_number", dest_paxos_replica_number);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_varchar, "source_replica_type", src_type);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_varchar, "target_replica_type", dest_type);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_varchar, "source_replica_type", src_type_str);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_varchar, "target_replica_type", dest_type_str);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_varchar, "comment", comment);
|
||||
EXTRACT_BOOL_FIELD_MYSQL_SKIP_RET(res, "is_manual", is_manual);
|
||||
//STEP2_0: make necessary members to build a task
|
||||
@ -2020,8 +1992,8 @@ int ObLSTypeTransformTask::build_task_from_sql_result(
|
||||
common::ObAddr dest_server;
|
||||
common::ObString zone;
|
||||
rootserver::ObDRTaskPriority priority_to_set;
|
||||
ObReplicaType src_type_to_set = REPLICA_TYPE_MAX;
|
||||
ObReplicaType dest_type_to_set = REPLICA_TYPE_MAX;
|
||||
ObReplicaType src_type_to_set = ObShareUtil::string_to_replica_type(src_type_str);
|
||||
ObReplicaType dest_type_to_set = ObShareUtil::string_to_replica_type(dest_type_str);
|
||||
ObDstReplica dst_replica;
|
||||
share::ObTaskId task_id_to_set;
|
||||
ObSqlString comment_to_set;
|
||||
@ -2048,18 +2020,6 @@ int ObLSTypeTransformTask::build_task_from_sql_result(
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid server address", K(dest_ip), K(dest_port));
|
||||
} else {
|
||||
//transform replica_type(string) -> src_type_to_set(ObReplicaType)
|
||||
if (src_type == common::ObString("FULL")) {
|
||||
src_type_to_set = REPLICA_TYPE_FULL;
|
||||
} else if (src_type == common::ObString("READONLY")) {
|
||||
src_type_to_set = REPLICA_TYPE_READONLY;
|
||||
}
|
||||
//transform replica_type(string) -> dest_type_to_set(ObReplicaType)
|
||||
if (dest_type == common::ObString("FULL")) {
|
||||
dest_type_to_set = REPLICA_TYPE_FULL;
|
||||
} else if (dest_type == common::ObString("READONLY")) {
|
||||
dest_type_to_set = REPLICA_TYPE_READONLY;
|
||||
}
|
||||
//transform priority(int) -> priority_to_set(ObDRTaskPriority)
|
||||
if (priority == 0) {
|
||||
priority_to_set = ObDRTaskPriority::HIGH_PRI;
|
||||
@ -2068,12 +2028,12 @@ int ObLSTypeTransformTask::build_task_from_sql_result(
|
||||
} else {
|
||||
priority_to_set = ObDRTaskPriority::MAX_PRI;
|
||||
}
|
||||
ObReplicaMember src_member(src_server, 0);
|
||||
ObReplicaMember dest_member(dest_server, 0);
|
||||
if (OB_FAIL(src_member.set_replica_type(src_type_to_set))) {
|
||||
LOG_WARN("fail to set src replica type", KR(ret), K(src_type_to_set));
|
||||
} else if (OB_FAIL(dest_member.set_replica_type(dest_type_to_set))) {
|
||||
LOG_WARN("fail to set dest replica type", KR(ret), K(dest_type_to_set));
|
||||
ObReplicaMember src_member;
|
||||
ObReplicaMember dest_member;
|
||||
if (OB_FAIL(src_member.init(src_server, 0, src_type_to_set))) {
|
||||
LOG_WARN("failed to init src_member", KR(ret), K(src_server), K(src_type_str), K(src_type_to_set));
|
||||
} else if (OB_FAIL(dest_member.init(dest_server, 0, dest_type_to_set))) {
|
||||
LOG_WARN("failed to init dest_member", KR(ret), K(dest_server), K(dest_type_str), K(dest_type_to_set));
|
||||
} else if (OB_FAIL(dst_replica.assign(
|
||||
0/*unit id*/,
|
||||
0/*unit group id*/,
|
||||
@ -2251,7 +2211,7 @@ int ObRemoveLSReplicaTask::fill_dml_splicer(
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_svr_ip", target_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_svr_port", get_remove_server().get_server().get_port()))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_paxos_replica_number", get_paxos_replica_number()))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_type", ob_replica_type_strs(get_remove_server().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("target_replica_type", ObShareUtil::replica_type_to_string(get_remove_server().get_replica_type())))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_svr_ip", src_ip))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_replica_svr_port", 0))
|
||||
|| OB_FAIL(dml_splicer.add_column("source_paxos_replica_number", get_orig_paxos_replica_number()))
|
||||
@ -2374,7 +2334,7 @@ int ObRemoveLSReplicaTask::simple_build(
|
||||
|| !remove_server.is_valid()
|
||||
|| orig_paxos_replica_number <= 0
|
||||
|| paxos_replica_number <= 0
|
||||
|| REPLICA_TYPE_MAX == replica_type)) {
|
||||
|| !ObReplicaTypeCheck::is_replica_type_valid(replica_type))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id), K(ls_id), K(task_id),
|
||||
K(leader), K(remove_server), K(orig_paxos_replica_number),
|
||||
@ -2422,7 +2382,7 @@ int ObRemoveLSReplicaTask::build_task_from_sql_result(
|
||||
int64_t schedule_time_us = 0;
|
||||
int64_t generate_time_us = 0;
|
||||
common::ObString comment;
|
||||
ObReplicaType replica_type = REPLICA_TYPE_MAX;
|
||||
common::ObString replica_type_str;
|
||||
bool is_manual = false;
|
||||
//STEP1_0: read certain members from sql result
|
||||
EXTRACT_INT_FIELD_MYSQL(res, "tenant_id", tenant_id, uint64_t);
|
||||
@ -2442,6 +2402,7 @@ int ObRemoveLSReplicaTask::build_task_from_sql_result(
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "task_exec_svr_port", dest_port);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_varchar, "target_replica_svr_ip", target_ip);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "target_replica_svr_port", target_port);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_varchar, "target_replica_type", replica_type_str);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "source_paxos_replica_number", src_paxos_replica_number);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_int, "target_paxos_replica_number", dest_paxos_replica_number);
|
||||
(void)GET_COL_IGNORE_NULL(res.get_varchar, "comment", comment);
|
||||
@ -2453,7 +2414,7 @@ int ObRemoveLSReplicaTask::build_task_from_sql_result(
|
||||
rootserver::ObDRTaskPriority priority_to_set;
|
||||
share::ObTaskId task_id_to_set;
|
||||
ObSqlString comment_to_set;
|
||||
ObSqlString task_id_sqlstring_format;
|
||||
ObSqlString task_id_sqlstring_format; // for adding trailing null
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(comment_to_set.assign(comment))) {
|
||||
@ -2484,13 +2445,21 @@ int ObRemoveLSReplicaTask::build_task_from_sql_result(
|
||||
} else {
|
||||
priority_to_set = ObDRTaskPriority::MAX_PRI;
|
||||
}
|
||||
//transform task_type(string) -> replica_type(ObReplicaType)
|
||||
// get replica_type_ from replica_type_str and check whether or not match with task_type.
|
||||
replica_type_ = ObShareUtil::string_to_replica_type(replica_type_str);
|
||||
if (0 == task_type.case_compare(ob_disaster_recovery_task_type_strs(ObDRTaskType::LS_REMOVE_PAXOS_REPLICA))) {
|
||||
replica_type_ = ObReplicaType::REPLICA_TYPE_FULL;
|
||||
if (OB_UNLIKELY(REPLICA_TYPE_FULL != replica_type_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("task_type and replica_type do not match", KR(ret), K(task_type), K(replica_type_));
|
||||
}
|
||||
} else if (0 == task_type.case_compare(ob_disaster_recovery_task_type_strs(ObDRTaskType::LS_REMOVE_NON_PAXOS_REPLICA))) {
|
||||
replica_type_ = ObReplicaType::REPLICA_TYPE_READONLY;
|
||||
if (OB_UNLIKELY(! ObReplicaTypeCheck::is_non_paxos_replica(replica_type_))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("task_type and replica_type do not match", KR(ret), K(task_type), K(replica_type_));
|
||||
}
|
||||
} else {
|
||||
replica_type_ = ObReplicaType::REPLICA_TYPE_MAX;
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected task_type", KR(ret), K(task_type));
|
||||
}
|
||||
}
|
||||
//STEP3_0: to build a task
|
||||
|
@ -128,7 +128,7 @@ bool ObLSReplicaTaskDisplayInfo::is_valid() const
|
||||
&& task_type_ != ObDRTaskType::MAX_TYPE
|
||||
&& task_priority_ != ObDRTaskPriority::MAX_PRI
|
||||
&& target_server_.is_valid()
|
||||
&& target_replica_type_ != REPLICA_TYPE_MAX
|
||||
&& target_replica_type_ != REPLICA_TYPE_INVALID
|
||||
&& target_replica_paxos_replica_number_ != OB_INVALID_COUNT
|
||||
&& source_replica_paxos_replica_number_ != OB_INVALID_COUNT
|
||||
&& execute_server_.is_valid();
|
||||
@ -293,6 +293,9 @@ int ObDRWorker::LocalityAlignment::build_locality_stat_map()
|
||||
// readonly locality
|
||||
const ObIArray<ReplicaAttr> &readonly_locality =
|
||||
zone_locality.replica_attr_set_.get_readonly_replica_attr_array();
|
||||
// columnstore locality
|
||||
const ObIArray<ReplicaAttr> &columnstore_locality =
|
||||
zone_locality.replica_attr_set_.get_columnstore_replica_attr_array();
|
||||
|
||||
if (OB_FAIL(locate_zone_locality(zone, zone_replica_desc))) {
|
||||
LOG_WARN("fail to locate zone locality", KR(ret), K(zone));
|
||||
@ -336,11 +339,17 @@ int ObDRWorker::LocalityAlignment::build_locality_stat_map()
|
||||
LOG_WARN("fail to push back", KR(ret));
|
||||
}
|
||||
}
|
||||
// readonly replica, all_server
|
||||
// readonly or colmnstore replica, all_server
|
||||
if (dr_ls_info_.is_duplicate_ls()) {
|
||||
// duplicate ls, should has R-replica all_server
|
||||
zone_replica_desc->is_readonly_all_server_ = true;
|
||||
zone_replica_desc->readonly_memstore_percent_ = 100;
|
||||
// duplicate ls, should has R-replica or C-replica all_server
|
||||
// if locality is C, then set columnstore_all_server.
|
||||
// if locality is F/R, then set readonly_all_server,
|
||||
if (columnstore_locality.count() > 0) {
|
||||
// dup_ls must not be sys_ls
|
||||
zone_replica_desc->set_columnstore_all_server();
|
||||
} else {
|
||||
zone_replica_desc->set_readonly_all_server();
|
||||
}
|
||||
} else {
|
||||
// readonly replica, normal
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < readonly_locality.count(); ++j) {
|
||||
@ -354,6 +363,22 @@ int ObDRWorker::LocalityAlignment::build_locality_stat_map()
|
||||
LOG_WARN("fail to push back", KR(ret));
|
||||
}
|
||||
}
|
||||
// columnstore replica, normal
|
||||
if (ls_id.is_sys_ls()) {
|
||||
// for sys ls, ignore C-replica in locality
|
||||
} else {
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < columnstore_locality.count(); ++j) {
|
||||
const ReplicaAttr &replica_attr = columnstore_locality.at(j);
|
||||
if (0 >= replica_attr.num_) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("replica num unexpected", KR(ret), K(zone), K(columnstore_locality));
|
||||
} else if (OB_FAIL(zone_replica_desc->push_back(ReplicaDesc(REPLICA_TYPE_COLUMNSTORE,
|
||||
replica_attr.memstore_percent_,
|
||||
replica_attr.num_)))) {
|
||||
LOG_WARN("fail to push back", KR(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG_INFO("ls zone locality map info", K(zone), KPC(zone_replica_desc));
|
||||
@ -592,6 +617,16 @@ int ObDRWorker::LocalityAlignment::do_generate_locality_task_from_full_replica(
|
||||
} else {
|
||||
found = true;
|
||||
}
|
||||
} else if (ObReplicaTypeCheck::is_columnstore_replica(replica_desc.replica_type_)) {
|
||||
// if zone_locality is C-replica, remove this F-replica
|
||||
// because transform from F to C is not supported
|
||||
if (OB_FAIL(generate_remove_replica_task(replica_stat_desc))) {
|
||||
LOG_WARN("fail to generate remove replica task", KR(ret));
|
||||
} else if (OB_FAIL(replica_stat_map_.remove(index))) {
|
||||
LOG_WARN("fail to remove", KR(ret));
|
||||
} else {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// process not found
|
||||
@ -599,11 +634,18 @@ int ObDRWorker::LocalityAlignment::do_generate_locality_task_from_full_replica(
|
||||
// failed
|
||||
} else if (found) {
|
||||
// found, bypass
|
||||
} else if (zone_replica_desc->is_readonly_all_server_) {
|
||||
} else if (zone_replica_desc->is_columnstore_all_server()) {
|
||||
// remove this F, because transform from F to C is not supported
|
||||
if (OB_FAIL(generate_remove_replica_task(replica_stat_desc))) {
|
||||
LOG_WARN("fail to generate remove replica task", KR(ret));
|
||||
} else if (OB_FAIL(replica_stat_map_.remove(index))) {
|
||||
LOG_WARN("fail to remove", KR(ret));
|
||||
}
|
||||
} else if (zone_replica_desc->is_readonly_all_server()) {
|
||||
if (OB_FAIL(generate_type_transform_task(
|
||||
replica_stat_desc,
|
||||
REPLICA_TYPE_READONLY,
|
||||
zone_replica_desc->readonly_memstore_percent_))) {
|
||||
zone_replica_desc->get_readonly_memstore_percent()))) {
|
||||
LOG_WARN("fail to generate type transform task", KR(ret), K(replica_stat_desc));
|
||||
} else if (OB_FAIL(replica_stat_map_.remove(index))) {
|
||||
LOG_WARN("fail to remove", KR(ret), K(index), K(replica), K(replica_stat_map_));
|
||||
@ -715,7 +757,7 @@ int ObDRWorker::LocalityAlignment::do_generate_locality_task_from_encryption_log
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDRWorker::LocalityAlignment::try_generate_type_transform_task_for_readonly_replica_(
|
||||
int ObDRWorker::LocalityAlignment::try_generate_task_for_readonly_replica_(
|
||||
ReplicaDescArray &zone_replica_desc_in_locality,
|
||||
ReplicaStatDesc &replica_stat_desc,
|
||||
const int64_t index,
|
||||
@ -732,6 +774,15 @@ int ObDRWorker::LocalityAlignment::try_generate_type_transform_task_for_readonly
|
||||
if (REPLICA_TYPE_READONLY == replica_desc.replica_type_) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("replica type unexpected", KR(ret), K(dr_ls_info_));
|
||||
} else if (ObReplicaTypeCheck::is_columnstore_replica(replica_desc.replica_type_)) {
|
||||
// if locality is C-replica, remove this R-replica because transform from R to C is not supported
|
||||
if (OB_FAIL(generate_remove_replica_task(replica_stat_desc))) {
|
||||
LOG_WARN("fail to generate remove replica task", KR(ret), K(replica_stat_desc));
|
||||
} else if (OB_FAIL(replica_stat_map_.remove(index))) {
|
||||
LOG_WARN("fail to remove", KR(ret), K(replica_stat_map_), K(index));
|
||||
} else {
|
||||
task_generated = true;
|
||||
}
|
||||
} else if (REPLICA_TYPE_FULL == replica_desc.replica_type_) {
|
||||
if (OB_ISNULL(replica_stat_desc.unit_stat_info_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
@ -764,7 +815,7 @@ int ObDRWorker::LocalityAlignment::try_generate_type_transform_task_for_readonly
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDRWorker::LocalityAlignment::try_generate_remove_readonly_task_for_duplicate_log_stream_(
|
||||
int ObDRWorker::LocalityAlignment::try_generate_remove_redundant_replica_task_for_dup_ls_(
|
||||
ReplicaStatDesc &replica_stat_desc,
|
||||
share::ObLSReplica &replica,
|
||||
const int64_t index)
|
||||
@ -829,15 +880,23 @@ int ObDRWorker::LocalityAlignment::do_generate_locality_task_from_readonly_repli
|
||||
bool task_generated = false;
|
||||
lib::ob_sort(zone_replica_desc->begin(), zone_replica_desc->end());
|
||||
// try to generate type_transform task if needed
|
||||
if (OB_FAIL(try_generate_type_transform_task_for_readonly_replica_(
|
||||
if (OB_FAIL(try_generate_task_for_readonly_replica_(
|
||||
*zone_replica_desc, replica_stat_desc, index, task_generated))) {
|
||||
LOG_WARN("fail to try generate type transform task", KR(ret),
|
||||
KPC(zone_replica_desc), K(replica_stat_desc), K(index), K(task_generated));
|
||||
} else if (task_generated) {
|
||||
// a type transform task generated, bypass
|
||||
} else if (zone_replica_desc->is_readonly_all_server_) {
|
||||
// for duplicate log stream, try to remove redudant R-replicas
|
||||
if (OB_FAIL(try_generate_remove_readonly_task_for_duplicate_log_stream_(replica_stat_desc, replica, index))) {
|
||||
// a type transform task or remove task generated, bypass
|
||||
} else if (zone_replica_desc->is_columnstore_all_server()) {
|
||||
// for duplicate log stream, if locality is C-replica, remove this R-replica
|
||||
// because transform from R to C is not supported
|
||||
if (OB_FAIL(generate_remove_replica_task(replica_stat_desc))) {
|
||||
LOG_WARN("fail to generate remove replica task", KR(ret), K(replica_stat_desc));
|
||||
} else if (OB_FAIL(replica_stat_map_.remove(index))) {
|
||||
LOG_WARN("fail to remove", KR(ret), K(replica_stat_map_), K(index));
|
||||
}
|
||||
} else if (zone_replica_desc->is_readonly_all_server()) {
|
||||
// for duplicate log stream, if locality is R-replica, try to remove redudant R-replicas
|
||||
if (OB_FAIL(try_generate_remove_redundant_replica_task_for_dup_ls_(replica_stat_desc, replica, index))) {
|
||||
LOG_WARN("fail to generate remove replica task for duplicate log stream",
|
||||
KR(ret), K(replica_stat_desc), K(replica), K(index));
|
||||
}
|
||||
@ -890,6 +949,65 @@ int ObDRWorker::LocalityAlignment::try_generate_locality_task_from_paxos_replica
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDRWorker::LocalityAlignment::do_generate_locality_task_from_columnstore_replica(
|
||||
ReplicaStatDesc &replica_stat_desc,
|
||||
share::ObLSReplica &replica,
|
||||
const int64_t index)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const common::ObZone &zone = replica.get_zone();
|
||||
if (REPLICA_TYPE_COLUMNSTORE != replica.get_replica_type()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("replica type unexpected", KR(ret), K(replica));
|
||||
} else {
|
||||
ReplicaDescArray *zone_replica_desc = nullptr;
|
||||
int tmp_ret = locality_map_.get_refactored(zone, zone_replica_desc);
|
||||
if (OB_HASH_NOT_EXIST == tmp_ret) {
|
||||
if (OB_FAIL(generate_remove_replica_task(replica_stat_desc))) {
|
||||
LOG_WARN("fail to generate remove replica task", KR(ret), K(replica_stat_desc));
|
||||
} else if (OB_FAIL(replica_stat_map_.remove(index))) {
|
||||
LOG_WARN("fail to remove", KR(ret), K(replica_stat_map_), K(index));
|
||||
}
|
||||
} else if (OB_SUCCESS == tmp_ret && OB_NOT_NULL(zone_replica_desc)) {
|
||||
bool task_generated = false;
|
||||
lib::ob_sort(zone_replica_desc->begin(), zone_replica_desc->end());
|
||||
// defensive check
|
||||
for (int64_t i = zone_replica_desc->count() - 1; OB_SUCC(ret) && i >= 0; --i) {
|
||||
ReplicaDesc &replica_desc = zone_replica_desc->at(i);
|
||||
if (ObReplicaTypeCheck::is_columnstore_replica(replica_desc.replica_type_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("replica type unexpected", KR(ret), K(replica_desc), K(dr_ls_info_));
|
||||
}
|
||||
}
|
||||
// normal routine
|
||||
if (OB_SUCC(ret)) {
|
||||
if (zone_replica_desc->is_columnstore_all_server()) {
|
||||
// for duplicate log stream, if locality is C-replica, try to remove redudant C-replicas
|
||||
if (OB_FAIL(try_generate_remove_redundant_replica_task_for_dup_ls_(replica_stat_desc, replica, index))) {
|
||||
LOG_WARN("fail to generate remove replica task for duplicate log stream",
|
||||
KR(ret), K(replica_stat_desc), K(replica), K(index));
|
||||
}
|
||||
} else {
|
||||
// handle two abnormal occasions:
|
||||
// 1. for duplicate ls, locality is R or F-replica;
|
||||
// 2. for non-duplicate ls, locality is other type than C-replica
|
||||
// in these both occasions, directly remove this C-replica,
|
||||
// because transform from C-replica to R/F is not supported.
|
||||
if (OB_FAIL(generate_remove_replica_task(replica_stat_desc))) {
|
||||
LOG_WARN("fail to generate remove replica task", KR(ret), K(replica_stat_desc));
|
||||
} else if (OB_FAIL(replica_stat_map_.remove(index))) {
|
||||
LOG_WARN("fail to remove", KR(ret), K(replica_stat_map_), K(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to get refactored", KR(ret), K(zone));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObDRWorker::LocalityAlignment::print_locality_information()
|
||||
{
|
||||
for (LocalityMap::iterator iter = locality_map_.begin();
|
||||
@ -945,6 +1063,13 @@ int ObDRWorker::LocalityAlignment::do_generate_locality_task()
|
||||
i))) {
|
||||
LOG_WARN("fail to generate locality task from readonly replica", KR(ret));
|
||||
}
|
||||
} else if (REPLICA_TYPE_COLUMNSTORE == replica->get_replica_type()) {
|
||||
if (OB_FAIL(do_generate_locality_task_from_columnstore_replica(
|
||||
replica_stat_desc,
|
||||
*replica,
|
||||
i))) {
|
||||
LOG_WARN("fail to generate locality task from columnstore replica", KR(ret));
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("replica type unexpected", KR(ret), KPC(replica));
|
||||
@ -1429,7 +1554,7 @@ int ObDRWorker::LocalityAlignment::try_get_normal_locality_alignment_task(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDRWorker::LocalityAlignment::try_get_readonly_all_server_locality_alignment_task(
|
||||
int ObDRWorker::LocalityAlignment::try_get_readonly_or_columnstore_all_server_locality_alignment_task(
|
||||
UnitProvider &unit_provider,
|
||||
const LATask *&task)
|
||||
{
|
||||
@ -1444,7 +1569,8 @@ int ObDRWorker::LocalityAlignment::try_get_readonly_all_server_locality_alignmen
|
||||
if (OB_UNLIKELY(nullptr == replica_desc_array)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("replica desc array ptr is null", KR(ret));
|
||||
} else if (!replica_desc_array->is_readonly_all_server_) {
|
||||
} else if (!replica_desc_array->is_readonly_all_server()
|
||||
&& !replica_desc_array->is_columnstore_all_server()) {
|
||||
// bypass
|
||||
} else if (OB_FAIL(dr_ls_info_.get_ls_status_info(ls_status_info))) {
|
||||
LOG_WARN("fail to get log stream info", KR(ret));
|
||||
@ -1462,8 +1588,9 @@ int ObDRWorker::LocalityAlignment::try_get_readonly_all_server_locality_alignmen
|
||||
add_replica_task_.member_time_us_ = ObTimeUtility::current_time();
|
||||
add_replica_task_.unit_id_ = unit.unit_id_;
|
||||
add_replica_task_.unit_group_id_ = ls_status_info->unit_group_id_;
|
||||
add_replica_task_.replica_type_ = REPLICA_TYPE_READONLY;
|
||||
add_replica_task_.memstore_percent_ = replica_desc_array->readonly_memstore_percent_;
|
||||
add_replica_task_.replica_type_ = replica_desc_array->is_columnstore_all_server() ?
|
||||
REPLICA_TYPE_COLUMNSTORE : REPLICA_TYPE_READONLY;
|
||||
add_replica_task_.memstore_percent_ = replica_desc_array->get_readonly_memstore_percent();
|
||||
add_replica_task_.orig_paxos_replica_number_ = curr_paxos_replica_number_;
|
||||
add_replica_task_.paxos_replica_number_ = curr_paxos_replica_number_;
|
||||
task = &add_replica_task_;
|
||||
@ -1492,7 +1619,7 @@ int ObDRWorker::LocalityAlignment::get_next_locality_alignment_task(
|
||||
} else if (nullptr != task) {
|
||||
// got one
|
||||
LOG_INFO("success to get a normal task", KPC(task));
|
||||
} else if (OB_FAIL(try_get_readonly_all_server_locality_alignment_task(
|
||||
} else if (OB_FAIL(try_get_readonly_or_columnstore_all_server_locality_alignment_task(
|
||||
unit_provider_,
|
||||
task))) {
|
||||
LOG_WARN("fail to get readonly all server locality alignment task", KR(ret));
|
||||
@ -2528,7 +2655,7 @@ int ObDRWorker::get_replica_type_by_leader_(
|
||||
// not leader replica get replica type may not right. when remove or modify replica,
|
||||
// replica type wrong may result in fatal error, so get it by leader
|
||||
int ret = OB_SUCCESS;
|
||||
replica_type = REPLICA_TYPE_MAX;
|
||||
replica_type = REPLICA_TYPE_INVALID;
|
||||
common::ObAddr leader_addr; // not used
|
||||
GlobalLearnerList learner_list;
|
||||
common::ObMemberList member_list;
|
||||
@ -2546,7 +2673,16 @@ int ObDRWorker::get_replica_type_by_leader_(
|
||||
} else if (member_list.contains(server_addr)) {
|
||||
replica_type = REPLICA_TYPE_FULL;
|
||||
} else if (learner_list.contains(server_addr)) {
|
||||
replica_type = REPLICA_TYPE_READONLY;
|
||||
ObMember learner;
|
||||
if (OB_FAIL(learner_list.get_learner_by_addr(server_addr, learner))) {
|
||||
LOG_WARN("failed to get_learner_by_addr", KR(ret), K(server_addr));
|
||||
} else {
|
||||
if (learner.is_columnstore()) {
|
||||
replica_type = REPLICA_TYPE_COLUMNSTORE;
|
||||
} else {
|
||||
replica_type = REPLICA_TYPE_READONLY;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to find server in leader member list and learner list",
|
||||
@ -2628,7 +2764,7 @@ int ObDRWorker::build_remove_replica_task_(
|
||||
ObRemoveLSReplicaTask &remove_replica_task)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_MAX;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_INVALID;
|
||||
common::ObAddr leader_addr;
|
||||
ObMember member_to_remove;
|
||||
if (OB_UNLIKELY(!inited_)) {
|
||||
@ -2652,10 +2788,10 @@ int ObDRWorker::build_remove_replica_task_(
|
||||
share::ObTaskId task_id;
|
||||
int64_t new_paxos_replica_number = 0;
|
||||
bool has_leader = false;
|
||||
ObReplicaMember remove_member(member_to_remove);
|
||||
ObReplicaMember remove_member;
|
||||
if (FALSE_IT(task_id.init(self_addr_))) {
|
||||
} else if (OB_FAIL(remove_member.set_replica_type(replica_type))) {
|
||||
LOG_WARN("fail to set replica type", KR(ret), K(replica_type), K(remove_member));
|
||||
} else if (OB_FAIL(remove_member.init(member_to_remove, replica_type))) {
|
||||
LOG_WARN("fail to init remove_member", KR(ret), K(member_to_remove), K(replica_type));
|
||||
} else if (OB_FAIL(check_and_generate_new_paxos_replica_num_(
|
||||
arg, replica_type, dr_ls_info, new_paxos_replica_number))) {
|
||||
LOG_WARN("fail to check and generate new paxos replica num", KR(ret), K(arg), K(replica_type), K(dr_ls_info));
|
||||
@ -2687,7 +2823,7 @@ int ObDRWorker::build_modify_replica_type_task_(
|
||||
int ret = OB_SUCCESS;
|
||||
share::ObUnit unit;
|
||||
share::ObLSReplica ls_replica;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_MAX;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_INVALID;
|
||||
if (OB_UNLIKELY(!inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("DRWorker not init", KR(ret));
|
||||
@ -2713,6 +2849,12 @@ int ObDRWorker::build_modify_replica_type_task_(
|
||||
LOG_USER_ERROR(OB_ENTRY_EXIST, "Current replica type is same as the target type, no need to modify");
|
||||
LOG_WARN("replica type is the same as the target type, no need to modify type",
|
||||
KR(ret), K(arg), K(replica_type));
|
||||
} else if (ObReplicaTypeCheck::is_columnstore_replica(arg.get_replica_type())
|
||||
|| ObReplicaTypeCheck::is_columnstore_replica(replica_type)) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "Current or target replica-type is C-replica, type transform");
|
||||
LOG_WARN("Current or target replica_type is C-replica, type transform not supported",
|
||||
KR(ret), K(arg), K(replica_type));
|
||||
} else if (REPLICA_TYPE_FULL == arg.get_replica_type()
|
||||
&& share::ObLSReplica::DEFAULT_REPLICA_COUNT == dr_ls_info.get_member_list_cnt()) {
|
||||
ret = OB_OP_NOT_ALLOW;
|
||||
@ -2769,8 +2911,8 @@ int ObDRWorker::build_migrate_replica_task_(
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
share::ObUnit destination_unit;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_MAX;
|
||||
share::ObLSReplica desti_ls_replica;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_INVALID;
|
||||
share::ObLSReplica dest_ls_replica;
|
||||
share::ObLSReplica source_ls_replica;
|
||||
if (OB_UNLIKELY(!inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
@ -2781,15 +2923,15 @@ int ObDRWorker::build_migrate_replica_task_(
|
||||
} else if (OB_FAIL(dr_ls_info.check_replica_exist_and_get_ls_replica(
|
||||
arg.get_server_addr(), source_ls_replica))) {
|
||||
LOG_WARN("fail to check and get replica by server", KR(ret), K(arg));
|
||||
} else if (!source_ls_replica.is_valid() || (source_ls_replica.is_valid() && !source_ls_replica.is_in_service())) {
|
||||
} else if (!source_ls_replica.is_valid() || !source_ls_replica.is_in_service()) {
|
||||
ret = OB_ENTRY_NOT_EXIST;
|
||||
LOG_USER_ERROR(OB_ENTRY_NOT_EXIST, "Source server does not have a replica of this LS");
|
||||
LOG_WARN("source server does not have a replica of this LS",
|
||||
KR(ret), K(arg), K(dr_ls_info), K(source_ls_replica));
|
||||
} else if (OB_FAIL(dr_ls_info.check_replica_exist_and_get_ls_replica(
|
||||
arg.get_destination_addr(), desti_ls_replica))) {
|
||||
arg.get_destination_addr(), dest_ls_replica))) {
|
||||
LOG_WARN("fail to check and get replica by server", KR(ret), K(arg));
|
||||
} else if (desti_ls_replica.is_valid()) {
|
||||
} else if (dest_ls_replica.is_valid()) {
|
||||
ret = OB_ENTRY_EXIST;
|
||||
LOG_USER_ERROR(OB_ENTRY_EXIST, "The destination server already has a replica");
|
||||
LOG_WARN("target server already has a replica, no need migrate", KR(ret), K(arg), K(dr_ls_info));
|
||||
@ -2898,6 +3040,16 @@ int ObDRWorker::build_modify_paxos_replica_num_task_(
|
||||
return ret;
|
||||
}
|
||||
|
||||
// this func is only for basic checking.
|
||||
// 1. if dest_replica_type is F/R replica, data_src can be same replica_type or F;
|
||||
// 2. if dest_replica_type is C replica, data_src can be F/R/C.
|
||||
bool can_as_data_source(const int32_t dest_replica_type, const int32_t src_replica_type)
|
||||
{
|
||||
return (dest_replica_type == src_replica_type
|
||||
|| REPLICA_TYPE_FULL == src_replica_type
|
||||
|| ObReplicaTypeCheck::is_columnstore_replica(dest_replica_type));
|
||||
}
|
||||
|
||||
int ObDRWorker::check_data_source_available_and_init_(
|
||||
const obrpc::ObAdminAlterLSReplicaArg &arg,
|
||||
const common::ObReplicaType &replica_type,
|
||||
@ -2916,7 +3068,7 @@ int ObDRWorker::check_data_source_available_and_init_(
|
||||
data_source.reset();
|
||||
share::ObLSReplica ls_replica;
|
||||
ObServerInfoInTable server_info;
|
||||
common::ObReplicaType provide_replica_type = REPLICA_TYPE_MAX;
|
||||
common::ObReplicaType provide_replica_type = REPLICA_TYPE_INVALID;
|
||||
if (OB_UNLIKELY(!inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("DRWorker not init", KR(ret));
|
||||
@ -2924,11 +3076,10 @@ int ObDRWorker::check_data_source_available_and_init_(
|
||||
// passed
|
||||
LOG_INFO("data_source is not valid", KR(ret), K(arg));
|
||||
} else if (OB_UNLIKELY(!arg.is_valid()
|
||||
|| OB_UNLIKELY(replica_type != REPLICA_TYPE_FULL && replica_type != REPLICA_TYPE_READONLY))) {
|
||||
|| OB_UNLIKELY(!ObReplicaTypeCheck::is_replica_type_valid(replica_type)))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(arg), K(replica_type));
|
||||
} else {
|
||||
ObDataSourceCandidateChecker type_checker(replica_type);
|
||||
if (OB_FAIL(dr_ls_info.check_replica_exist_and_get_ls_replica(arg.get_data_source(), ls_replica))) {
|
||||
LOG_WARN("fail to get ls replica", KR(ret), K(dr_ls_info));
|
||||
} else if (!ls_replica.is_valid() || (ls_replica.is_valid() && !ls_replica.is_in_service())) {
|
||||
@ -2941,10 +3092,10 @@ int ObDRWorker::check_data_source_available_and_init_(
|
||||
ret = OB_OP_NOT_ALLOW;
|
||||
LOG_USER_ERROR(OB_OP_NOT_ALLOW, "Data source replica restore or clone failed, which is");
|
||||
LOG_WARN("ls replica restore failed", KR(ret), K(arg), K(ls_replica));
|
||||
} else if (!type_checker.is_candidate(provide_replica_type)) {
|
||||
} else if (!can_as_data_source(replica_type, provide_replica_type)) {
|
||||
ret = OB_OP_NOT_ALLOW;
|
||||
LOG_USER_ERROR(OB_OP_NOT_ALLOW, "R replica is not supported as the source of F replica, which is");
|
||||
LOG_WARN("type_checker failed", KR(ret), K(arg), K(provide_replica_type));
|
||||
LOG_WARN("provided data_source replica_type not supported", KR(ret), K(arg), K(replica_type), K(provide_replica_type));
|
||||
} else if (OB_FAIL(SVR_TRACER.get_server_info(arg.get_data_source(), server_info))) {
|
||||
LOG_WARN("fail to get server info", KR(ret), K(arg));
|
||||
} else if (!server_info.is_alive()) {
|
||||
@ -3013,7 +3164,7 @@ int ObDRWorker::check_and_generate_new_paxos_replica_num_(
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("DRWorker not init", KR(ret));
|
||||
} else if (OB_UNLIKELY(!arg.is_valid()
|
||||
|| (REPLICA_TYPE_FULL != replica_type && REPLICA_TYPE_READONLY != replica_type))) {
|
||||
|| !ObReplicaTypeCheck::is_replica_type_valid(replica_type))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(arg), K(replica_type));
|
||||
} else if (std::abs(new_p - curr_p) > 1) {
|
||||
@ -3023,13 +3174,13 @@ int ObDRWorker::check_and_generate_new_paxos_replica_num_(
|
||||
} else if (task_type.is_add_task()) {
|
||||
if (REPLICA_TYPE_FULL == replica_type) {
|
||||
member_change_type = MEMBER_CHANGE_ADD;
|
||||
} else if (REPLICA_TYPE_READONLY == replica_type) {
|
||||
} else if (ObReplicaTypeCheck::is_non_paxos_replica(replica_type)) {
|
||||
member_change_type = MEMBER_CHANGE_NOP;
|
||||
}
|
||||
} else if (task_type.is_remove_task()) {
|
||||
if (REPLICA_TYPE_FULL == replica_type) {
|
||||
member_change_type = MEMBER_CHANGE_SUB;
|
||||
} else if (REPLICA_TYPE_READONLY == replica_type) {
|
||||
} else if (ObReplicaTypeCheck::is_non_paxos_replica(replica_type)) {
|
||||
member_change_type = MEMBER_CHANGE_NOP;
|
||||
}
|
||||
} else if (task_type.is_modify_replica_task()) {
|
||||
@ -3037,11 +3188,15 @@ int ObDRWorker::check_and_generate_new_paxos_replica_num_(
|
||||
member_change_type = MEMBER_CHANGE_ADD;
|
||||
} else if (REPLICA_TYPE_READONLY == replica_type) {
|
||||
member_change_type = MEMBER_CHANGE_SUB;
|
||||
} else if (ObReplicaTypeCheck::is_columnstore_replica(replica_type)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid replica_type, do not support transforming to C-replica", KR(ret), K(arg));
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("task type unexpected", KR(ret), K(arg), K(dr_ls_info), K(replica_type));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if ((MEMBER_CHANGE_ADD == member_change_type)) {
|
||||
if (OB_FAIL(check_for_alter_full_replica_(member_list_count + 1, new_p))) {
|
||||
@ -3192,7 +3347,7 @@ int ObDRWorker::check_has_leader_while_remove_replica(
|
||||
int64_t arb_replica_num = 0;
|
||||
uint64_t tenant_id = OB_INVALID_TENANT_ID;
|
||||
ObLSID ls_id;
|
||||
ObReplicaType replica_type = REPLICA_TYPE_MAX;
|
||||
ObReplicaType replica_type = REPLICA_TYPE_INVALID;
|
||||
for (int64_t index = 0; OB_SUCC(ret) && index < replica_cnt; ++index) {
|
||||
share::ObLSReplica *ls_replica = nullptr;
|
||||
DRServerStatInfo *server_stat_info = nullptr;
|
||||
@ -3482,6 +3637,9 @@ int ObDRWorker::try_remove_permanent_offline_replicas(
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_READONLY;
|
||||
if (OB_FAIL(learner_list.get_member_by_index(index, learner_to_remove))) {
|
||||
LOG_WARN("fail to get learner by index", KR(ret), K(index));
|
||||
} else if (FALSE_IT(replica_type = learner_to_remove.is_columnstore() ?
|
||||
REPLICA_TYPE_COLUMNSTORE : REPLICA_TYPE_READONLY)) {
|
||||
// shall never be here
|
||||
} else if (OB_FAIL(do_single_replica_permanent_offline_(
|
||||
tenant_id,
|
||||
ls_id,
|
||||
@ -3490,7 +3648,7 @@ int ObDRWorker::try_remove_permanent_offline_replicas(
|
||||
replica_type,
|
||||
learner_to_remove,
|
||||
acc_dr_task))) {
|
||||
LOG_WARN("fail to do single replica permanent offline task for readonly replica", KR(ret), K(tenant_id),
|
||||
LOG_WARN("fail to do single replica permanent offline task for non-paxos replica", KR(ret), K(tenant_id),
|
||||
K(ls_id), K(dr_ls_info), K(only_for_display), K(replica_type), K(learner_to_remove), K(acc_dr_task));
|
||||
}
|
||||
}
|
||||
@ -3532,12 +3690,12 @@ int ObDRWorker::do_single_replica_permanent_offline_(
|
||||
const int64_t memstore_percent = 100;
|
||||
ObDRTaskKey task_key;
|
||||
bool can_generate = false;
|
||||
ObReplicaMember remove_member(member_to_remove);
|
||||
ObReplicaMember remove_member;
|
||||
ObDRTaskType task_type = ObReplicaTypeCheck::is_paxos_replica_V2(replica_type)
|
||||
? ObDRTaskType::LS_REMOVE_PAXOS_REPLICA
|
||||
: ObDRTaskType::LS_REMOVE_NON_PAXOS_REPLICA;
|
||||
if (OB_FAIL(remove_member.set_replica_type(replica_type))) {
|
||||
LOG_WARN("fail to set replica type", KR(ret), K(replica_type), K(remove_member));
|
||||
if (OB_FAIL(remove_member.init(member_to_remove, replica_type))) {
|
||||
LOG_WARN("failed to init remove_member", KR(ret), K(member_to_remove), K(replica_type));
|
||||
} else if (OB_FAIL(construct_extra_infos_to_build_remove_replica_task(
|
||||
dr_ls_info,
|
||||
task_id,
|
||||
@ -3560,7 +3718,7 @@ int ObDRWorker::do_single_replica_permanent_offline_(
|
||||
replica_type,
|
||||
new_paxos_replica_number,
|
||||
source_server,
|
||||
REPLICA_TYPE_MAX/*source_replica_type*/,
|
||||
REPLICA_TYPE_INVALID/*source_replica_type*/,
|
||||
old_paxos_replica_number,
|
||||
leader_addr,
|
||||
"remove permanent offline replica"))) {
|
||||
@ -4216,8 +4374,8 @@ int ObDRWorker::record_task_plan_for_locality_alignment(
|
||||
ObDRTaskType task_type = ObDRTaskType::MAX_TYPE;
|
||||
uint64_t tenant_id = OB_INVALID_ID;
|
||||
share::ObLSID ls_id;
|
||||
ObReplicaType source_replica_type = REPLICA_TYPE_MAX;
|
||||
ObReplicaType target_replica_type = REPLICA_TYPE_MAX;
|
||||
ObReplicaType source_replica_type = REPLICA_TYPE_INVALID;
|
||||
ObReplicaType target_replica_type = REPLICA_TYPE_INVALID;
|
||||
ObDRTaskPriority task_priority = ObDRTaskPriority::MAX_PRI;
|
||||
common::ObAddr leader_addr;
|
||||
common::ObAddr source_svr;
|
||||
@ -4245,7 +4403,7 @@ int ObDRWorker::record_task_plan_for_locality_alignment(
|
||||
case RemoveNonPaxos: {
|
||||
const RemoveReplicaLATask *my_task = reinterpret_cast<const RemoveReplicaLATask *>(task);
|
||||
task_type = RemovePaxos == task->get_task_type() ? ObDRTaskType::LS_REMOVE_PAXOS_REPLICA : ObDRTaskType::LS_REMOVE_NON_PAXOS_REPLICA;
|
||||
source_replica_type = REPLICA_TYPE_MAX;
|
||||
source_replica_type = REPLICA_TYPE_INVALID;
|
||||
target_replica_type = my_task->replica_type_;
|
||||
task_priority = task_type == ObDRTaskType::LS_REMOVE_PAXOS_REPLICA ? ObDRTaskPriority::HIGH_PRI : ObDRTaskPriority::LOW_PRI;
|
||||
target_svr = my_task->remove_server_;
|
||||
@ -4476,15 +4634,15 @@ int ObDRWorker::try_shrink_resource_pools(
|
||||
&& share::ObUnit::UNIT_STATUS_DELETING == unit_stat_info->get_unit().status_) {
|
||||
// replica is still in member_list, but unit is in DELETING status
|
||||
// If this is a duplicate log stream
|
||||
// 1.1 for R-replica: execute remove_learner task directly
|
||||
// 1.1 for non-paxos(R or C) replica: execute remove_learner task directly
|
||||
// 1.2 for F-replica: try to execute migrate-replica first,
|
||||
// if migrate-replica task can not generate then try to type_transform another R to F
|
||||
// If this is a normal log stream
|
||||
// 2.1 try to execute migrate-replica task for both R-replica and F-replica
|
||||
// 2.1 try to execute migrate-replica task for replica of any type
|
||||
if (dr_ls_info.is_duplicate_ls()) {
|
||||
if (REPLICA_TYPE_READONLY == ls_replica->get_replica_type()) {
|
||||
if (ObReplicaTypeCheck::is_non_paxos_replica(ls_replica->get_replica_type())) {
|
||||
// 1.1 try to generate and execute remove learner task
|
||||
if (OB_FAIL(try_remove_readonly_replica_for_deleting_unit_(
|
||||
if (OB_FAIL(try_remove_non_paxos_replica_for_deleting_unit_(
|
||||
*ls_replica,
|
||||
only_for_display,
|
||||
dr_ls_info,
|
||||
@ -4554,7 +4712,7 @@ int ObDRWorker::try_shrink_resource_pools(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDRWorker::try_remove_readonly_replica_for_deleting_unit_(
|
||||
int ObDRWorker::try_remove_non_paxos_replica_for_deleting_unit_(
|
||||
const share::ObLSReplica &ls_replica,
|
||||
const bool &only_for_display,
|
||||
DRLSInfo &dr_ls_info,
|
||||
@ -4607,7 +4765,7 @@ int ObDRWorker::try_remove_readonly_replica_for_deleting_unit_(
|
||||
ls_replica.get_replica_type(),
|
||||
new_paxos_replica_number,
|
||||
source_server,
|
||||
REPLICA_TYPE_MAX/*source_replica_type*/,
|
||||
REPLICA_TYPE_INVALID/*source_replica_type*/,
|
||||
old_paxos_replica_number,
|
||||
leader_addr,
|
||||
"shrink unit task"))) {
|
||||
@ -5055,7 +5213,7 @@ int ObDRWorker::check_need_generate_cancel_unit_migration_task(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDRWorker::construct_extra_info_to_build_cancael_migration_task(
|
||||
int ObDRWorker::construct_extra_info_to_build_cancel_migration_task(
|
||||
const bool &is_paxos_replica_related,
|
||||
DRLSInfo &dr_ls_info,
|
||||
const share::ObLSReplica &ls_replica,
|
||||
@ -5103,7 +5261,7 @@ int ObDRWorker::generate_cancel_unit_migration_task(
|
||||
int ret = OB_SUCCESS;
|
||||
ObRemoveLSReplicaTask remove_member_task;
|
||||
ObString comment_to_set = "";
|
||||
ObReplicaType replica_type = is_paxos_replica_related ? REPLICA_TYPE_FULL : REPLICA_TYPE_READONLY;
|
||||
ObReplicaType replica_type = remove_member.get_replica_type();
|
||||
if (is_paxos_replica_related) {
|
||||
comment_to_set.assign_ptr(drtask::CANCEL_MIGRATE_UNIT_WITH_PAXOS_REPLICA,
|
||||
strlen(drtask::CANCEL_MIGRATE_UNIT_WITH_PAXOS_REPLICA));
|
||||
@ -5132,7 +5290,7 @@ int ObDRWorker::generate_cancel_unit_migration_task(
|
||||
old_paxos_replica_number,
|
||||
new_paxos_replica_number,
|
||||
replica_type))) {
|
||||
LOG_WARN("fail to build remove member task", KR(ret));
|
||||
LOG_WARN("fail to build remove member task", KR(ret), K(task_key), K(task_id));
|
||||
} else if (OB_FAIL(disaster_recovery_task_mgr_->add_task(remove_member_task))) {
|
||||
LOG_WARN("fail to add task", KR(ret), K(remove_member_task));
|
||||
} else {
|
||||
@ -5218,7 +5376,7 @@ int ObDRWorker::try_cancel_unit_migration(
|
||||
strlen(drtask::CANCEL_MIGRATE_UNIT_WITH_NON_PAXOS_REPLICA));
|
||||
}
|
||||
|
||||
if (OB_FAIL(construct_extra_info_to_build_cancael_migration_task(
|
||||
if (OB_FAIL(construct_extra_info_to_build_cancel_migration_task(
|
||||
is_paxos_replica_related,
|
||||
dr_ls_info,
|
||||
*ls_replica,
|
||||
@ -5240,7 +5398,7 @@ int ObDRWorker::try_cancel_unit_migration(
|
||||
ls_replica->get_replica_type(),
|
||||
new_paxos_replica_number,
|
||||
source_svr,
|
||||
REPLICA_TYPE_MAX,
|
||||
REPLICA_TYPE_INVALID,
|
||||
old_paxos_replica_number,
|
||||
leader_addr,
|
||||
comment_to_set))) {
|
||||
@ -5773,7 +5931,8 @@ int ObDRWorker::check_ls_only_in_member_list_or_with_flag_(
|
||||
}
|
||||
} else {
|
||||
ret = OB_STATE_NOT_MATCH;
|
||||
LOG_WARN("read only replica with flag should not appear in inner_ls_info", KR(ret), K(learner_to_check), K(inner_ls_info));
|
||||
LOG_WARN("read only replica with migrating-flag should not appear in inner_ls_info",
|
||||
KR(ret), K(learner_to_check), K(inner_ls_info));
|
||||
}
|
||||
} else if (OB_FAIL(inner_ls_info.find(learner_to_check.get_server(), replica))) {
|
||||
LOG_WARN("fail to find read only replica", KR(ret), K(inner_ls_info), K(learner_to_check));
|
||||
|
@ -310,7 +310,7 @@ private:
|
||||
LA_P_ADD_LOGONLY,
|
||||
LA_P_ADD_ENCRYPTION,
|
||||
LA_P_FULL_TO_LOGONLY,
|
||||
LA_P_ADD_READONLY,
|
||||
LA_P_ADD_NON_PAXOS,
|
||||
LA_P_REMOVE_NON_PAXOS,
|
||||
LA_P_FULL_TO_READONLY,
|
||||
LA_P_REMOVE_PAXOS,
|
||||
@ -348,7 +348,7 @@ private:
|
||||
RemoveReplicaLATask()
|
||||
: LATask(),
|
||||
remove_server_(),
|
||||
replica_type_(REPLICA_TYPE_MAX),
|
||||
replica_type_(REPLICA_TYPE_INVALID),
|
||||
memstore_percent_(100),
|
||||
member_time_us_(-1),
|
||||
orig_paxos_replica_number_(0),
|
||||
@ -389,7 +389,7 @@ private:
|
||||
dst_server_(),
|
||||
unit_id_(OB_INVALID_ID),
|
||||
unit_group_id_(OB_INVALID_ID),
|
||||
replica_type_(REPLICA_TYPE_MAX),
|
||||
replica_type_(REPLICA_TYPE_INVALID),
|
||||
memstore_percent_(100),
|
||||
member_time_us_(-1),
|
||||
orig_paxos_replica_number_(0),
|
||||
@ -405,8 +405,8 @@ private:
|
||||
priority = LATaskPrio::LA_P_ADD_LOGONLY;
|
||||
} else if (common::REPLICA_TYPE_ENCRYPTION_LOGONLY == replica_type_) {
|
||||
priority = LATaskPrio::LA_P_ADD_ENCRYPTION;
|
||||
} else if (common::REPLICA_TYPE_READONLY == replica_type_) {
|
||||
priority = LATaskPrio::LA_P_ADD_READONLY;
|
||||
} else if (ObReplicaTypeCheck::is_non_paxos_replica(replica_type_)) {
|
||||
priority = LATaskPrio::LA_P_ADD_NON_PAXOS;
|
||||
} else {} // default priority value
|
||||
return priority;
|
||||
}
|
||||
@ -442,10 +442,10 @@ private:
|
||||
dst_server_(),
|
||||
unit_id_(OB_INVALID_ID),
|
||||
unit_group_id_(OB_INVALID_ID),
|
||||
src_replica_type_(REPLICA_TYPE_MAX),
|
||||
src_replica_type_(REPLICA_TYPE_INVALID),
|
||||
src_memstore_percent_(100),
|
||||
src_member_time_us_(-1),
|
||||
dst_replica_type_(REPLICA_TYPE_MAX),
|
||||
dst_replica_type_(REPLICA_TYPE_INVALID),
|
||||
dst_memstore_percent_(100),
|
||||
dst_member_time_us_(-1),
|
||||
orig_paxos_replica_number_(0),
|
||||
@ -527,7 +527,7 @@ private:
|
||||
memstore_percent_(memstore_percent),
|
||||
replica_num_(replica_num) {}
|
||||
ReplicaDesc()
|
||||
: replica_type_(REPLICA_TYPE_MAX),
|
||||
: replica_type_(REPLICA_TYPE_INVALID),
|
||||
memstore_percent_(100),
|
||||
replica_num_(0) {}
|
||||
TO_STRING_KV(K(replica_type_),
|
||||
@ -535,14 +535,16 @@ private:
|
||||
K(replica_num_));
|
||||
int64_t cast(const common::ObReplicaType replica_type) {
|
||||
int64_t ret_val = 0;
|
||||
if (REPLICA_TYPE_READONLY == replica_type) {
|
||||
if (REPLICA_TYPE_COLUMNSTORE == replica_type) {
|
||||
ret_val = 1;
|
||||
} else if (REPLICA_TYPE_ENCRYPTION_LOGONLY == replica_type) {
|
||||
} else if (REPLICA_TYPE_READONLY == replica_type) {
|
||||
ret_val = 2;
|
||||
} else if (REPLICA_TYPE_LOGONLY == replica_type) {
|
||||
} else if (REPLICA_TYPE_ENCRYPTION_LOGONLY == replica_type) {
|
||||
ret_val = 3;
|
||||
} else if (REPLICA_TYPE_FULL == replica_type) {
|
||||
} else if (REPLICA_TYPE_LOGONLY == replica_type) {
|
||||
ret_val = 4;
|
||||
} else if (REPLICA_TYPE_FULL == replica_type) {
|
||||
ret_val = 5;
|
||||
} else {
|
||||
ret_val = 0; // invalid type, put it at the beginning
|
||||
}
|
||||
@ -580,35 +582,6 @@ private:
|
||||
&& nullptr != unit_stat_info_
|
||||
&& nullptr != unit_in_group_stat_info_;
|
||||
}
|
||||
int64_t cast(const common::ObReplicaType replica_type) {
|
||||
int64_t ret_val = 0;
|
||||
if (REPLICA_TYPE_READONLY == replica_type) {
|
||||
ret_val = 1;
|
||||
} else if (REPLICA_TYPE_ENCRYPTION_LOGONLY == replica_type) {
|
||||
ret_val = 2;
|
||||
} else if (REPLICA_TYPE_LOGONLY == replica_type) {
|
||||
ret_val = 3;
|
||||
} else if (REPLICA_TYPE_FULL == replica_type) {
|
||||
ret_val = 4;
|
||||
} else {
|
||||
ret_val = 0; // invalid type, put it at the beginning
|
||||
}
|
||||
return ret_val;
|
||||
}
|
||||
bool operator<(const ReplicaStatDesc &that) {
|
||||
bool bool_ret = true;
|
||||
if (nullptr == this->replica_ && nullptr != that.replica_) {
|
||||
bool_ret = true;
|
||||
} else if (nullptr != this->replica_ && nullptr == that.replica_) {
|
||||
bool_ret = false;
|
||||
} else if (nullptr == this->replica_ && nullptr == that.replica_) {
|
||||
bool_ret = true;
|
||||
} else {
|
||||
bool_ret = cast(this->replica_->get_replica_type())
|
||||
< cast(that.replica_->get_replica_type());
|
||||
}
|
||||
return bool_ret;
|
||||
}
|
||||
TO_STRING_KV(KPC(replica_),
|
||||
KPC(server_stat_info_),
|
||||
KPC(unit_stat_info_),
|
||||
@ -625,10 +598,22 @@ private:
|
||||
public:
|
||||
ReplicaDescArray() : common::ObSEArrayImpl<ReplicaDesc, 7>(),
|
||||
is_readonly_all_server_(false),
|
||||
readonly_memstore_percent_(100) {}
|
||||
public:
|
||||
is_columnstore_all_server_(false) {}
|
||||
void set_readonly_all_server() {
|
||||
is_readonly_all_server_ = true;
|
||||
is_columnstore_all_server_ = false;
|
||||
}
|
||||
void set_columnstore_all_server() {
|
||||
is_columnstore_all_server_ = true;
|
||||
is_readonly_all_server_ = false;
|
||||
}
|
||||
bool is_readonly_all_server() { return is_readonly_all_server_; }
|
||||
bool is_columnstore_all_server() { return is_columnstore_all_server_; }
|
||||
int64_t get_readonly_memstore_percent() { return readonly_memstore_percent_; }
|
||||
private:
|
||||
bool is_readonly_all_server_;
|
||||
int64_t readonly_memstore_percent_;
|
||||
bool is_columnstore_all_server_;
|
||||
const int64_t readonly_memstore_percent_ = 100; // obsolete
|
||||
};
|
||||
|
||||
|
||||
@ -699,13 +684,17 @@ private:
|
||||
ReplicaStatDesc &replica_stat_desc,
|
||||
share::ObLSReplica &replica,
|
||||
const int64_t index);
|
||||
int do_generate_locality_task_from_columnstore_replica(
|
||||
ReplicaStatDesc &replica_stat_desc,
|
||||
share::ObLSReplica &replica,
|
||||
const int64_t index);
|
||||
|
||||
int try_generate_type_transform_task_for_readonly_replica_(
|
||||
int try_generate_task_for_readonly_replica_(
|
||||
ReplicaDescArray &zone_replica_desc_in_locality,
|
||||
ReplicaStatDesc &replica_stat_desc,
|
||||
const int64_t index,
|
||||
bool &task_generated);
|
||||
int try_generate_remove_readonly_task_for_duplicate_log_stream_(
|
||||
int try_generate_remove_redundant_replica_task_for_dup_ls_(
|
||||
ReplicaStatDesc &replica_stat_desc,
|
||||
share::ObLSReplica &replica,
|
||||
const int64_t index);
|
||||
@ -733,7 +722,7 @@ private:
|
||||
ReplicaDesc &replica_desc);
|
||||
int generate_modify_paxos_replica_number_task();
|
||||
// private func for get_next_locality_alignment_task
|
||||
int try_get_readonly_all_server_locality_alignment_task(
|
||||
int try_get_readonly_or_columnstore_all_server_locality_alignment_task(
|
||||
UnitProvider &unit_provider,
|
||||
const LATask *&task);
|
||||
int try_get_normal_locality_alignment_task(
|
||||
@ -933,7 +922,7 @@ private:
|
||||
bool &is_paxos_replica_related,
|
||||
bool &need_generate);
|
||||
|
||||
int construct_extra_info_to_build_cancael_migration_task(
|
||||
int construct_extra_info_to_build_cancel_migration_task(
|
||||
const bool &is_paxos_replica_related,
|
||||
DRLSInfo &dr_ls_info,
|
||||
const share::ObLSReplica &ls_replica,
|
||||
@ -1043,7 +1032,7 @@ private:
|
||||
// @params[in] only_for_display, whether just to display this task
|
||||
// @params[in] dr_ls_info, disaster recovery infos of this log stream
|
||||
// @params[out] acc_dr_task, accumulated disaster recovery task count
|
||||
int try_remove_readonly_replica_for_deleting_unit_(
|
||||
int try_remove_non_paxos_replica_for_deleting_unit_(
|
||||
const share::ObLSReplica &ls_replica,
|
||||
const bool &only_for_display,
|
||||
DRLSInfo &dr_ls_info,
|
||||
|
@ -40,19 +40,6 @@ using namespace oceanbase::share::schema;
|
||||
ret = OB_INVALID_ARGUMENT; \
|
||||
LOG_WARN("invalid locality", K(ret)); \
|
||||
} while (0)
|
||||
// full replica
|
||||
const char *const ObLocalityDistribution::FULL_REPLICA_STR = "FULL";
|
||||
const char *const ObLocalityDistribution::F_REPLICA_STR = "F";
|
||||
// logonly replica
|
||||
const char *const ObLocalityDistribution::LOGONLY_REPLICA_STR = "LOGONLY";
|
||||
const char *const ObLocalityDistribution::L_REPLICA_STR = "L";
|
||||
// readonly replica
|
||||
const char *const ObLocalityDistribution::READONLY_REPLICA_STR = "READONLY";
|
||||
const char *const ObLocalityDistribution::R_REPLICA_STR = "R";
|
||||
// encryption logonly replica
|
||||
const char *const ObLocalityDistribution::ENCRYPTION_LOGONLY_REPLICA_STR = "ENCRYPTION_LOGONLY";
|
||||
const char *const ObLocalityDistribution::E_REPLICA_STR = "E";
|
||||
// some other terminology
|
||||
const common::ObZone ObLocalityDistribution::EVERY_ZONE("everyzone");
|
||||
const char *const ObLocalityDistribution::ALL_SERVER_STR = "ALL_SERVER";
|
||||
const char *const ObLocalityDistribution::MEMSTORE_PERCENT_STR = "MEMSTORE_PERCENT";
|
||||
@ -149,6 +136,9 @@ int ObLocalityDistribution::ZoneSetReplicaDist::check_valid_replica_dist(
|
||||
for (int64_t i = 0; is_valid && i < all_replica_attr_array_[READONLY_REPLICA].count(); ++i) {
|
||||
is_valid = all_replica_attr_array_[READONLY_REPLICA].at(i).num_ >= 0;
|
||||
}
|
||||
for (int64_t i = 0; is_valid && i < all_replica_attr_array_[COLUMNSTORE_REPLICA].count(); ++i) {
|
||||
is_valid = all_replica_attr_array_[COLUMNSTORE_REPLICA].at(i).num_ >= 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
is_valid = false; // do not support mixed-zone locality from 3.2.1 and versions to come
|
||||
@ -209,6 +199,12 @@ bool ObLocalityDistribution::ZoneSetReplicaDist::has_non_encryption_logonly() co
|
||||
const ReplicaAttr &attr = all_replica_attr_array_[READONLY_REPLICA].at(i);
|
||||
has = attr.num_ > 0;
|
||||
}
|
||||
for (int64_t i = 0;
|
||||
!has && i < all_replica_attr_array_[COLUMNSTORE_REPLICA].count();
|
||||
++i) {
|
||||
const ReplicaAttr &attr = all_replica_attr_array_[COLUMNSTORE_REPLICA].at(i);
|
||||
has = attr.num_ > 0;
|
||||
}
|
||||
return has;
|
||||
}
|
||||
|
||||
@ -436,6 +432,9 @@ int ObLocalityDistribution::ZoneSetReplicaDist::replica_type_to_str(
|
||||
case ENCRYPTION_LOGONLY_REPLICA:
|
||||
replica_type_str = "ENCRYPTION_LOGONLY";
|
||||
break;
|
||||
case COLUMNSTORE_REPLICA:
|
||||
replica_type_str = "COLUMNSTORE";
|
||||
break;
|
||||
default:
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected replica type", K(ret), K(replica_type));
|
||||
@ -658,9 +657,11 @@ int ObLocalityDistribution::RawLocalityIter::get_replica_arrangements(
|
||||
&& OB_SUCC(get_next_replica_arrangement(
|
||||
cursor, end, replica_type, replica_num, memstore_percent))) {
|
||||
if (OB_UNLIKELY(FULL_REPLICA != replica_type
|
||||
&& READONLY_REPLICA != replica_type)) {
|
||||
&& READONLY_REPLICA != replica_type
|
||||
&& COLUMNSTORE_REPLICA != replica_type)) {
|
||||
// TODO: F-replica is supported since 4.0,
|
||||
// R-replica is supported since 4.2,
|
||||
// C-replica is supported since 4.3.2
|
||||
// other types will be supported later
|
||||
INVALID_LOCALITY();
|
||||
switch (replica_type) {
|
||||
@ -775,6 +776,20 @@ int ObLocalityDistribution::RawLocalityIter::get_replica_type(
|
||||
cursor += strlen(R_REPLICA_STR);
|
||||
} else {} // not this type
|
||||
}
|
||||
if (!type_found && remain >= strlen(COLUMNSTORE_REPLICA_STR)) {
|
||||
if (0 == strncmp(COLUMNSTORE_REPLICA_STR, &locality_str_[cursor], strlen(COLUMNSTORE_REPLICA_STR))) {
|
||||
replica_type = COLUMNSTORE_REPLICA;
|
||||
type_found = true;
|
||||
cursor += strlen(COLUMNSTORE_REPLICA_STR);
|
||||
} else {} // not this type
|
||||
}
|
||||
if (!type_found && remain >= strlen(C_REPLICA_STR)) {
|
||||
if (0 == strncmp(C_REPLICA_STR, &locality_str_[cursor], strlen(C_REPLICA_STR))) {
|
||||
replica_type = COLUMNSTORE_REPLICA;
|
||||
type_found = true;
|
||||
cursor += strlen(C_REPLICA_STR);
|
||||
} else {} // not this type
|
||||
}
|
||||
if (!type_found && remain >= strlen(ENCRYPTION_LOGONLY_REPLICA_STR)) {
|
||||
if (0 == strncmp(ENCRYPTION_LOGONLY_REPLICA_STR,
|
||||
&locality_str_[cursor],
|
||||
@ -1591,72 +1606,6 @@ int ObLocalityDistribution::convert_zone_list(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocalityDistribution::get_zone_replica_num(
|
||||
const common::ObZone &zone,
|
||||
share::ObReplicaNumSet &replica_num_set)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (zone.is_empty()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(zone));
|
||||
} else {
|
||||
bool found = false;
|
||||
for (int64_t i = 0; !found && OB_SUCC(ret) && i < zone_set_replica_dist_array_.count(); ++i) {
|
||||
const ZoneSetReplicaDist &this_dist = zone_set_replica_dist_array_.at(i);
|
||||
if (zone != this_dist.get_zone_set().at(0)) {
|
||||
// bypass
|
||||
} else{
|
||||
replica_num_set.set_replica_num(this_dist.get_full_replica_num(),
|
||||
this_dist.get_logonly_replica_num(),
|
||||
this_dist.get_readonly_replica_num(),
|
||||
this_dist.get_encryption_logonly_replica_num());
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
// failed
|
||||
} else if (!found) {
|
||||
ret = OB_ENTRY_NOT_EXIST;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocalityDistribution::get_zone_replica_num(
|
||||
const common::ObZone &zone,
|
||||
share::ObZoneReplicaAttrSet &zone_replica_attr_set)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (zone.is_empty()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(zone));
|
||||
} else {
|
||||
bool found = false;
|
||||
for (int64_t i = 0; !found && OB_SUCC(ret) && i < zone_set_replica_dist_array_.count(); ++i) {
|
||||
const ZoneSetReplicaDist &this_dist = zone_set_replica_dist_array_.at(i);
|
||||
if (zone != this_dist.get_zone_set().at(0)) {
|
||||
// bypass
|
||||
} else if (OB_FAIL(zone_replica_attr_set.zone_set_.assign(this_dist.get_zone_set()))) {
|
||||
LOG_WARN("fail to assign zone set", K(ret));
|
||||
} else {
|
||||
zone_replica_attr_set.zone_ = zone;
|
||||
if (OB_FAIL(zone_replica_attr_set.replica_attr_set_.set_replica_attr_array(
|
||||
this_dist.get_full_replica_attr(),
|
||||
this_dist.get_logonly_replica_attr(),
|
||||
this_dist.get_readonly_replica_attr(),
|
||||
this_dist.get_encryption_logonly_replica_attr()))) {
|
||||
LOG_WARN("fail to set replica attr array", KR(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
// failed
|
||||
} else if (!found) {
|
||||
ret = OB_ENTRY_NOT_EXIST;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocalityDistribution::get_zone_replica_attr_array(
|
||||
common::ObIArray<share::ObZoneReplicaAttrSet> &zone_replica_num_array)
|
||||
{
|
||||
@ -1675,7 +1624,8 @@ int ObLocalityDistribution::get_zone_replica_attr_array(
|
||||
this_dist.get_full_replica_attr(),
|
||||
this_dist.get_logonly_replica_attr(),
|
||||
this_dist.get_readonly_replica_attr(),
|
||||
this_dist.get_encryption_logonly_replica_attr()))) {
|
||||
this_dist.get_encryption_logonly_replica_attr(),
|
||||
this_dist.get_columnstore_replica_attr()))) {
|
||||
LOG_WARN("fail to set replica attr array", KR(ret));
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ namespace schema
|
||||
{
|
||||
struct ObZoneRegion;
|
||||
class ObSchemaGetterGuard;
|
||||
class ObLocality;
|
||||
class ObSimpleTableSchemaV2;
|
||||
class ObTablegroupSchema;
|
||||
class ObTenantSchema;
|
||||
@ -80,12 +79,6 @@ public:
|
||||
int64_t &pos);
|
||||
int get_zone_replica_attr_array(
|
||||
common::ObIArray<share::ObZoneReplicaAttrSet> &zone_replica_num_array);
|
||||
int get_zone_replica_num(
|
||||
const common::ObZone &zone,
|
||||
share::ObReplicaNumSet &replica_num_set);
|
||||
int get_zone_replica_num(
|
||||
const common::ObZone &zone,
|
||||
share::ObZoneReplicaAttrSet &zone_replica_num_set);
|
||||
public:
|
||||
static const int64_t ALL_SERVER_CNT = INT64_MAX;
|
||||
private:
|
||||
@ -94,24 +87,12 @@ private:
|
||||
static const int32_t LOGONLY_REPLICA = 1;
|
||||
static const int32_t READONLY_REPLICA = 2;
|
||||
static const int32_t ENCRYPTION_LOGONLY_REPLICA = 3;
|
||||
static const int32_t REPLICA_TYPE_MAX = 4;
|
||||
static const int32_t COLUMNSTORE_REPLICA = 4;
|
||||
static const int32_t REPLICA_TYPE_MAX = 5;
|
||||
private:
|
||||
static const int64_t MAX_BUCKET_NUM = 2 * common::MAX_ZONE_NUM;
|
||||
static const int64_t INVALID_CURSOR = -1;
|
||||
static const int64_t INVALID_COUNT = -1;
|
||||
// full replica
|
||||
static const char *const FULL_REPLICA_STR;
|
||||
static const char *const F_REPLICA_STR;
|
||||
// logonly replica
|
||||
static const char *const LOGONLY_REPLICA_STR;
|
||||
static const char *const L_REPLICA_STR;
|
||||
// readonly replica
|
||||
static const char *const READONLY_REPLICA_STR;
|
||||
static const char *const R_REPLICA_STR;
|
||||
// encryption logonly replica
|
||||
static const char *const ENCRYPTION_LOGONLY_REPLICA_STR;
|
||||
static const char *const E_REPLICA_STR;
|
||||
// others
|
||||
static const common::ObZone EVERY_ZONE;
|
||||
static const char *const ALL_SERVER_STR;
|
||||
static const char *const MEMSTORE_PERCENT_STR;
|
||||
@ -173,6 +154,12 @@ private:
|
||||
: 0);
|
||||
return num;
|
||||
}
|
||||
inline int64_t get_columnstore_replica_num() const {
|
||||
int64_t num = (all_replica_attr_array_[COLUMNSTORE_REPLICA].count() > 0
|
||||
? all_replica_attr_array_[COLUMNSTORE_REPLICA].at(0).num_
|
||||
: 0);
|
||||
return num;
|
||||
}
|
||||
inline const ReplicaAttrArray &get_full_replica_attr() const {
|
||||
return all_replica_attr_array_[FULL_REPLICA];
|
||||
}
|
||||
@ -185,6 +172,9 @@ private:
|
||||
inline const ReplicaAttrArray &get_encryption_logonly_replica_attr() const {
|
||||
return all_replica_attr_array_[ENCRYPTION_LOGONLY_REPLICA];
|
||||
}
|
||||
inline const ReplicaAttrArray &get_columnstore_replica_attr() const {
|
||||
return all_replica_attr_array_[COLUMNSTORE_REPLICA];
|
||||
}
|
||||
inline const common::ObIArray<common::ObZone> &get_zone_set() const { return zone_set_; }
|
||||
public:
|
||||
int format_to_locality_str(char *buf, int64_t buf_len, int64_t &pos) const;
|
||||
@ -199,7 +189,8 @@ private:
|
||||
"full_replica_attr", all_replica_attr_array_[FULL_REPLICA],
|
||||
"logonly_replica_attr", all_replica_attr_array_[LOGONLY_REPLICA],
|
||||
"readonly_replica_attr", all_replica_attr_array_[READONLY_REPLICA],
|
||||
"encryption_logonly_replica_attr", all_replica_attr_array_[ENCRYPTION_LOGONLY_REPLICA]);
|
||||
"encryption_logonly_replica_attr", all_replica_attr_array_[ENCRYPTION_LOGONLY_REPLICA],
|
||||
"columnstore_replica_attr", all_replica_attr_array_[COLUMNSTORE_REPLICA]);
|
||||
private:
|
||||
bool specific_replica_need_format(
|
||||
const ReplicaTypeID replica_type) const;
|
||||
|
@ -35,7 +35,7 @@ struct ObReplicaAddr
|
||||
initial_leader_(false),
|
||||
addr_(),
|
||||
zone_(),
|
||||
replica_type_(common::REPLICA_TYPE_MAX),
|
||||
replica_type_(common::REPLICA_TYPE_INVALID),
|
||||
replica_property_() {}
|
||||
void reset() { *this = ObReplicaAddr(); }
|
||||
int64_t get_memstore_percent() const {return replica_property_.get_memstore_percent();}
|
||||
|
@ -2565,14 +2565,10 @@ int ObRootService::create_resource_pool(const obrpc::ObCreateResourcePoolArg &ar
|
||||
LOG_USER_ERROR(OB_MISS_ARGUMENT, "unit_num");
|
||||
}
|
||||
LOG_WARN("missing arg to create resource pool", K(arg), K(ret));
|
||||
} else if (REPLICA_TYPE_LOGONLY != arg.replica_type_
|
||||
&& REPLICA_TYPE_FULL != arg.replica_type_) {
|
||||
} else if (REPLICA_TYPE_FULL != arg.replica_type_) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("only full/logonly pool are supported", K(ret), K(arg));
|
||||
} else if (REPLICA_TYPE_LOGONLY == arg.replica_type_
|
||||
&& arg.unit_num_> 1) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("logonly resource pool should only have one unit on one zone", K(ret), K(arg));
|
||||
LOG_WARN("only full replica pool are supported", K(ret), K(arg));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "replica_type of resource pool other than FULL replica");
|
||||
} else if (0 == arg.unit_.case_compare(OB_STANDBY_UNIT_CONFIG_TEMPLATE_NAME)) {
|
||||
ret = OB_OP_NOT_ALLOW;
|
||||
LOG_WARN("can not create resource pool use standby unit config template", K(ret), K(arg));
|
||||
@ -9374,7 +9370,7 @@ int ObRootService::add_rs_event_for_alter_ls_replica_(
|
||||
ROOTSERVICE_EVENT_ADD(ADD_EVENT_FOR_ALTER_LS_REPLICA,
|
||||
"ls_id", arg.get_ls_id().id(),
|
||||
"target_replica", arg.get_server_addr(),
|
||||
"replica_type", replica_type_to_str(arg.get_replica_type()),
|
||||
"replica_type", share::ObShareUtil::replica_type_to_string(arg.get_replica_type()),
|
||||
"", NULL,
|
||||
extra_info);
|
||||
} else if (arg.get_alter_task_type().is_migrate_task()) {
|
||||
@ -9641,6 +9637,31 @@ int ObRootService::check_restore_tenant_valid(const share::ObPhysicalRestoreJob
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if loclaity contains any C replica
|
||||
ObLocalityDistribution locality_dist;
|
||||
common::ObArray<share::schema::ObZoneRegion> zone_region_list;
|
||||
common::ObArray<share::ObZoneReplicaAttrSet> zone_replica_num_array;
|
||||
if (OB_FAIL(ret)) {
|
||||
// already failed
|
||||
} else if (OB_FAIL(locality_dist.init())) {
|
||||
LOG_WARN("fail to init locality dist", K(ret));
|
||||
} else if (OB_FAIL(ddl_service_.construct_zone_region_list(zone_region_list, zones))) {
|
||||
LOG_WARN("fail to construct zone region list", K(ret));
|
||||
} else if (OB_FAIL(locality_dist.parse_locality(
|
||||
job_info.get_locality(), zones, &zone_region_list))) {
|
||||
LOG_WARN("fail to parse locality", K(ret));
|
||||
} else if (OB_FAIL(locality_dist.get_zone_replica_attr_array(zone_replica_num_array))) {
|
||||
LOG_WARN("fail to get zone region replica num array", K(ret));
|
||||
} else {
|
||||
FOREACH_X(zone_replica_attr, zone_replica_num_array, OB_SUCC(ret)) {
|
||||
if (zone_replica_attr->get_columnstore_replica_num() > 0) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("restore tenant with C replica not supported", KR(ret),
|
||||
"locality_str", job_info.get_locality(), K(zone_replica_num_array));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "restore tenant with COLUMNSTORE replica in locality is");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO check if need check R replica
|
||||
|
@ -569,188 +569,6 @@ int ObTenantGroupParser::jump_to_next_ttg(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocalityTaskHelp::filter_logonly_task(const common::ObIArray<share::ObResourcePoolName> &pools,
|
||||
ObUnitManager &unit_mgr,
|
||||
ObIArray<share::ObZoneReplicaNumSet> &zone_locality)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObArray<ObUnitInfo> logonly_unit_infos;
|
||||
ObArray<ObUnitInfo> unit_infos;
|
||||
if (pools.count() <= 0) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(pools));
|
||||
} else if (OB_FAIL(unit_mgr.get_unit_infos(pools, unit_infos))) {
|
||||
LOG_WARN("fail to get unit infos", K(ret), K(pools));
|
||||
} else {
|
||||
for (int64_t i = 0; i < unit_infos.count() && OB_SUCC(ret); ++i) {
|
||||
if (REPLICA_TYPE_LOGONLY != unit_infos.at(i).unit_.replica_type_) {
|
||||
// only L unit is counted
|
||||
} else if (OB_FAIL(logonly_unit_infos.push_back(unit_infos.at(i)))) {
|
||||
LOG_WARN("fail to push back", K(ret), K(i), K(unit_infos));
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; i < zone_locality.count() && OB_SUCC(ret); ++i) {
|
||||
share::ObZoneReplicaAttrSet &zone_replica_attr_set = zone_locality.at(i);
|
||||
if (zone_replica_attr_set.get_logonly_replica_num()
|
||||
+ zone_replica_attr_set.get_encryption_logonly_replica_num() <= 0) {
|
||||
// no L replica : nothing todo
|
||||
} else if (zone_replica_attr_set.zone_set_.count() <= 0) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("zone set unexpected", K(ret), K(zone_replica_attr_set));
|
||||
} else {
|
||||
for (int64_t j = 0; j < logonly_unit_infos.count(); j++) {
|
||||
const ObUnitInfo &unit_info = logonly_unit_infos.at(j);
|
||||
if (!has_exist_in_array(zone_replica_attr_set.zone_set_, unit_info.unit_.zone_)) {
|
||||
// bypass
|
||||
} else if (zone_replica_attr_set.get_logonly_replica_num()
|
||||
+ zone_replica_attr_set.get_encryption_logonly_replica_num() <= 0) {
|
||||
// bypass
|
||||
} else if (zone_replica_attr_set.get_logonly_replica_num() > 0) {
|
||||
ret = zone_replica_attr_set.sub_logonly_replica_num(ReplicaAttr(1, 100));
|
||||
} else {
|
||||
ret = zone_replica_attr_set.sub_encryption_logonly_replica_num(ReplicaAttr(1, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocalityTaskHelp::get_logonly_task_with_logonly_unit(const uint64_t tenant_id,
|
||||
ObUnitManager &unit_mgr,
|
||||
share::schema::ObSchemaGetterGuard &schema_guard,
|
||||
ObIArray<share::ObZoneReplicaNumSet> &zone_locality)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObArray<ObUnitInfo> logonly_unit_infos;
|
||||
const ObTenantSchema *tenant_schema = NULL;
|
||||
zone_locality.reset();
|
||||
common::ObArray<share::ObZoneReplicaAttrSet> tenant_zone_locality;
|
||||
if (OB_INVALID_ID == tenant_id) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(schema_guard.get_tenant_info(tenant_id, tenant_schema))) {
|
||||
LOG_WARN("fail to get tenant info", K(ret), K(tenant_id));
|
||||
} else if (OB_ISNULL(tenant_schema)) {
|
||||
ret = OB_TENANT_NOT_EXIST;
|
||||
LOG_WARN("get invalid tenant schema", K(ret), K(tenant_schema));
|
||||
} else if (OB_FAIL(unit_mgr.get_logonly_unit_by_tenant(tenant_id, logonly_unit_infos))) {
|
||||
LOG_WARN("fail to get logonly unit infos", K(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(tenant_schema->get_zone_replica_attr_array(tenant_zone_locality))) {
|
||||
LOG_WARN("fail to get zone replica attr array", K(ret));
|
||||
} else {
|
||||
share::ObZoneReplicaNumSet logonly_set;
|
||||
for (int64_t i = 0; i < logonly_unit_infos.count() && OB_SUCC(ret); i++) {
|
||||
const ObUnitInfo &unit = logonly_unit_infos.at(i);
|
||||
for (int64_t j = 0; j < tenant_zone_locality.count(); j++) {
|
||||
logonly_set.reset();
|
||||
const ObZoneReplicaNumSet &zone_set = tenant_zone_locality.at(j);
|
||||
if (zone_set.zone_ == unit.unit_.zone_
|
||||
&& zone_set.get_logonly_replica_num() == 1) {
|
||||
logonly_set.zone_ = zone_set.zone_;
|
||||
if (OB_FAIL(logonly_set.replica_attr_set_.add_logonly_replica_num(ReplicaAttr(1, 100)))) {
|
||||
LOG_WARN("fail to add logonly replica num", K(ret));
|
||||
} else if (OB_FAIL(zone_locality.push_back(logonly_set))) {
|
||||
LOG_WARN("fail to push back", K(ret));
|
||||
}
|
||||
} else if (zone_set.zone_ == unit.unit_.zone_
|
||||
&& zone_set.get_encryption_logonly_replica_num() == 1) {
|
||||
logonly_set.zone_ = zone_set.zone_;
|
||||
if (OB_FAIL(logonly_set.replica_attr_set_.add_encryption_logonly_replica_num(ReplicaAttr(1, 100)))) {
|
||||
LOG_WARN("fail to add logonly replica num", K(ret));
|
||||
} else if (OB_FAIL(zone_locality.push_back(logonly_set))) {
|
||||
LOG_WARN("fail to push back", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocalityTaskHelp::filter_logonly_task(const uint64_t tenant_id,
|
||||
ObUnitManager &unit_mgr,
|
||||
share::schema::ObSchemaGetterGuard &schema_guard,
|
||||
ObIArray<share::ObZoneReplicaAttrSet> &zone_locality)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObArray<ObUnitInfo> logonly_unit_infos;
|
||||
if (OB_FAIL(unit_mgr.get_logonly_unit_by_tenant(schema_guard, tenant_id, logonly_unit_infos))) {
|
||||
LOG_WARN("fail to get loggonly unit by tenant", K(ret), K(tenant_id));
|
||||
} else {
|
||||
LOG_DEBUG("get all logonly unit", K(tenant_id), K(logonly_unit_infos), K(zone_locality));
|
||||
for (int64_t i = 0; i < zone_locality.count() && OB_SUCC(ret); ++i) {
|
||||
share::ObZoneReplicaAttrSet &zone_replica_attr_set = zone_locality.at(i);
|
||||
if (zone_replica_attr_set.get_logonly_replica_num()
|
||||
+ zone_replica_attr_set.get_encryption_logonly_replica_num() <= 0) {
|
||||
// no L replica : nothing todo
|
||||
} else if (zone_replica_attr_set.zone_set_.count() <= 0) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("zone set unexpected", K(ret), K(zone_replica_attr_set));
|
||||
} else {
|
||||
for (int64_t j = 0; j < logonly_unit_infos.count(); j++) {
|
||||
const ObUnitInfo &unit_info = logonly_unit_infos.at(j);
|
||||
if (!has_exist_in_array(zone_replica_attr_set.zone_set_, unit_info.unit_.zone_)) {
|
||||
// bypass
|
||||
} else if (zone_replica_attr_set.get_logonly_replica_num()
|
||||
+ zone_replica_attr_set.get_encryption_logonly_replica_num() <= 0) {
|
||||
// bypass
|
||||
} else if (zone_replica_attr_set.get_logonly_replica_num() > 0) {
|
||||
ret = zone_replica_attr_set.sub_logonly_replica_num(ReplicaAttr(1, 100));
|
||||
} else {
|
||||
ret = zone_replica_attr_set.sub_encryption_logonly_replica_num(ReplicaAttr(1, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocalityTaskHelp::alloc_logonly_replica(ObUnitManager &unit_mgr,
|
||||
const ObIArray<share::ObResourcePoolName> &pools,
|
||||
const common::ObIArray<ObZoneReplicaNumSet> &zone_locality,
|
||||
ObPartitionAddr &partition_addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObArray<ObUnitInfo> logonly_units;
|
||||
ObArray<ObUnitInfo> unit_infos;
|
||||
if (OB_FAIL(unit_mgr.get_unit_infos(pools, unit_infos))) {
|
||||
LOG_WARN("fail to get unit infos", K(ret), K(pools));
|
||||
} else {
|
||||
for (int64_t i = 0; i < unit_infos.count() && OB_SUCC(ret); i++) {
|
||||
if (REPLICA_TYPE_LOGONLY != unit_infos.at(i).unit_.replica_type_) {
|
||||
//nothing todo
|
||||
} else if (OB_FAIL(logonly_units.push_back(unit_infos.at(i)))) {
|
||||
LOG_WARN("fail to push back", K(ret), K(i), K(unit_infos));
|
||||
}
|
||||
}
|
||||
}
|
||||
ObReplicaAddr raddr;
|
||||
for (int64_t i = 0; i < logonly_units.count() && OB_SUCC(ret); i++) {
|
||||
for (int64_t j = 0; j < zone_locality.count() && OB_SUCC(ret); j++) {
|
||||
if (zone_locality.at(j).zone_ == logonly_units.at(i).unit_.zone_
|
||||
&& (zone_locality.at(j).get_logonly_replica_num() == 1
|
||||
|| zone_locality.at(j).get_encryption_logonly_replica_num() == 1)) {
|
||||
raddr.reset();
|
||||
raddr.unit_id_ = logonly_units.at(i).unit_.unit_id_;
|
||||
raddr.addr_ = logonly_units.at(i).unit_.server_;
|
||||
raddr.zone_ = logonly_units.at(i).unit_.zone_;
|
||||
raddr.replica_type_ = zone_locality.at(j).get_logonly_replica_num() == 1
|
||||
? REPLICA_TYPE_LOGONLY
|
||||
: REPLICA_TYPE_ENCRYPTION_LOGONLY;
|
||||
if (OB_FAIL(partition_addr.push_back(raddr))) {
|
||||
LOG_WARN("fail to push back", K(ret), K(raddr));
|
||||
} else {
|
||||
LOG_INFO("alloc partition for logonly replica", K(raddr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocalityCheckHelp::calc_paxos_replica_num(
|
||||
const common::ObIArray<share::ObZoneReplicaNumSet> &zone_locality,
|
||||
int64_t &paxos_num)
|
||||
@ -1562,6 +1380,7 @@ int ObLocalityCheckHelp::check_alter_single_zone_locality_valid(
|
||||
int ret = OB_SUCCESS;
|
||||
bool is_legal = true;
|
||||
// 1. check whether non_paxos member change
|
||||
// check R-replica
|
||||
if (!non_paxos_locality_modified) {
|
||||
const ObIArray<ReplicaAttr> &pre_readonly_replica = orig_locality.replica_attr_set_.get_readonly_replica_attr_array();
|
||||
const ObIArray<ReplicaAttr> &cur_readonly_replica = new_locality.replica_attr_set_.get_readonly_replica_attr_array();
|
||||
@ -1577,8 +1396,19 @@ int ObLocalityCheckHelp::check_alter_single_zone_locality_valid(
|
||||
}
|
||||
}
|
||||
}
|
||||
// check C-replica
|
||||
if (new_locality.get_columnstore_replica_num() != orig_locality.get_columnstore_replica_num()) {
|
||||
if (new_locality.get_full_replica_num() != orig_locality.get_full_replica_num()
|
||||
|| new_locality.get_readonly_replica_num() != orig_locality.get_readonly_replica_num()) {
|
||||
// transform between R/F and C is illegal
|
||||
is_legal = false;
|
||||
} else {
|
||||
non_paxos_locality_modified = true;
|
||||
}
|
||||
}
|
||||
// 2. check whether alter locality is legal.
|
||||
if (new_locality.get_logonly_replica_num() < orig_locality.get_logonly_replica_num()) {
|
||||
if (!is_legal) {
|
||||
} else if (new_locality.get_logonly_replica_num() < orig_locality.get_logonly_replica_num()) {
|
||||
// L-replica must not transfrom to other replica type.
|
||||
if (new_locality.get_full_replica_num() > orig_locality.get_full_replica_num()) {
|
||||
is_legal = false; // maybe L->F
|
||||
|
@ -36,7 +36,6 @@ namespace schema
|
||||
{
|
||||
class ObMultiVersionSchemaService;
|
||||
class ObTableSchema;
|
||||
class ObLocality;
|
||||
class ObSchemaGetterGuard;
|
||||
}
|
||||
}
|
||||
@ -394,35 +393,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class ObLocalityTaskHelp
|
||||
{
|
||||
public:
|
||||
ObLocalityTaskHelp() {}
|
||||
virtual ~ObLocalityTaskHelp() {}
|
||||
static int filter_logonly_task(
|
||||
const common::ObIArray<share::ObResourcePoolName> &pools,
|
||||
ObUnitManager &unit_mgr,
|
||||
common::ObIArray<share::ObZoneReplicaAttrSet> &zone_locality);
|
||||
|
||||
static int filter_logonly_task(
|
||||
const uint64_t tenant_id,
|
||||
ObUnitManager &unit_manager,
|
||||
share::schema::ObSchemaGetterGuard &schema_guard,
|
||||
common::ObIArray<share::ObZoneReplicaAttrSet> &zone_locality);
|
||||
|
||||
static int alloc_logonly_replica(
|
||||
ObUnitManager &unit_manager,
|
||||
const common::ObIArray<share::ObResourcePoolName> &pools,
|
||||
const common::ObIArray<share::ObZoneReplicaAttrSet> &zone_locality,
|
||||
ObPartitionAddr &partition_addr);
|
||||
|
||||
static int get_logonly_task_with_logonly_unit(
|
||||
const uint64_t tenant_id,
|
||||
ObUnitManager &unit_mgr,
|
||||
share::schema::ObSchemaGetterGuard &schema_guard,
|
||||
common::ObIArray<share::ObZoneReplicaAttrSet> &zone_locality);
|
||||
};
|
||||
|
||||
enum PaxosReplicaNumberTaskType
|
||||
{
|
||||
NOP_PAXOS_REPLICA_NUMBER = 0,
|
||||
|
@ -2744,7 +2744,7 @@ int ObUnitManager::check_old_pool_name_condition(
|
||||
common::ObIArray<share::ObResourcePool*> &old_pool)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_MAX;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_INVALID;
|
||||
uint64_t tenant_id = OB_INVALID_ID;
|
||||
share::ObUnitConfig *unit_config = NULL;
|
||||
int64_t unit_count = 0;
|
||||
|
@ -184,11 +184,11 @@ int ObAllVirtualLSReplicaTaskPlan::get_full_row_(
|
||||
ADD_COLUMN(set_varchar, table, "target_replica_svr_ip", target_ip_str, columns);
|
||||
ADD_COLUMN(set_int, table, "target_replica_svr_port", target_port, columns);
|
||||
ADD_COLUMN(set_int, table, "target_paxos_replica_number", task_stat.get_target_replica_paxos_replica_number(), columns);
|
||||
ADD_COLUMN(set_varchar, table, "target_replica_type", ob_replica_type_strs(task_stat.get_target_replica_type()), columns);
|
||||
ADD_COLUMN(set_varchar, table, "target_replica_type", ObShareUtil::replica_type_to_string(task_stat.get_target_replica_type()), columns);
|
||||
ADD_COLUMN(set_varchar, table, "source_replica_svr_ip", task_stat.get_source_server().is_valid() ? source_ip_str : "", columns);
|
||||
ADD_COLUMN(set_int, table, "source_replica_svr_port", source_port, columns);
|
||||
ADD_COLUMN(set_int, table, "source_paxos_replica_number", task_stat.get_source_replica_paxos_replica_number(), columns);
|
||||
ADD_COLUMN(set_varchar, table, "source_replica_type", task_stat.get_source_server().is_valid() ? ob_replica_type_strs(task_stat.get_source_replica_type()) : "", columns);
|
||||
ADD_COLUMN(set_varchar, table, "source_replica_type", task_stat.get_source_server().is_valid() ? ObShareUtil::replica_type_to_string(task_stat.get_source_replica_type()) : "", columns);
|
||||
ADD_COLUMN(set_varchar, table, "task_exec_svr_ip", execute_ip_str, columns);
|
||||
ADD_COLUMN(set_int, table, "task_exec_svr_port", execute_port, columns);
|
||||
ADD_COLUMN(set_varchar, table, "comment", task_stat.get_comment().string(), columns);
|
||||
|
@ -127,7 +127,6 @@ ob_set_subtarget(ob_share common
|
||||
ob_list_parser.cpp
|
||||
ob_local_device.cpp
|
||||
ob_locality_info.cpp
|
||||
ob_locality_parser.cpp
|
||||
ob_locality_priority.cpp
|
||||
ob_locality_table_operator.cpp
|
||||
ob_ls_id.cpp
|
||||
|
@ -61,7 +61,7 @@ inline bool ObFeedbackReplicaLocation::is_valid_obj() const
|
||||
{
|
||||
return server_.is_valid()
|
||||
&& (common::INVALID_ROLE != role_)
|
||||
&& (common::REPLICA_TYPE_MAX != replica_type_);
|
||||
&& (common::REPLICA_TYPE_INVALID != replica_type_);
|
||||
}
|
||||
|
||||
class ObFeedbackPartitionLocation : public ObAbstractFeedbackObject<ObFeedbackPartitionLocation>
|
||||
@ -195,7 +195,7 @@ inline bool ObFeedbackRerouteInfo::is_valid_obj() const
|
||||
return (for_session_reroute_ && server_.is_valid()) ||
|
||||
(!for_session_reroute_ && server_.is_valid()
|
||||
&& (common::INVALID_ROLE != role_)
|
||||
&& (common::REPLICA_TYPE_MAX != replica_type_)
|
||||
&& (common::REPLICA_TYPE_INVALID != replica_type_)
|
||||
&& tbl_name_len_ > 0
|
||||
&& tbl_name_len_ <= common::OB_MAX_TABLE_NAME_LENGTH
|
||||
&& OB_INVALID_VERSION != tbl_schema_version_);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "share/compaction/ob_compaction_locality_cache.h"
|
||||
#include "src/storage/compaction/ob_medium_compaction_func.h"
|
||||
#include "src/storage/compaction/ob_compaction_util.h"
|
||||
#include "src/storage/tx_storage/ob_ls_service.h"
|
||||
#include "src/share/ob_zone_merge_info.h"
|
||||
#include "observer/ob_server_struct.h"
|
||||
#include "src/share/ob_zone_merge_table_operator.h"
|
||||
@ -22,11 +23,233 @@ namespace oceanbase
|
||||
namespace share
|
||||
{
|
||||
|
||||
/****************************** ObLSReplicaUniItem ******************************/
|
||||
ObLSReplicaUniItem::ObLSReplicaUniItem()
|
||||
: ls_id_(),
|
||||
server_()
|
||||
{}
|
||||
|
||||
ObLSReplicaUniItem::ObLSReplicaUniItem(const ObLSID &ls_id, const common::ObAddr &server)
|
||||
: ls_id_(ls_id),
|
||||
server_(server)
|
||||
{}
|
||||
|
||||
ObLSReplicaUniItem::~ObLSReplicaUniItem()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
void ObLSReplicaUniItem::reset() {
|
||||
ls_id_.reset();
|
||||
server_.reset();
|
||||
}
|
||||
|
||||
uint64_t ObLSReplicaUniItem::hash() const
|
||||
{
|
||||
uint64_t hash_val = 0;
|
||||
hash_val += ls_id_.hash();
|
||||
hash_val += server_.hash();
|
||||
return hash_val;
|
||||
}
|
||||
|
||||
int ObLSReplicaUniItem::hash(uint64_t &hash_val) const
|
||||
{
|
||||
hash_val = hash();
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
bool ObLSReplicaUniItem::is_valid() const
|
||||
{
|
||||
return ls_id_.is_valid() && server_.is_valid();
|
||||
}
|
||||
|
||||
bool ObLSReplicaUniItem::operator == (const ObLSReplicaUniItem &other) const
|
||||
{
|
||||
bool bret = true;
|
||||
if (this == &other) {
|
||||
} else if (ls_id_ != other.ls_id_ || server_ != other.server_) {
|
||||
bret = false;
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
bool ObLSReplicaUniItem::operator != (const ObLSReplicaUniItem &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/****************************** ObLSColumnReplicaCache ******************************/
|
||||
ObLSColumnReplicaCache::ObLSColumnReplicaCache()
|
||||
: is_inited_(false),
|
||||
ls_id_set_(),
|
||||
ls_replica_set_()
|
||||
{}
|
||||
|
||||
ObLSColumnReplicaCache::~ObLSColumnReplicaCache()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
// init
|
||||
int ObLSColumnReplicaCache::init()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (IS_INIT) {
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("init twice", K(ret));
|
||||
} else if (OB_FAIL(ls_id_set_.create(BUCKET_NUM_OF_LS_ID_SET, ObMemAttr(MTL_ID(), "LSIDsForCkm")))) {
|
||||
LOG_WARN("fail to create ls id set", K(ret));
|
||||
} else if (OB_FAIL(ls_replica_set_.create(BUCKET_NUM_OF_LS_REPLICA_SET, ObMemAttr(MTL_ID(), "LSReplTypes")))) {
|
||||
LOG_WARN("fail to create ls replica type map", K(ret));
|
||||
} else {
|
||||
is_inited_ = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObLSColumnReplicaCache::destroy()
|
||||
{
|
||||
int ret = OB_SUCCESS; // only for log
|
||||
if (ls_replica_set_.created()) {
|
||||
if (OB_FAIL(ls_replica_set_.destroy())) {
|
||||
LOG_WARN("fail to destroy ls replica set", K(ret));
|
||||
}
|
||||
}
|
||||
if (ls_id_set_.created()) {
|
||||
if (OB_FAIL(ls_id_set_.destroy())) {
|
||||
LOG_WARN("fail to destroy ls replica set", K(ret));
|
||||
}
|
||||
}
|
||||
is_inited_ = false;
|
||||
}
|
||||
|
||||
void ObLSColumnReplicaCache::reuse()
|
||||
{
|
||||
ls_id_set_.reuse();
|
||||
ls_replica_set_.reuse();
|
||||
}
|
||||
|
||||
int ObLSColumnReplicaCache::check_contains_ls(const ObLSID &ls_id, bool &contained) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
contained = false;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret));
|
||||
} else if (OB_FAIL(ls_id_set_.exist_refactored(ls_id))) {
|
||||
if (OB_HASH_EXIST == ret || OB_HASH_NOT_EXIST == ret) {
|
||||
contained = (OB_HASH_EXIST == ret);
|
||||
ret = OB_SUCCESS;
|
||||
} else {
|
||||
LOG_WARN("fail to check contains ls", K(ret), K(ls_id), KPC(this));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLSColumnReplicaCache::mark_ls_finished(const ObLSID &ls_id)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret));
|
||||
} else if (OB_FAIL(ls_id_set_.set_refactored(ls_id))) {
|
||||
if (OB_HASH_EXIST == ret) {
|
||||
ret = OB_SUCCESS;
|
||||
} else {
|
||||
LOG_WARN("fail to mark ls finish", K(ret), K(ls_id), KPC(this));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLSColumnReplicaCache::add_cs_replica(const ObLSReplicaUniItem &ls_item)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret));
|
||||
} else if (OB_FAIL(ls_replica_set_.set_refactored(ls_item))) {
|
||||
LOG_WARN("fail to add col replica", K(ret), K(ls_item), KPC(this));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLSColumnReplicaCache::update(const ObLSID &ls_id, const ObAddr &server)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool is_contained = false;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret));
|
||||
} else if (OB_FAIL(check_contains_ls(ls_id, is_contained))) {
|
||||
LOG_WARN("fail to check exist for ls", K(ls_id), KPC(this));
|
||||
} else if (is_contained) {
|
||||
} else if (OB_ISNULL(GCTX.lst_operator_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("lst operator is null", K(ret));
|
||||
} else {
|
||||
const int64_t tenant_id = MTL_ID();
|
||||
const int64_t cluster_id = GCONF.cluster_id;
|
||||
ObLSInfo ls_info;
|
||||
if (OB_FAIL(GCTX.lst_operator_->get(cluster_id, tenant_id, ls_id, ObLSTable::DEFAULT_MODE, ls_info))) {
|
||||
LOG_WARN("fail to get ls info", K(ret), K(cluster_id), K(tenant_id), K(ls_id));
|
||||
} else {
|
||||
const ObLSInfo::ReplicaArray &all_replicas = ls_info.get_replicas();
|
||||
ObLSReplicaUniItem ls_item(ls_id, server);
|
||||
for (int64_t i = 0; i < all_replicas.count() && OB_SUCC(ret); ++i) {
|
||||
const ObLSReplica &replica = all_replicas.at(i);
|
||||
if (ObRole::LEADER == replica.get_role()) {
|
||||
const common::GlobalLearnerList &learner_list = replica.get_learner_list();
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < learner_list.get_member_number(); ++i) {
|
||||
ObMember learner;
|
||||
if (OB_FAIL(learner_list.get_learner(i, learner))) {
|
||||
LOG_WARN("fail to get learner", K(ret), K(i), K(learner_list));
|
||||
} else if (learner.is_columnstore()) {
|
||||
ls_item.server_ = learner.get_server();
|
||||
if (OB_FAIL(add_cs_replica(ls_item))) {
|
||||
LOG_WARN("fail to add ls item", K(ret), K(ls_item));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(mark_ls_finished(ls_item.ls_id_))) {
|
||||
LOG_WARN("fail to make ls finished", K(ret));
|
||||
}
|
||||
LOG_TRACE("[CS-Replica] get learner list", K(ret), K(learner_list));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLSColumnReplicaCache::check_is_cs_replica(const ObLSReplicaUniItem &ls_item, bool &is_cs_replica) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_cs_replica = false;
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret));
|
||||
} else if (OB_FAIL(ls_replica_set_.exist_refactored(ls_item))) {
|
||||
if (OB_HASH_EXIST == ret || OB_HASH_NOT_EXIST == ret) {
|
||||
is_cs_replica = (OB_HASH_EXIST == ret);
|
||||
ret = OB_SUCCESS;
|
||||
} else {
|
||||
LOG_WARN("fail to check contains ls", K(ret), K(ls_item), KPC(this));
|
||||
}
|
||||
}
|
||||
LOG_TRACE("[CS-Replica] check current ls is cs replica", K(ret), K(ls_item), K(is_cs_replica), KPC(this));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************** ObCompactionLocalityCache ******************************/
|
||||
ObCompactionLocalityCache::ObCompactionLocalityCache()
|
||||
: is_inited_(false),
|
||||
tenant_id_(OB_INVALID_TENANT_ID),
|
||||
merge_info_mgr_(nullptr),
|
||||
ls_infos_map_()
|
||||
ls_infos_map_(),
|
||||
ls_cs_replica_cache_()
|
||||
{}
|
||||
|
||||
ObCompactionLocalityCache::~ObCompactionLocalityCache()
|
||||
@ -45,6 +268,8 @@ int ObCompactionLocalityCache::init(const uint64_t tenant_id, rootserver::ObMajo
|
||||
LOG_WARN("invalid argument", K(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(ls_infos_map_.create(OB_MAX_LS_NUM_PER_TENANT_PER_SERVER, "CaLsInfoMap", "CaLsInfoNode", tenant_id))) {
|
||||
LOG_WARN("fail to create ls info map", K(ret));
|
||||
} else if (OB_FAIL(ls_cs_replica_cache_.init())) {
|
||||
LOG_WARN("fail to init col replica cache", K(ret));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
destroy();
|
||||
@ -100,6 +325,7 @@ int ObCompactionLocalityCache::inner_refresh_ls_locality()
|
||||
if (OB_SUCC(ret)) {
|
||||
// 1. clear ls_infos cached in memory
|
||||
ls_infos_map_.reuse();
|
||||
ls_cs_replica_cache_.reuse();
|
||||
// 2. load ls_infos from __all_ls_meta_table
|
||||
ObArray<ObLSInfo> ls_infos;
|
||||
ls_infos.set_attr(ObMemAttr(tenant_id_, "RefLSInfos"));
|
||||
@ -230,12 +456,16 @@ int ObCompactionLocalityCache::refresh_by_zone(
|
||||
} else if (OB_FAIL(tmp_ls_info.init_by_replica(tmp_replica))) {
|
||||
LOG_WARN("fail to init ls_info by replica", KR(ret), K(tmp_replica));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (tmp_replica.is_column_replica() && OB_FAIL(ls_cs_replica_cache_.add_cs_replica(ObLSReplicaUniItem(ls_id, tmp_replica.get_server())))) {
|
||||
LOG_WARN("fail to add cs replica", K(ret), K(ls_id), K(tmp_replica), K_(ls_cs_replica_cache));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (FAILEDx(ls_infos_map_.set_refactored(ls_id, tmp_ls_info, 1/*overwrite*/))) {
|
||||
LOG_WARN("fail to set refactored", KR(ret), K(ls_id), K(tmp_ls_info));
|
||||
} else {
|
||||
FLOG_INFO("success to refresh cached ls_info", K(ret), K(tmp_ls_info), K(zone_list), K(member_list_array));
|
||||
FLOG_INFO("success to refresh cached ls_info", K(ret), K(tmp_ls_info), K(zone_list));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -29,6 +29,46 @@ class ObMySQLResult;
|
||||
namespace share
|
||||
{
|
||||
|
||||
struct ObLSReplicaUniItem
|
||||
{
|
||||
ObLSReplicaUniItem();
|
||||
ObLSReplicaUniItem(const ObLSID &ls_id, const common::ObAddr &server);
|
||||
~ObLSReplicaUniItem();
|
||||
void reset();
|
||||
uint64_t hash() const;
|
||||
int hash(uint64_t &hash_val) const;
|
||||
bool is_valid() const;
|
||||
bool operator == (const ObLSReplicaUniItem &other) const;
|
||||
bool operator != (const ObLSReplicaUniItem &other) const;
|
||||
TO_STRING_KV(K_(ls_id), K_(server));
|
||||
|
||||
share::ObLSID ls_id_;
|
||||
common::ObAddr server_;
|
||||
};
|
||||
|
||||
class ObLSColumnReplicaCache
|
||||
{
|
||||
public:
|
||||
ObLSColumnReplicaCache();
|
||||
~ObLSColumnReplicaCache();
|
||||
int init();
|
||||
void destroy();
|
||||
void reuse();
|
||||
int check_contains_ls(const ObLSID &ls_id, bool &contained) const;
|
||||
int mark_ls_finished(const ObLSID &ls_id);
|
||||
int add_cs_replica(const ObLSReplicaUniItem &ls_item);
|
||||
int update(const ObLSID &ls_id, const ObAddr &server);
|
||||
int check_is_cs_replica(const ObLSReplicaUniItem &ls_item, bool &is_cs_replica) const;
|
||||
TO_STRING_KV(K_(is_inited), K_(ls_id_set), K_(ls_replica_set));
|
||||
private:
|
||||
const static int64_t BUCKET_NUM_OF_LS_ID_SET = 15;
|
||||
const static int64_t BUCKET_NUM_OF_LS_REPLICA_SET = 31;
|
||||
private:
|
||||
bool is_inited_;
|
||||
hash::ObHashSet<ObLSID, hash::NoPthreadDefendMode> ls_id_set_; // pre-wamred ls id, unused
|
||||
hash::ObHashSet<ObLSReplicaUniItem, hash::NoPthreadDefendMode> ls_replica_set_; // cs-prelica ls
|
||||
};
|
||||
|
||||
class ObCompactionLocalityCache
|
||||
{
|
||||
public:
|
||||
@ -39,6 +79,7 @@ public:
|
||||
bool empty() const { return ls_infos_map_.empty(); }
|
||||
int refresh_ls_locality(const bool force_refresh);
|
||||
int get_ls_info(const share::ObLSID &ls_id, share::ObLSInfo &ls_info);
|
||||
const share::ObLSColumnReplicaCache& get_cs_replica_cache() const { return ls_cs_replica_cache_; }
|
||||
TO_STRING_KV(K_(is_inited), K_(tenant_id));
|
||||
|
||||
private:
|
||||
@ -62,6 +103,7 @@ private:
|
||||
uint64_t tenant_id_;
|
||||
rootserver::ObMajorMergeInfoManager *merge_info_mgr_;
|
||||
common::hash::ObHashMap<share::ObLSID, share::ObLSInfo> ls_infos_map_;
|
||||
share::ObLSColumnReplicaCache ls_cs_replica_cache_;
|
||||
};
|
||||
|
||||
} // namespace share
|
||||
|
@ -560,7 +560,7 @@ int ObInnerTableSchema::dba_ob_resource_pools_schema(ObTableSchema &table_schema
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT RESOURCE_POOL_ID, NAME, CASE TENANT_ID WHEN -1 THEN NULL ELSE TENANT_ID END AS TENANT_ID, gmt_create AS CREATE_TIME, gmt_modified AS MODIFY_TIME, UNIT_COUNT, UNIT_CONFIG_ID, ZONE_LIST, CASE replica_type WHEN 0 THEN "FULL" WHEN 5 THEN "LOGONLY" WHEN 16 THEN "READONLY" WHEN 261 THEN "ENCRYPTION LOGONLY" ELSE NULL END AS REPLICA_TYPE FROM oceanbase.__all_resource_pool )__"))) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT RESOURCE_POOL_ID, NAME, CASE TENANT_ID WHEN -1 THEN NULL ELSE TENANT_ID END AS TENANT_ID, gmt_create AS CREATE_TIME, gmt_modified AS MODIFY_TIME, UNIT_COUNT, UNIT_CONFIG_ID, ZONE_LIST, CASE replica_type WHEN 0 THEN "FULL" ELSE NULL END AS REPLICA_TYPE FROM oceanbase.__all_resource_pool )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
@ -910,7 +910,7 @@ int ObInnerTableSchema::dba_ob_ls_locations_schema(ObTableSchema &table_schema)
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( ( SELECT NOW(6) AS CREATE_TIME, NOW(6) AS MODIFY_TIME, LS_ID, SVR_IP, SVR_PORT, SQL_PORT, ZONE, (CASE ROLE WHEN 1 THEN "LEADER" ELSE "FOLLOWER" END) AS ROLE, (CASE ROLE WHEN 1 THEN MEMBER_LIST ELSE NULL END) AS MEMBER_LIST, (CASE ROLE WHEN 1 THEN PAXOS_REPLICA_NUMBER ELSE NULL END) AS PAXOS_REPLICA_NUMBER, (CASE REPLICA_TYPE WHEN 0 THEN "FULL" WHEN 5 THEN "LOGONLY" WHEN 16 THEN "READONLY" WHEN 261 THEN "ENCRYPTION LOGONLY" ELSE NULL END) AS REPLICA_TYPE, (CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST, (CASE REBUILD WHEN 0 THEN "FALSE" ELSE "TRUE" END) AS REBUILD FROM OCEANBASE.__ALL_VIRTUAL_CORE_META_TABLE WHERE EFFECTIVE_TENANT_ID() = 1 ) UNION ALL ( SELECT GMT_CREATE AS CREATE_TIME, GMT_MODIFIED AS MODIFY_TIME, LS_ID, SVR_IP, SVR_PORT, SQL_PORT, ZONE, (CASE ROLE WHEN 1 THEN "LEADER" ELSE "FOLLOWER" END) AS ROLE, (CASE ROLE WHEN 1 THEN MEMBER_LIST ELSE NULL END) AS MEMBER_LIST, (CASE ROLE WHEN 1 THEN PAXOS_REPLICA_NUMBER ELSE NULL END) AS PAXOS_REPLICA_NUMBER, (CASE REPLICA_TYPE WHEN 0 THEN "FULL" WHEN 5 THEN "LOGONLY" WHEN 16 THEN "READONLY" WHEN 261 THEN "ENCRYPTION LOGONLY" ELSE NULL END) AS REPLICA_TYPE, (CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST, (CASE REBUILD WHEN 0 THEN "FALSE" ELSE "TRUE" END) AS REBUILD FROM OCEANBASE.__ALL_VIRTUAL_LS_META_TABLE WHERE TENANT_ID = EFFECTIVE_TENANT_ID() AND TENANT_ID != 1 ) )__"))) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( ( SELECT NOW(6) AS CREATE_TIME, NOW(6) AS MODIFY_TIME, LS_ID, SVR_IP, SVR_PORT, SQL_PORT, ZONE, (CASE ROLE WHEN 1 THEN "LEADER" ELSE "FOLLOWER" END) AS ROLE, (CASE ROLE WHEN 1 THEN MEMBER_LIST ELSE NULL END) AS MEMBER_LIST, (CASE ROLE WHEN 1 THEN PAXOS_REPLICA_NUMBER ELSE NULL END) AS PAXOS_REPLICA_NUMBER, (CASE REPLICA_TYPE WHEN 0 THEN "FULL" WHEN 5 THEN "LOGONLY" WHEN 16 THEN "READONLY" WHEN 261 THEN "ENCRYPTION LOGONLY" WHEN 1040 THEN "COLUMNSTORE" ELSE NULL END) AS REPLICA_TYPE, (CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST, (CASE REBUILD WHEN 0 THEN "FALSE" ELSE "TRUE" END) AS REBUILD FROM OCEANBASE.__ALL_VIRTUAL_CORE_META_TABLE WHERE EFFECTIVE_TENANT_ID() = 1 ) UNION ALL ( SELECT GMT_CREATE AS CREATE_TIME, GMT_MODIFIED AS MODIFY_TIME, LS_ID, SVR_IP, SVR_PORT, SQL_PORT, ZONE, (CASE ROLE WHEN 1 THEN "LEADER" ELSE "FOLLOWER" END) AS ROLE, (CASE ROLE WHEN 1 THEN MEMBER_LIST ELSE NULL END) AS MEMBER_LIST, (CASE ROLE WHEN 1 THEN PAXOS_REPLICA_NUMBER ELSE NULL END) AS PAXOS_REPLICA_NUMBER, (CASE REPLICA_TYPE WHEN 0 THEN "FULL" WHEN 5 THEN "LOGONLY" WHEN 16 THEN "READONLY" WHEN 261 THEN "ENCRYPTION LOGONLY" WHEN 1040 THEN "COLUMNSTORE" ELSE NULL END) AS REPLICA_TYPE, (CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST, (CASE REBUILD WHEN 0 THEN "FALSE" ELSE "TRUE" END) AS REBUILD FROM OCEANBASE.__ALL_VIRTUAL_LS_META_TABLE WHERE TENANT_ID = EFFECTIVE_TENANT_ID() AND TENANT_ID != 1 ) )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
@ -960,7 +960,7 @@ int ObInnerTableSchema::cdb_ob_ls_locations_schema(ObTableSchema &table_schema)
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( ( SELECT NOW(6) AS CREATE_TIME, NOW(6) AS MODIFY_TIME, TENANT_ID, LS_ID, SVR_IP, SVR_PORT, SQL_PORT, ZONE, (CASE ROLE WHEN 1 THEN "LEADER" ELSE "FOLLOWER" END) AS ROLE, (CASE ROLE WHEN 1 THEN MEMBER_LIST ELSE NULL END) AS MEMBER_LIST, (CASE ROLE WHEN 1 THEN PAXOS_REPLICA_NUMBER ELSE NULL END) AS PAXOS_REPLICA_NUMBER, (CASE REPLICA_TYPE WHEN 0 THEN "FULL" WHEN 5 THEN "LOGONLY" WHEN 16 THEN "READONLY" WHEN 261 THEN "ENCRYPTION LOGONLY" ELSE NULL END) AS REPLICA_TYPE, (CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST, (CASE REBUILD WHEN 0 THEN "FALSE" ELSE "TRUE" END) AS REBUILD FROM OCEANBASE.__ALL_VIRTUAL_CORE_META_TABLE ) UNION ALL ( SELECT GMT_CREATE AS CREATE_TIME, GMT_MODIFIED AS MODIFY_TIME, TENANT_ID, LS_ID, SVR_IP, SVR_PORT, SQL_PORT, ZONE, (CASE ROLE WHEN 1 THEN "LEADER" ELSE "FOLLOWER" END) AS ROLE, (CASE ROLE WHEN 1 THEN MEMBER_LIST ELSE NULL END) AS MEMBER_LIST, (CASE ROLE WHEN 1 THEN PAXOS_REPLICA_NUMBER ELSE NULL END) AS PAXOS_REPLICA_NUMBER, (CASE REPLICA_TYPE WHEN 0 THEN "FULL" WHEN 5 THEN "LOGONLY" WHEN 16 THEN "READONLY" WHEN 261 THEN "ENCRYPTION LOGONLY" ELSE NULL END) AS REPLICA_TYPE, (CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST, (CASE REBUILD WHEN 0 THEN "FALSE" ELSE "TRUE" END) AS REBUILD FROM OCEANBASE.__ALL_VIRTUAL_LS_META_TABLE WHERE TENANT_ID != 1 ) )__"))) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( ( SELECT NOW(6) AS CREATE_TIME, NOW(6) AS MODIFY_TIME, TENANT_ID, LS_ID, SVR_IP, SVR_PORT, SQL_PORT, ZONE, (CASE ROLE WHEN 1 THEN "LEADER" ELSE "FOLLOWER" END) AS ROLE, (CASE ROLE WHEN 1 THEN MEMBER_LIST ELSE NULL END) AS MEMBER_LIST, (CASE ROLE WHEN 1 THEN PAXOS_REPLICA_NUMBER ELSE NULL END) AS PAXOS_REPLICA_NUMBER, (CASE REPLICA_TYPE WHEN 0 THEN "FULL" WHEN 5 THEN "LOGONLY" WHEN 16 THEN "READONLY" WHEN 261 THEN "ENCRYPTION LOGONLY" WHEN 1040 THEN "COLUMNSTORE" ELSE NULL END) AS REPLICA_TYPE, (CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST, (CASE REBUILD WHEN 0 THEN "FALSE" ELSE "TRUE" END) AS REBUILD FROM OCEANBASE.__ALL_VIRTUAL_CORE_META_TABLE ) UNION ALL ( SELECT GMT_CREATE AS CREATE_TIME, GMT_MODIFIED AS MODIFY_TIME, TENANT_ID, LS_ID, SVR_IP, SVR_PORT, SQL_PORT, ZONE, (CASE ROLE WHEN 1 THEN "LEADER" ELSE "FOLLOWER" END) AS ROLE, (CASE ROLE WHEN 1 THEN MEMBER_LIST ELSE NULL END) AS MEMBER_LIST, (CASE ROLE WHEN 1 THEN PAXOS_REPLICA_NUMBER ELSE NULL END) AS PAXOS_REPLICA_NUMBER, (CASE REPLICA_TYPE WHEN 0 THEN "FULL" WHEN 5 THEN "LOGONLY" WHEN 16 THEN "READONLY" WHEN 261 THEN "ENCRYPTION LOGONLY" WHEN 1040 THEN "COLUMNSTORE" ELSE NULL END) AS REPLICA_TYPE, (CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST, (CASE REBUILD WHEN 0 THEN "FALSE" ELSE "TRUE" END) AS REBUILD FROM OCEANBASE.__ALL_VIRTUAL_LS_META_TABLE WHERE TENANT_ID != 1 ) )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
|
@ -817,7 +817,7 @@ int ObInnerTableSchema::cdb_ob_tablet_checksum_error_info_schema(ObTableSchema &
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT TENANT_ID, TABLET_ID FROM ( SELECT TENANT_ID, TABLET_ID, ROW_COUNT, DATA_CHECKSUM, B_COLUMN_CHECKSUMS, COMPACTION_SCN FROM OCEANBASE.__ALL_VIRTUAL_TABLET_REPLICA_CHECKSUM ) J GROUP BY J.TENANT_ID, J.TABLET_ID, J.COMPACTION_SCN HAVING MIN(J.DATA_CHECKSUM) != MAX(J.DATA_CHECKSUM) OR MIN(J.ROW_COUNT) != MAX(J.ROW_COUNT) OR MIN(J.B_COLUMN_CHECKSUMS) != MAX(J.B_COLUMN_CHECKSUMS) )__"))) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT TENANT_ID, TABLET_ID FROM ( SELECT CKM.TENANT_ID, CKM.TABLET_ID, CKM.ROW_COUNT, CKM.DATA_CHECKSUM, CKM.B_COLUMN_CHECKSUMS, CKM.COMPACTION_SCN, M.REPLICA_TYPE FROM OCEANBASE.__ALL_VIRTUAL_TABLET_REPLICA_CHECKSUM CKM JOIN OCEANBASE.__ALL_VIRTUAL_LS_META_TABLE M ON CKM.TENANT_ID = M.TENANT_ID AND CKM.LS_ID = M.LS_ID AND CKM.SVR_IP = M.SVR_IP AND CKM.SVR_PORT = M.SVR_PORT ) J GROUP BY J.TENANT_ID, J.TABLET_ID, J.COMPACTION_SCN, J.REPLICA_TYPE HAVING MIN(J.DATA_CHECKSUM) != MAX(J.DATA_CHECKSUM) OR MIN(J.ROW_COUNT) != MAX(J.ROW_COUNT) OR MIN(J.B_COLUMN_CHECKSUMS) != MAX(J.B_COLUMN_CHECKSUMS) )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ int ObInnerTableSchema::dba_ob_ls_locations_ora_schema(ObTableSchema &table_sche
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(TO_CHAR(GMT_CREATE) AS VARCHAR2(19)) AS CREATE_TIME, CAST(TO_CHAR(GMT_MODIFIED) AS VARCHAR2(19)) AS MODIFY_TIME, CAST(LS_ID AS NUMBER) AS LS_ID, SVR_IP, CAST(SVR_PORT AS NUMBER) AS SVR_PORT, CAST(SQL_PORT AS NUMBER) AS SQL_PORT, ZONE, (CASE ROLE WHEN 1 THEN 'LEADER' ELSE 'FOLLOWER' END) AS ROLE, (CASE ROLE WHEN 1 THEN MEMBER_LIST ELSE NULL END) AS MEMBER_LIST, CAST((CASE ROLE WHEN 1 THEN PAXOS_REPLICA_NUMBER ELSE NULL END) AS NUMBER) AS PAXOS_REPLICA_NUMBER, (CASE REPLICA_TYPE WHEN 0 THEN 'FULL' WHEN 5 THEN 'LOGONLY' WHEN 16 THEN 'READONLY' WHEN 261 THEN 'ENCRYPTION LOGONLY' ELSE NULL END) AS REPLICA_TYPE, (CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE NULL END) AS LEARNER_LIST, (CASE REBUILD WHEN 0 THEN 'FALSE' ELSE 'TRUE' END) AS REBUILD FROM SYS.ALL_VIRTUAL_LS_META_TABLE WHERE TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(TO_CHAR(GMT_CREATE) AS VARCHAR2(19)) AS CREATE_TIME, CAST(TO_CHAR(GMT_MODIFIED) AS VARCHAR2(19)) AS MODIFY_TIME, CAST(LS_ID AS NUMBER) AS LS_ID, SVR_IP, CAST(SVR_PORT AS NUMBER) AS SVR_PORT, CAST(SQL_PORT AS NUMBER) AS SQL_PORT, ZONE, (CASE ROLE WHEN 1 THEN 'LEADER' ELSE 'FOLLOWER' END) AS ROLE, (CASE ROLE WHEN 1 THEN MEMBER_LIST ELSE NULL END) AS MEMBER_LIST, CAST((CASE ROLE WHEN 1 THEN PAXOS_REPLICA_NUMBER ELSE NULL END) AS NUMBER) AS PAXOS_REPLICA_NUMBER, (CASE REPLICA_TYPE WHEN 0 THEN 'FULL' WHEN 5 THEN 'LOGONLY' WHEN 16 THEN 'READONLY' WHEN 261 THEN 'ENCRYPTION LOGONLY' WHEN 1040 THEN 'COLUMNSTORE' ELSE NULL END) AS REPLICA_TYPE, (CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE NULL END) AS LEARNER_LIST, (CASE REBUILD WHEN 0 THEN 'FALSE' ELSE 'TRUE' END) AS REBUILD FROM SYS.ALL_VIRTUAL_LS_META_TABLE WHERE TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
|
@ -19630,9 +19630,6 @@ SELECT RESOURCE_POOL_ID,
|
||||
ZONE_LIST,
|
||||
CASE replica_type
|
||||
WHEN 0 THEN "FULL"
|
||||
WHEN 5 THEN "LOGONLY"
|
||||
WHEN 16 THEN "READONLY"
|
||||
WHEN 261 THEN "ENCRYPTION LOGONLY"
|
||||
ELSE NULL
|
||||
END AS REPLICA_TYPE
|
||||
FROM oceanbase.__all_resource_pool
|
||||
@ -19889,6 +19886,7 @@ def_table_schema(
|
||||
WHEN 5 THEN "LOGONLY"
|
||||
WHEN 16 THEN "READONLY"
|
||||
WHEN 261 THEN "ENCRYPTION LOGONLY"
|
||||
WHEN 1040 THEN "COLUMNSTORE"
|
||||
ELSE NULL END) AS REPLICA_TYPE,
|
||||
(CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST,
|
||||
(CASE REBUILD
|
||||
@ -19915,6 +19913,7 @@ def_table_schema(
|
||||
WHEN 5 THEN "LOGONLY"
|
||||
WHEN 16 THEN "READONLY"
|
||||
WHEN 261 THEN "ENCRYPTION LOGONLY"
|
||||
WHEN 1040 THEN "COLUMNSTORE"
|
||||
ELSE NULL END) AS REPLICA_TYPE,
|
||||
(CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST,
|
||||
(CASE REBUILD
|
||||
@ -19954,6 +19953,7 @@ def_table_schema(
|
||||
WHEN 5 THEN "LOGONLY"
|
||||
WHEN 16 THEN "READONLY"
|
||||
WHEN 261 THEN "ENCRYPTION LOGONLY"
|
||||
WHEN 1040 THEN "COLUMNSTORE"
|
||||
ELSE NULL END) AS REPLICA_TYPE,
|
||||
(CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST,
|
||||
(CASE REBUILD
|
||||
@ -19979,6 +19979,7 @@ def_table_schema(
|
||||
WHEN 5 THEN "LOGONLY"
|
||||
WHEN 16 THEN "READONLY"
|
||||
WHEN 261 THEN "ENCRYPTION LOGONLY"
|
||||
WHEN 1040 THEN "COLUMNSTORE"
|
||||
ELSE NULL END) AS REPLICA_TYPE,
|
||||
(CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE "" END) AS LEARNER_LIST,
|
||||
(CASE REBUILD
|
||||
@ -28107,15 +28108,18 @@ def_table_schema(
|
||||
TABLET_ID
|
||||
FROM
|
||||
(
|
||||
SELECT TENANT_ID,
|
||||
TABLET_ID,
|
||||
ROW_COUNT,
|
||||
DATA_CHECKSUM,
|
||||
B_COLUMN_CHECKSUMS,
|
||||
COMPACTION_SCN
|
||||
FROM OCEANBASE.__ALL_VIRTUAL_TABLET_REPLICA_CHECKSUM
|
||||
SELECT CKM.TENANT_ID,
|
||||
CKM.TABLET_ID,
|
||||
CKM.ROW_COUNT,
|
||||
CKM.DATA_CHECKSUM,
|
||||
CKM.B_COLUMN_CHECKSUMS,
|
||||
CKM.COMPACTION_SCN,
|
||||
M.REPLICA_TYPE
|
||||
FROM OCEANBASE.__ALL_VIRTUAL_TABLET_REPLICA_CHECKSUM CKM
|
||||
JOIN OCEANBASE.__ALL_VIRTUAL_LS_META_TABLE M
|
||||
ON CKM.TENANT_ID = M.TENANT_ID AND CKM.LS_ID = M.LS_ID AND CKM.SVR_IP = M.SVR_IP AND CKM.SVR_PORT = M.SVR_PORT
|
||||
) J
|
||||
GROUP BY J.TENANT_ID, J.TABLET_ID, J.COMPACTION_SCN
|
||||
GROUP BY J.TENANT_ID, J.TABLET_ID, J.COMPACTION_SCN, J.REPLICA_TYPE
|
||||
HAVING MIN(J.DATA_CHECKSUM) != MAX(J.DATA_CHECKSUM)
|
||||
OR MIN(J.ROW_COUNT) != MAX(J.ROW_COUNT)
|
||||
OR MIN(J.B_COLUMN_CHECKSUMS) != MAX(J.B_COLUMN_CHECKSUMS)
|
||||
@ -50752,6 +50756,7 @@ def_table_schema(
|
||||
WHEN 5 THEN 'LOGONLY'
|
||||
WHEN 16 THEN 'READONLY'
|
||||
WHEN 261 THEN 'ENCRYPTION LOGONLY'
|
||||
WHEN 1040 THEN 'COLUMNSTORE'
|
||||
ELSE NULL END) AS REPLICA_TYPE,
|
||||
(CASE ROLE WHEN 1 THEN LEARNER_LIST ELSE NULL END) AS LEARNER_LIST,
|
||||
(CASE REBUILD
|
||||
|
@ -366,17 +366,17 @@ bool ObLSLocation::operator!=(const ObLSLocation &other) const
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
int ObLSLocation::get_replica_count(int64_t &full_replica_cnt, int64_t &readonly_replica_cnt)
|
||||
int ObLSLocation::get_replica_count(int64_t &full_replica_cnt, int64_t &non_paxos_replica_cnt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
full_replica_cnt = 0;
|
||||
readonly_replica_cnt = 0;
|
||||
non_paxos_replica_cnt = 0;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < replica_locations_.count(); ++i) {
|
||||
const ObLSReplicaLocation &replica = replica_locations_.at(i);
|
||||
if (REPLICA_TYPE_FULL == replica.get_replica_type()) {
|
||||
full_replica_cnt++;
|
||||
} else if (REPLICA_TYPE_READONLY == replica.get_replica_type()) {
|
||||
readonly_replica_cnt++;
|
||||
} else if (ObReplicaTypeCheck::is_non_paxos_replica(replica.get_replica_type())) {
|
||||
non_paxos_replica_cnt++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -190,7 +190,7 @@ public:
|
||||
inline uint64_t get_tenant_id() const { return cache_key_.get_tenant_id(); }
|
||||
inline ObLSID get_ls_id() const { return cache_key_.get_ls_id(); }
|
||||
const ObLSLocationCacheKey &get_cache_key() const { return cache_key_; }
|
||||
int get_replica_count(int64_t &full_replica_cnt, int64_t &readonly_replica_cnt);
|
||||
int get_replica_count(int64_t &full_replica_cnt, int64_t &non_paxos_replica_cnt);
|
||||
inline const common::ObIArray<ObLSReplicaLocation> &get_replica_locations() const
|
||||
{
|
||||
return replica_locations_;
|
||||
|
@ -51,7 +51,7 @@ int ObLSReplicaAddr::init(const common::ObAddr &addr,
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!addr.is_valid()
|
||||
|| common::REPLICA_TYPE_MAX == replica_type)) {
|
||||
|| common::REPLICA_TYPE_INVALID == replica_type)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(addr), K(replica_type));
|
||||
} else {
|
||||
@ -662,6 +662,12 @@ int ObLSCreator::check_create_ls_result_(
|
||||
if (OB_FAIL(learner_list.add_learner(ObMember(addr, timestamp)))) {
|
||||
LOG_WARN("failed to add member", KR(ret), K(addr));
|
||||
}
|
||||
} else if (result->get_replica_type() == REPLICA_TYPE_COLUMNSTORE) {
|
||||
ObMember member(addr, timestamp);
|
||||
member.set_columnstore();
|
||||
if (OB_FAIL(learner_list.add_learner(member))) {
|
||||
LOG_WARN("failed to add member", KR(ret), K(addr), K(member));
|
||||
}
|
||||
}
|
||||
LOG_TRACE("create ls result", KR(ret), K(i), K(addr), KPC(result));
|
||||
}
|
||||
@ -991,7 +997,9 @@ int ObLSCreator::construct_ls_addrs_according_to_locality_(
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < zone_locality_array.count(); ++i) {
|
||||
const share::ObZoneReplicaAttrSet &zone_locality = zone_locality_array.at(i);
|
||||
ObLSReplicaAddr replica_addr;
|
||||
if (OB_FAIL(alloc_zone_ls_addr(is_sys_ls, zone_locality, unit_info_array, replica_addr))) {
|
||||
if (is_sys_ls && zone_locality.get_columnstore_replica_num() > 0) {
|
||||
// ignore, C-replica not applicable for sys-ls
|
||||
} else if (OB_FAIL(alloc_zone_ls_addr(is_sys_ls, zone_locality, unit_info_array, replica_addr))) {
|
||||
LOG_WARN("fail to alloc zone ls addr", KR(ret), K(zone_locality), K(unit_info_array));
|
||||
} else if (OB_FAIL(ls_addr.push_back(replica_addr))) {
|
||||
LOG_WARN("fail to push back", KR(ret), K(replica_addr));
|
||||
@ -1106,11 +1114,9 @@ int ObLSCreator::alloc_duplicate_ls_addr_(
|
||||
} else if (OB_FAIL(construct_ls_addrs_according_to_locality_(
|
||||
zone_locality_array,
|
||||
unit_info_array,
|
||||
true/*is_sys_ls*/,
|
||||
false/*is_sys_ls*/,
|
||||
true/*is_duplicate_ls*/,
|
||||
ls_addr))) {
|
||||
// although duplicate log stream is a user log steam, we use the same logic to alloc addrs as sys log stream
|
||||
// so set is_sys_ls to true when execute construct_ls_addrs_according_to_locality_
|
||||
LOG_WARN("fail to construct ls addrs for tenant user ls", KR(ret), K(zone_locality_array),
|
||||
K(unit_info_array), K(ls_addr));
|
||||
}
|
||||
@ -1129,6 +1135,14 @@ int ObLSCreator::compensate_zone_readonly_replica_(
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(unit_info_array));
|
||||
} else {
|
||||
ObReplicaType replica_type_to_add = ObReplicaType::REPLICA_TYPE_INVALID;
|
||||
if (zlocality.get_columnstore_replica_num() > 0) {
|
||||
// For C zone locality, compensate C-replica.
|
||||
replica_type_to_add = ObReplicaType::REPLICA_TYPE_COLUMNSTORE;
|
||||
} else {
|
||||
// For other zone locality (F/R), compensate R-replica
|
||||
replica_type_to_add = ObReplicaType::REPLICA_TYPE_READONLY;
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < unit_info_array.count(); ++i) {
|
||||
const share::ObUnit &unit = unit_info_array.at(i);
|
||||
if (locality_zone != unit.zone_) {
|
||||
@ -1142,7 +1156,7 @@ int ObLSCreator::compensate_zone_readonly_replica_(
|
||||
ObLSReplicaAddr ls_replica_addr;
|
||||
if (OB_FAIL(ls_replica_addr.init(
|
||||
unit.server_,
|
||||
ObReplicaType::REPLICA_TYPE_READONLY))) {
|
||||
replica_type_to_add))) {
|
||||
LOG_WARN("fail to init ls replica addr", KR(ret), K(unit), K(locality_zone));
|
||||
} else if (OB_FAIL(ls_addr.push_back(ls_replica_addr))) {
|
||||
LOG_WARN("fail to push back", KR(ret), K(ls_replica_addr));
|
||||
@ -1174,25 +1188,31 @@ int ObLSCreator::alloc_zone_ls_addr(
|
||||
if (OB_FAIL(ls_replica_addr.init(
|
||||
unit.server_,
|
||||
ObReplicaType::REPLICA_TYPE_FULL))) {
|
||||
LOG_WARN("fail to init ls replica addr", KR(ret));
|
||||
LOG_WARN("fail to init ls replica addr", KR(ret), K(unit.server_));
|
||||
}
|
||||
} else if (zlocality.replica_attr_set_.get_logonly_replica_attr_array().count() > 0) {
|
||||
if (OB_FAIL(ls_replica_addr.init(
|
||||
unit.server_,
|
||||
ObReplicaType::REPLICA_TYPE_LOGONLY))) {
|
||||
LOG_WARN("fail to init ls replica addr", KR(ret));
|
||||
LOG_WARN("fail to init ls replica addr", KR(ret), K(unit.server_));
|
||||
}
|
||||
} else if (zlocality.replica_attr_set_.get_encryption_logonly_replica_attr_array().count() > 0) {
|
||||
if (OB_FAIL(ls_replica_addr.init(
|
||||
unit.server_,
|
||||
ObReplicaType::REPLICA_TYPE_ENCRYPTION_LOGONLY))) {
|
||||
LOG_WARN("fail to init ls replica addr", KR(ret));
|
||||
LOG_WARN("fail to init ls replica addr", KR(ret), K(unit.server_));
|
||||
}
|
||||
} else if (zlocality.replica_attr_set_.get_readonly_replica_attr_array().count() > 0) {
|
||||
if (OB_FAIL(ls_replica_addr.init(
|
||||
unit.server_,
|
||||
ObReplicaType::REPLICA_TYPE_READONLY))) {
|
||||
LOG_WARN("fail to init ls replica addr", KR(ret));
|
||||
LOG_WARN("fail to init ls replica addr", KR(ret), K(unit.server_));
|
||||
}
|
||||
} else if (zlocality.replica_attr_set_.get_columnstore_replica_attr_array().count() > 0) {
|
||||
if (OB_FAIL(ls_replica_addr.init(
|
||||
unit.server_,
|
||||
ObReplicaType::REPLICA_TYPE_COLUMNSTORE))) {
|
||||
LOG_WARN("fail to init ls replica addr", KR(ret), K(unit.server_));
|
||||
}
|
||||
} else { // zone locality shall has a paxos replica in 4.0 by
|
||||
// now(2021.10.25)
|
||||
|
@ -52,7 +52,7 @@ struct ObLSReplicaAddr
|
||||
|
||||
ObLSReplicaAddr()
|
||||
: addr_(),
|
||||
replica_type_(common::REPLICA_TYPE_MAX) {}
|
||||
replica_type_(common::REPLICA_TYPE_INVALID) {}
|
||||
void reset() { *this = ObLSReplicaAddr(); }
|
||||
int init(const common::ObAddr &addr,
|
||||
const common::ObReplicaType replica_type);
|
||||
|
@ -993,13 +993,18 @@ int ObLSInfo::update_replica_status()
|
||||
bool in_leader_learner_list = false;
|
||||
ObMember learner;
|
||||
// rectify replica_type_
|
||||
const ObReplicaType replica_type_before_rectify = r->get_replica_type();
|
||||
if (OB_NOT_NULL(learner_list) && learner_list->contains(r->get_server())) {
|
||||
r->set_replica_type(REPLICA_TYPE_READONLY);
|
||||
in_leader_learner_list = true;
|
||||
if (OB_FAIL(learner_list->get_learner_by_addr(r->get_server(), learner))) {
|
||||
LOG_WARN("fail to get learner by addr", KR(ret));
|
||||
} else if (in_leader_learner_list) {
|
||||
} else {
|
||||
in_member_time_us = learner.get_timestamp();
|
||||
if (learner.is_columnstore()) {
|
||||
r->set_replica_type(REPLICA_TYPE_COLUMNSTORE);
|
||||
} else {
|
||||
r->set_replica_type(REPLICA_TYPE_READONLY);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
r->set_replica_type(REPLICA_TYPE_FULL);
|
||||
@ -1021,8 +1026,17 @@ int ObLSInfo::update_replica_status()
|
||||
// 2 non_paxos replicas (READONLY),NORMAL when in leader's learner_list otherwise offline
|
||||
// 3 if non_paxos replicas are deleted by partition service, status in meta table is set to REPLICA_STATUS_OFFLINE,
|
||||
// then set replica_status to REPLICA_STATUS_OFFLINE
|
||||
// 4 COLUMNSTORE replica, if not in learner list or columnstore-flag is false,
|
||||
// then set replica_status to REPLICA_STATUS_OFFLINE
|
||||
if (REPLICA_STATUS_OFFLINE == r->get_replica_status()) {
|
||||
// do nothing
|
||||
} else if (REPLICA_TYPE_COLUMNSTORE == replica_type_before_rectify
|
||||
&& REPLICA_TYPE_COLUMNSTORE != r->get_replica_type()) {
|
||||
// we set replica_type according to leader's member/learner_list, but need to log a warning.
|
||||
LOG_WARN("replica_type before rectify is COLUMNSTORE, "
|
||||
"but not match with leader's member_list and learner_list",
|
||||
K(replica_type_before_rectify), K(member_list), K(learner_list), KPC(r));
|
||||
r->set_replica_status(REPLICA_STATUS_OFFLINE);
|
||||
} else if (in_leader_member_list || in_leader_learner_list) {
|
||||
r->set_replica_status(REPLICA_STATUS_NORMAL);
|
||||
} else {
|
||||
|
@ -135,6 +135,7 @@ public:
|
||||
inline bool is_paxos_replica() const { return common::REPLICA_TYPE_ENCRYPTION_LOGONLY == replica_type_
|
||||
|| common::REPLICA_TYPE_FULL == replica_type_
|
||||
|| common::REPLICA_TYPE_LOGONLY == replica_type_; }
|
||||
inline bool is_column_replica() const { return common::REPLICA_TYPE_COLUMNSTORE == replica_type_; }
|
||||
int64_t to_string(char *buf, const int64_t buf_len) const;
|
||||
// operator-related functions
|
||||
int assign(const ObLSReplica &other);
|
||||
|
@ -633,6 +633,8 @@ class ObString;
|
||||
ACT(BEFROE_UPDATE_DATA_VERSION,)\
|
||||
ACT(BEFORE_DATA_DICT_DUMP_FINISH,)\
|
||||
ACT(AFTER_PHYSICAL_RESTORE_CREATE_TENANT,)\
|
||||
ACT(BEFROE_UPDATE_MIG_TABLET_CONVERT_CO_PROGRESSING,)\
|
||||
ACT(AFTER_SET_CO_CONVERT_RETRY_EXHUASTED,)\
|
||||
ACT(MAX_DEBUG_SYNC_POINT,)
|
||||
|
||||
DECLARE_ENUM(ObDebugSyncPoint, debug_sync_point, OB_DEBUG_SYNC_POINT_DEF);
|
||||
|
@ -1,95 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#define USING_LOG_PREFIX SHARE
|
||||
#include "ob_locality_parser.h"
|
||||
#include "lib/alloc/alloc_assist.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::share;
|
||||
|
||||
// full replica
|
||||
const char *ObLocalityParser::FULL_REPLICA_STR = "FULL";
|
||||
const char *ObLocalityParser::F_REPLICA_STR = "F";
|
||||
// logonly replica
|
||||
const char *ObLocalityParser::LOGONLY_REPLICA_STR = "LOGONLY";
|
||||
const char *ObLocalityParser::L_REPLICA_STR = "L";
|
||||
// backup replica
|
||||
const char *ObLocalityParser::BACKUP_REPLICA_STR = "BACKUP";
|
||||
const char *ObLocalityParser::B_REPLICA_STR = "B";
|
||||
// readonly replica
|
||||
const char *ObLocalityParser::READONLY_REPLICA_STR = "READONLY";
|
||||
const char *ObLocalityParser::R_REPLICA_STR = "R";
|
||||
// memonly replica
|
||||
const char *ObLocalityParser::MEMONLY_REPLICA_STR = "MEMONLY";
|
||||
const char *ObLocalityParser::M_REPLICA_STR = "M";
|
||||
// encryption logonly replica
|
||||
const char *ObLocalityParser::ENCRYPTION_LOGONLY_REPLICA_STR = "ENCRYPTION_LOGONLY";
|
||||
const char *ObLocalityParser::E_REPLICA_STR = "E";
|
||||
|
||||
int ObLocalityParser::parse_type(const char *str, int64_t len, ObReplicaType &replica_type)
|
||||
{
|
||||
UNUSED(len);
|
||||
// TODO: only support F-replica in 4.0 and R-replica in 4.2 for now, will support others in the future
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(str)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid replica type string. null!", K(ret));
|
||||
LOG_USER_ERROR(OB_INVALID_ARGUMENT, "replica_type, replica_type should not be null");
|
||||
} else if (0 == STRCASECMP(FULL_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_FULL;
|
||||
} else if (0 == STRCASECMP(F_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_FULL;
|
||||
} else if (0 == STRCASECMP(LOGONLY_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_LOGONLY;
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "logonly-replica");
|
||||
} else if ( 0 == STRCASECMP(L_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_LOGONLY;
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "logonly-replica");
|
||||
} else if (0 == STRCASECMP(ENCRYPTION_LOGONLY_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_ENCRYPTION_LOGONLY;
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "encryption-logonly-replica");
|
||||
} else if ( 0 == STRCASECMP(E_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_ENCRYPTION_LOGONLY;
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "encryption-logonly-replica");
|
||||
} else if ( 0 == STRCASECMP(BACKUP_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_BACKUP;
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "backup-replica");
|
||||
} else if ( 0 == STRCASECMP(B_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_BACKUP;
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "backup-replica");
|
||||
} else if ( 0 == STRCASECMP(READONLY_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_READONLY;
|
||||
} else if ( 0 == STRCASECMP(R_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_READONLY;
|
||||
} else if ( 0 == STRCASECMP(MEMONLY_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_MEMONLY;
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "memonly-replica");
|
||||
} else if ( 0 == STRCASECMP(M_REPLICA_STR, str)) {
|
||||
replica_type = REPLICA_TYPE_MEMONLY;
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "memonly-replica");
|
||||
} else {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid replica type string", K(str), K(ret));
|
||||
LOG_USER_ERROR(OB_INVALID_ARGUMENT, "replica_type, unrecognized replica_type");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SHARE_OB_LOCALITY_PARSER_H_
|
||||
#define OCEANBASE_SHARE_OB_LOCALITY_PARSER_H_
|
||||
|
||||
#include "share/ob_define.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace share
|
||||
{
|
||||
class ObLocalityParser
|
||||
{
|
||||
public:
|
||||
static int parse_type(const char *str, int64_t len, common::ObReplicaType &type);
|
||||
private:
|
||||
// full replica
|
||||
static const char *FULL_REPLICA_STR;
|
||||
static const char *F_REPLICA_STR;
|
||||
// logonly replica
|
||||
static const char *LOGONLY_REPLICA_STR;
|
||||
static const char *L_REPLICA_STR;
|
||||
// backup replica
|
||||
static const char *BACKUP_REPLICA_STR;
|
||||
static const char *B_REPLICA_STR;
|
||||
// readonly replica
|
||||
static const char *READONLY_REPLICA_STR;
|
||||
static const char *R_REPLICA_STR;
|
||||
// memonly replica
|
||||
static const char *MEMONLY_REPLICA_STR;
|
||||
static const char *M_REPLICA_STR;
|
||||
// encryption logonly replica
|
||||
static const char *ENCRYPTION_LOGONLY_REPLICA_STR;
|
||||
static const char *E_REPLICA_STR;
|
||||
};
|
||||
|
||||
} // end namespace share
|
||||
} // end namespace oceanbase
|
||||
#endif
|
@ -59,6 +59,15 @@ int64_t BaseReplicaAttrSet::get_encryption_logonly_replica_num() const
|
||||
return num;
|
||||
}
|
||||
|
||||
int64_t BaseReplicaAttrSet::get_columnstore_replica_num() const
|
||||
{
|
||||
int64_t num = 0;
|
||||
for (int64_t i = 0; i < get_columnstore_replica_attr_array().count(); ++i) {
|
||||
num += get_columnstore_replica_attr_array().at(i).num_;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
int64_t BaseReplicaAttrSet::get_paxos_replica_num() const
|
||||
{
|
||||
return get_full_replica_num()
|
||||
@ -81,6 +90,9 @@ int64_t BaseReplicaAttrSet::get_specific_replica_num() const
|
||||
if (ObLocalityDistribution::ALL_SERVER_CNT != get_encryption_logonly_replica_num()) {
|
||||
specific_replica_num += get_encryption_logonly_replica_num();
|
||||
}
|
||||
if (ObLocalityDistribution::ALL_SERVER_CNT != get_columnstore_replica_num()) {
|
||||
specific_replica_num += get_columnstore_replica_num();
|
||||
}
|
||||
return specific_replica_num;
|
||||
}
|
||||
|
||||
@ -117,7 +129,8 @@ bool ObReplicaAttrSet::operator==(const ObReplicaAttrSet &that) const
|
||||
if (full_replica_attr_array_.count() != that.full_replica_attr_array_.count()
|
||||
|| logonly_replica_attr_array_.count() != that.logonly_replica_attr_array_.count()
|
||||
|| readonly_replica_attr_array_.count() != that.readonly_replica_attr_array_.count()
|
||||
|| encryption_logonly_replica_attr_array_.count() != that.encryption_logonly_replica_attr_array_.count()) {
|
||||
|| encryption_logonly_replica_attr_array_.count() != that.encryption_logonly_replica_attr_array_.count()
|
||||
|| columnstore_replica_attr_array_.count() != that.columnstore_replica_attr_array_.count()) {
|
||||
equal = false;
|
||||
} else {
|
||||
for (int64_t i = 0; equal && i < full_replica_attr_array_.count(); ++i) {
|
||||
@ -140,6 +153,11 @@ bool ObReplicaAttrSet::operator==(const ObReplicaAttrSet &that) const
|
||||
equal = false;
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; equal && i < columnstore_replica_attr_array_.count(); ++i) {
|
||||
if (columnstore_replica_attr_array_.at(i) != that.columnstore_replica_attr_array_.at(i)) {
|
||||
equal = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
@ -162,6 +180,9 @@ int ObReplicaAttrSet::assign(const BaseReplicaAttrSet &that)
|
||||
} else if (OB_FAIL(encryption_logonly_replica_attr_array_.assign(
|
||||
that.get_encryption_logonly_replica_attr_array()))) {
|
||||
LOG_WARN("fail to assign encryption logonly replica attr array", KR(ret));
|
||||
} else if (OB_FAIL(columnstore_replica_attr_array_.assign(
|
||||
that.get_columnstore_replica_attr_array()))) {
|
||||
LOG_WARN("fail to assign columnstore replica attr array", KR(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -170,7 +191,8 @@ int ObReplicaAttrSet::set_replica_attr_array(
|
||||
const common::ObIArray<share::ReplicaAttr> &full_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &logonly_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &readonly_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &encryption_logonly_replica_attr_array)
|
||||
const common::ObIArray<share::ReplicaAttr> &encryption_logonly_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &columnstore_replica_attr_array)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(full_replica_attr_array_.assign(full_replica_attr_array))) {
|
||||
@ -181,6 +203,8 @@ int ObReplicaAttrSet::set_replica_attr_array(
|
||||
LOG_WARN("fail to assign readonly replica attr array", KR(ret));
|
||||
} else if (OB_FAIL(encryption_logonly_replica_attr_array_.assign(encryption_logonly_replica_attr_array))) {
|
||||
LOG_WARN("fail to assign encryption logonly replica attr array", KR(ret));
|
||||
} else if (OB_FAIL(columnstore_replica_attr_array_.assign(columnstore_replica_attr_array))) {
|
||||
LOG_WARN("fail to assign columnstore replica attr array", KR(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -201,12 +225,15 @@ int ObReplicaAttrSet::set_paxos_replica_attr_array(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObReplicaAttrSet::set_readonly_replica_attr_array(
|
||||
const common::ObIArray<share::ReplicaAttr> &readonly_replica_attr_array)
|
||||
int ObReplicaAttrSet::set_non_paxos_replica_attr_array(
|
||||
const common::ObIArray<share::ReplicaAttr> &readonly_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &columnstore_replica_attr_array)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(readonly_replica_attr_array_.assign(readonly_replica_attr_array))) {
|
||||
LOG_WARN("fail to assign full replica attr array", K(ret));
|
||||
} else if (OB_FAIL(columnstore_replica_attr_array_.assign(columnstore_replica_attr_array))) {
|
||||
LOG_WARN("fail to assign columnstore replica attr array", KR(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -263,6 +290,10 @@ bool ObReplicaAttrSet::is_specific_replica_attr() const
|
||||
const ReplicaAttr &replica_attr = encryption_logonly_replica_attr_array_.at(i);
|
||||
bool_ret = 100 != replica_attr.memstore_percent_;
|
||||
}
|
||||
for (int64_t i = 0; !bool_ret && i < columnstore_replica_attr_array_.count(); i++) {
|
||||
const ReplicaAttr &replica_attr = columnstore_replica_attr_array_.at(i);
|
||||
bool_ret = 100 != replica_attr.memstore_percent_;
|
||||
}
|
||||
return bool_ret;
|
||||
}
|
||||
|
||||
@ -373,6 +404,30 @@ int ObReplicaAttrSet::add_encryption_logonly_replica_num(const ReplicaAttr &repl
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObReplicaAttrSet::add_columnstore_replica_num(const ReplicaAttr &replica_attr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (replica_attr.num_ > 0) {
|
||||
if (columnstore_replica_attr_array_.count() <= 0) {
|
||||
if (OB_FAIL(columnstore_replica_attr_array_.push_back(
|
||||
ReplicaAttr(0, replica_attr.memstore_percent_)))) {
|
||||
LOG_WARN("fail to push back", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
// bypass
|
||||
} else if (columnstore_replica_attr_array_.count() <= 0) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("index unexpected", K(ret),
|
||||
"columnstore_replica_attr_array_count",
|
||||
columnstore_replica_attr_array_.count());
|
||||
} else {
|
||||
columnstore_replica_attr_array_.at(0).num_ += replica_attr.num_;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObReplicaAttrSet::sub_full_replica_num(const ReplicaAttr &replica_attr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -485,56 +540,27 @@ int ObReplicaAttrSet::sub_encryption_logonly_replica_num(const ReplicaAttr &repl
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ObReplicaAttrSet::has_this_replica(
|
||||
const common::ObReplicaType replica_type,
|
||||
const int64_t memstore_percent)
|
||||
{
|
||||
bool found = false;
|
||||
if (common::REPLICA_TYPE_FULL == replica_type) {
|
||||
for (int64_t i = 0; !found && i < full_replica_attr_array_.count(); ++i) {
|
||||
ReplicaAttr &this_replica_attr = full_replica_attr_array_.at(i);
|
||||
if (this_replica_attr.num_ > 0 && memstore_percent == this_replica_attr.memstore_percent_) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
} else if (common::REPLICA_TYPE_LOGONLY == replica_type) {
|
||||
for (int64_t i = 0; !found && i < logonly_replica_attr_array_.count(); ++i) {
|
||||
ReplicaAttr &this_replica_attr = logonly_replica_attr_array_.at(i);
|
||||
if (this_replica_attr.num_ > 0 && memstore_percent == this_replica_attr.memstore_percent_) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
} else if (common::REPLICA_TYPE_READONLY == replica_type) {
|
||||
for (int64_t i = 0; !found && i < readonly_replica_attr_array_.count(); ++i) {
|
||||
ReplicaAttr &this_replica_attr = readonly_replica_attr_array_.at(i);
|
||||
if (this_replica_attr.num_ > 0 && memstore_percent == this_replica_attr.memstore_percent_) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
} else if (common::REPLICA_TYPE_ENCRYPTION_LOGONLY == replica_type) {
|
||||
for (int64_t i = 0; !found && i < encryption_logonly_replica_attr_array_.count(); ++i) {
|
||||
ReplicaAttr &this_replica_attr = encryption_logonly_replica_attr_array_.at(i);
|
||||
if (this_replica_attr.num_ > 0 && memstore_percent == this_replica_attr.memstore_percent_) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
found = false;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
int ObReplicaAttrSet::get_readonly_memstore_percent(int64_t &memstore_percent) const
|
||||
int ObReplicaAttrSet::sub_columnstore_replica_num(const ReplicaAttr &replica_attr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (readonly_replica_attr_array_.count() <= 0 || readonly_replica_attr_array_.count() > 1) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("readonly replica attr array count unexpected", K(ret),
|
||||
"array_count", readonly_replica_attr_array_.count());
|
||||
} else {
|
||||
const ReplicaAttr &replica_attr = readonly_replica_attr_array_.at(0);
|
||||
memstore_percent = replica_attr.memstore_percent_;
|
||||
if (replica_attr.num_ > 0) {
|
||||
if (columnstore_replica_attr_array_.count() <= 0) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("columnstore replica attr array empty", K(ret));
|
||||
} else if (columnstore_replica_attr_array_.at(0).num_ < replica_attr.num_) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("columnstore replica num not enough", K(ret),
|
||||
"columnstore_replica_num_in_array",
|
||||
columnstore_replica_attr_array_.at(0).num_,
|
||||
K(replica_attr));
|
||||
} else {
|
||||
columnstore_replica_attr_array_.at(0).num_ -= replica_attr.num_;
|
||||
if (columnstore_replica_attr_array_.at(0).num_ <= 0) {
|
||||
if (OB_FAIL(columnstore_replica_attr_array_.remove(0))) {
|
||||
LOG_WARN("fail to remove", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -552,7 +578,7 @@ int ObZoneReplicaAttrSet::append(const ObZoneReplicaAttrSet &that)
|
||||
OB_SUCC(ret) && i < that.replica_attr_set_.get_full_replica_attr_array().count();
|
||||
++i) {
|
||||
const ReplicaAttr &this_replica_attr = that.replica_attr_set_.get_full_replica_attr_array().at(i);
|
||||
if (OB_FAIL(add_full_replica_num(this_replica_attr))) {
|
||||
if (OB_FAIL(replica_attr_set_.add_full_replica_num(this_replica_attr))) {
|
||||
LOG_WARN("fail to add full replica num", K(ret));
|
||||
}
|
||||
}
|
||||
@ -562,7 +588,7 @@ int ObZoneReplicaAttrSet::append(const ObZoneReplicaAttrSet &that)
|
||||
OB_SUCC(ret) && i < that.replica_attr_set_.get_logonly_replica_attr_array().count();
|
||||
++i) {
|
||||
const ReplicaAttr &this_replica_attr = that.replica_attr_set_.get_logonly_replica_attr_array().at(i);
|
||||
if (OB_FAIL(add_logonly_replica_num(this_replica_attr))) {
|
||||
if (OB_FAIL(replica_attr_set_.add_logonly_replica_num(this_replica_attr))) {
|
||||
LOG_WARN("fail to add logonly replica num", K(ret));
|
||||
}
|
||||
}
|
||||
@ -572,7 +598,7 @@ int ObZoneReplicaAttrSet::append(const ObZoneReplicaAttrSet &that)
|
||||
OB_SUCC(ret) && i < that.replica_attr_set_.get_readonly_replica_attr_array().count();
|
||||
++i) {
|
||||
const ReplicaAttr &this_replica_attr = that.replica_attr_set_.get_readonly_replica_attr_array().at(i);
|
||||
if (OB_FAIL(add_readonly_replica_num(this_replica_attr))) {
|
||||
if (OB_FAIL(replica_attr_set_.add_readonly_replica_num(this_replica_attr))) {
|
||||
LOG_WARN("fail to add readonly replica num", K(ret));
|
||||
}
|
||||
}
|
||||
@ -583,12 +609,22 @@ int ObZoneReplicaAttrSet::append(const ObZoneReplicaAttrSet &that)
|
||||
++i) {
|
||||
const ReplicaAttr &this_replica_attr
|
||||
= that.replica_attr_set_.get_encryption_logonly_replica_attr_array().at(i);
|
||||
if (OB_FAIL(add_encryption_logonly_replica_num(this_replica_attr))) {
|
||||
if (OB_FAIL(replica_attr_set_.add_encryption_logonly_replica_num(this_replica_attr))) {
|
||||
LOG_WARN("fail to add logonly replica num", K(ret));
|
||||
}
|
||||
}
|
||||
lib::ob_sort(replica_attr_set_.get_encryption_logonly_replica_attr_array_for_sort().begin(),
|
||||
replica_attr_set_.get_encryption_logonly_replica_attr_array_for_sort().end());
|
||||
for (int64_t i = 0;
|
||||
OB_SUCC(ret) && i < that.replica_attr_set_.get_columnstore_replica_attr_array().count();
|
||||
++i) {
|
||||
const ReplicaAttr &this_replica_attr = that.replica_attr_set_.get_columnstore_replica_attr_array().at(i);
|
||||
if (OB_FAIL(replica_attr_set_.add_columnstore_replica_num(this_replica_attr))) {
|
||||
LOG_WARN("fail to add columnstore replica num", K(ret));
|
||||
}
|
||||
}
|
||||
lib::ob_sort(replica_attr_set_.get_columnstore_replica_attr_array_for_sort().begin(),
|
||||
replica_attr_set_.get_columnstore_replica_attr_array_for_sort().end());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -755,36 +791,6 @@ bool ObZoneReplicaAttrSet::check_paxos_num_valid() const
|
||||
}
|
||||
|
||||
|
||||
void ObReplicaNumSet::set_replica_num(
|
||||
int64_t full_replica_num,
|
||||
int64_t logonly_replica_num,
|
||||
int64_t readonly_replica_num,
|
||||
int64_t encryption_logonly_replica_num)
|
||||
{
|
||||
full_replica_num_ = full_replica_num;
|
||||
logonly_replica_num_ = logonly_replica_num;
|
||||
readonly_replica_num_ = readonly_replica_num;
|
||||
encryption_logonly_replica_num_ = encryption_logonly_replica_num;
|
||||
}
|
||||
|
||||
int64_t ObReplicaNumSet::get_specific_replica_num() const
|
||||
{
|
||||
int64_t specific_replica_num = 0;
|
||||
if (ObLocalityDistribution::ALL_SERVER_CNT != full_replica_num_) {
|
||||
specific_replica_num += full_replica_num_;
|
||||
}
|
||||
if (ObLocalityDistribution::ALL_SERVER_CNT != logonly_replica_num_) {
|
||||
specific_replica_num += logonly_replica_num_;
|
||||
}
|
||||
if (ObLocalityDistribution::ALL_SERVER_CNT != readonly_replica_num_) {
|
||||
specific_replica_num += readonly_replica_num_;
|
||||
}
|
||||
if (ObLocalityDistribution::ALL_SERVER_CNT != encryption_logonly_replica_num_) {
|
||||
specific_replica_num += encryption_logonly_replica_num_;
|
||||
}
|
||||
return specific_replica_num;
|
||||
}
|
||||
|
||||
int64_t SchemaReplicaAttrSet::get_convert_size() const
|
||||
{
|
||||
int64_t convert_size = sizeof(SchemaReplicaAttrSet);
|
||||
@ -796,6 +802,8 @@ int64_t SchemaReplicaAttrSet::get_convert_size() const
|
||||
convert_size += readonly_set.count() * static_cast<int64_t>(sizeof(share::ReplicaAttr));
|
||||
const ObIArray<ReplicaAttr> &encryption_logonly_set = get_encryption_logonly_replica_attr_array();
|
||||
convert_size += encryption_logonly_set.count() * static_cast<int64_t>(sizeof(share::ReplicaAttr));
|
||||
const ObIArray<ReplicaAttr> &columnstore_set = get_columnstore_replica_attr_array();
|
||||
convert_size += columnstore_set.count() * static_cast<int64_t>(sizeof(share::ReplicaAttr));
|
||||
return convert_size;
|
||||
}
|
||||
|
||||
|
@ -72,22 +72,26 @@ public:
|
||||
virtual const common::ObIArray<ReplicaAttr> &get_logonly_replica_attr_array() const = 0;
|
||||
virtual const common::ObIArray<ReplicaAttr> &get_readonly_replica_attr_array() const = 0;
|
||||
virtual const common::ObIArray<ReplicaAttr> &get_encryption_logonly_replica_attr_array() const = 0;
|
||||
virtual const common::ObIArray<ReplicaAttr> &get_columnstore_replica_attr_array() const = 0;
|
||||
virtual common::ObIArray<ReplicaAttr> &get_full_replica_attr_array() = 0;
|
||||
virtual common::ObIArray<ReplicaAttr> &get_logonly_replica_attr_array() = 0;
|
||||
virtual common::ObIArray<ReplicaAttr> &get_readonly_replica_attr_array() = 0;
|
||||
virtual common::ObIArray<ReplicaAttr> &get_encryption_logonly_replica_attr_array() = 0;
|
||||
virtual common::ObIArray<ReplicaAttr> &get_columnstore_replica_attr_array() = 0;
|
||||
|
||||
int64_t get_full_replica_num() const;
|
||||
int64_t get_logonly_replica_num() const;
|
||||
int64_t get_readonly_replica_num() const;
|
||||
int64_t get_encryption_logonly_replica_num() const;
|
||||
int64_t get_columnstore_replica_num() const;
|
||||
int64_t get_paxos_replica_num() const;
|
||||
int64_t get_specific_replica_num() const;
|
||||
|
||||
TO_STRING_KV("full_replica_attr_array", get_full_replica_attr_array(),
|
||||
"logonly_replica_attr_array", get_logonly_replica_attr_array(),
|
||||
"readonly_replica_attr_array", get_readonly_replica_attr_array(),
|
||||
"encryption_logonly_replica_attr_array", get_encryption_logonly_replica_attr_array());
|
||||
"encryption_logonly_replica_attr_array", get_encryption_logonly_replica_attr_array(),
|
||||
"columnstore_replica_attr_array", get_columnstore_replica_attr_array());
|
||||
};
|
||||
|
||||
typedef common::ObArrayHelper<share::ReplicaAttr> SchemaReplicaAttrArray;
|
||||
@ -100,7 +104,8 @@ public:
|
||||
full_replica_attr_array_(),
|
||||
logonly_replica_attr_array_(),
|
||||
readonly_replica_attr_array_(),
|
||||
encryption_logonly_replica_attr_array_() {}
|
||||
encryption_logonly_replica_attr_array_(),
|
||||
columnstore_replica_attr_array_() {}
|
||||
virtual ~SchemaReplicaAttrSet() {}
|
||||
int64_t get_convert_size() const;
|
||||
public:
|
||||
@ -116,6 +121,9 @@ public:
|
||||
virtual const common::ObIArray<ReplicaAttr> &get_encryption_logonly_replica_attr_array() const override {
|
||||
return encryption_logonly_replica_attr_array_;
|
||||
}
|
||||
virtual const common::ObIArray<ReplicaAttr> &get_columnstore_replica_attr_array() const override {
|
||||
return columnstore_replica_attr_array_;
|
||||
}
|
||||
virtual common::ObIArray<ReplicaAttr> &get_full_replica_attr_array() override {
|
||||
return full_replica_attr_array_;
|
||||
}
|
||||
@ -128,18 +136,23 @@ public:
|
||||
virtual common::ObIArray<ReplicaAttr> &get_encryption_logonly_replica_attr_array() override {
|
||||
return encryption_logonly_replica_attr_array_;
|
||||
}
|
||||
virtual common::ObIArray<ReplicaAttr> &get_columnstore_replica_attr_array() override {
|
||||
return columnstore_replica_attr_array_;
|
||||
}
|
||||
public:
|
||||
void reset() {
|
||||
full_replica_attr_array_.reset();
|
||||
logonly_replica_attr_array_.reset();
|
||||
readonly_replica_attr_array_.reset();
|
||||
encryption_logonly_replica_attr_array_.reset();
|
||||
columnstore_replica_attr_array_.reset();
|
||||
}
|
||||
private:
|
||||
SchemaReplicaAttrArray full_replica_attr_array_;
|
||||
SchemaReplicaAttrArray logonly_replica_attr_array_;
|
||||
SchemaReplicaAttrArray readonly_replica_attr_array_;
|
||||
SchemaReplicaAttrArray encryption_logonly_replica_attr_array_;
|
||||
SchemaReplicaAttrArray columnstore_replica_attr_array_;
|
||||
};
|
||||
|
||||
class ObReplicaAttrSet : public BaseReplicaAttrSet
|
||||
@ -160,21 +173,20 @@ public:
|
||||
logonly_replica_attr_array_.reset();
|
||||
readonly_replica_attr_array_.reset();
|
||||
encryption_logonly_replica_attr_array_.reset();
|
||||
columnstore_replica_attr_array_.reset();
|
||||
}
|
||||
|
||||
int add_full_replica_num(const ReplicaAttr &replica_attr);
|
||||
int add_logonly_replica_num(const ReplicaAttr &replica_attr);
|
||||
int add_readonly_replica_num(const ReplicaAttr &replica_attr);
|
||||
int add_encryption_logonly_replica_num(const ReplicaAttr &replica_attr);
|
||||
int add_columnstore_replica_num(const ReplicaAttr &replica_attr);
|
||||
|
||||
int sub_full_replica_num(const ReplicaAttr &replica_attr);
|
||||
int sub_logonly_replica_num(const ReplicaAttr &replica_attr);
|
||||
int sub_readonly_replica_num(const ReplicaAttr &replica_attr);
|
||||
int sub_encryption_logonly_replica_num(const ReplicaAttr &replica_attr);
|
||||
|
||||
bool has_this_replica(
|
||||
const common::ObReplicaType replica_type,
|
||||
const int64_t memstore_percent);
|
||||
int sub_columnstore_replica_num(const ReplicaAttr &replica_attr);
|
||||
|
||||
virtual const common::ObIArray<ReplicaAttr> &get_full_replica_attr_array() const override {
|
||||
return full_replica_attr_array_;
|
||||
@ -188,6 +200,9 @@ public:
|
||||
virtual const common::ObIArray<ReplicaAttr> &get_encryption_logonly_replica_attr_array() const override {
|
||||
return encryption_logonly_replica_attr_array_;
|
||||
}
|
||||
virtual const common::ObIArray<ReplicaAttr> &get_columnstore_replica_attr_array() const override {
|
||||
return columnstore_replica_attr_array_;
|
||||
}
|
||||
virtual common::ObIArray<ReplicaAttr> &get_full_replica_attr_array() override {
|
||||
return full_replica_attr_array_;
|
||||
}
|
||||
@ -200,6 +215,9 @@ public:
|
||||
virtual common::ObIArray<ReplicaAttr> &get_encryption_logonly_replica_attr_array() override {
|
||||
return encryption_logonly_replica_attr_array_;
|
||||
}
|
||||
virtual common::ObIArray<ReplicaAttr> &get_columnstore_replica_attr_array() override {
|
||||
return columnstore_replica_attr_array_;
|
||||
}
|
||||
|
||||
ReplicaAttrArray &get_full_replica_attr_array_for_sort() {
|
||||
return full_replica_attr_array_;
|
||||
@ -213,22 +231,25 @@ public:
|
||||
ReplicaAttrArray &get_encryption_logonly_replica_attr_array_for_sort() {
|
||||
return encryption_logonly_replica_attr_array_;
|
||||
}
|
||||
ReplicaAttrArray &get_columnstore_replica_attr_array_for_sort() {
|
||||
return columnstore_replica_attr_array_;
|
||||
}
|
||||
|
||||
int set_replica_attr_array(
|
||||
const common::ObIArray<share::ReplicaAttr> &full_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &logonly_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &readonly_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &encryption_logonly_replica_attr_array);
|
||||
const common::ObIArray<share::ReplicaAttr> &encryption_logonly_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &columnstore_replica_attr_array);
|
||||
|
||||
int set_paxos_replica_attr_array(
|
||||
const common::ObIArray<share::ReplicaAttr> &full_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &logonly_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &encryption_logonly_replica_attr_array);
|
||||
|
||||
int set_readonly_replica_attr_array(
|
||||
const common::ObIArray<share::ReplicaAttr> &readonly_replica_attr_array);
|
||||
|
||||
int get_readonly_memstore_percent(int64_t &memstore_percent) const;
|
||||
int set_non_paxos_replica_attr_array(
|
||||
const common::ObIArray<share::ReplicaAttr> &readonly_replica_attr_array,
|
||||
const common::ObIArray<share::ReplicaAttr> &columnstore_replica_attr_array);
|
||||
|
||||
bool has_paxos_replica() const;
|
||||
bool is_specific_readonly_replica() const;
|
||||
@ -240,6 +261,7 @@ private:
|
||||
ReplicaAttrArray logonly_replica_attr_array_;
|
||||
ReplicaAttrArray readonly_replica_attr_array_;
|
||||
ReplicaAttrArray encryption_logonly_replica_attr_array_;
|
||||
ReplicaAttrArray columnstore_replica_attr_array_;
|
||||
};
|
||||
|
||||
struct SchemaZoneReplicaAttrSet
|
||||
@ -253,6 +275,7 @@ struct SchemaZoneReplicaAttrSet
|
||||
int64_t get_logonly_replica_num() const {return replica_attr_set_.get_logonly_replica_num();}
|
||||
int64_t get_readonly_replica_num() const {return replica_attr_set_.get_readonly_replica_num();}
|
||||
int64_t get_encryption_logonly_replica_num() const {return replica_attr_set_.get_encryption_logonly_replica_num();}
|
||||
int64_t get_columnstore_replica_num() const {return replica_attr_set_.get_columnstore_replica_num();}
|
||||
int64_t get_paxos_replica_num() const {
|
||||
return get_full_replica_num() + get_logonly_replica_num() + get_encryption_logonly_replica_num();
|
||||
}
|
||||
@ -291,34 +314,9 @@ struct ObZoneReplicaAttrSet
|
||||
int64_t get_encryption_logonly_replica_num() const {
|
||||
return replica_attr_set_.get_encryption_logonly_replica_num();
|
||||
}
|
||||
int64_t get_columnstore_replica_num() const {return replica_attr_set_.get_columnstore_replica_num();}
|
||||
const common::ObIArray<common::ObZone> &get_zone_set() const { return zone_set_; }
|
||||
|
||||
int add_full_replica_num(const ReplicaAttr &replica_attr) {
|
||||
return replica_attr_set_.add_full_replica_num(replica_attr);
|
||||
}
|
||||
int add_logonly_replica_num(const ReplicaAttr &replica_attr) {
|
||||
return replica_attr_set_.add_logonly_replica_num(replica_attr);
|
||||
}
|
||||
int add_readonly_replica_num(const ReplicaAttr &replica_attr) {
|
||||
return replica_attr_set_.add_readonly_replica_num(replica_attr);
|
||||
}
|
||||
int add_encryption_logonly_replica_num(const ReplicaAttr &replica_attr) {
|
||||
return replica_attr_set_.add_encryption_logonly_replica_num(replica_attr);
|
||||
}
|
||||
|
||||
int sub_full_replica_num(const ReplicaAttr &replica_attr) {
|
||||
return replica_attr_set_.sub_full_replica_num(replica_attr);
|
||||
}
|
||||
int sub_logonly_replica_num(const ReplicaAttr &replica_attr) {
|
||||
return replica_attr_set_.sub_logonly_replica_num(replica_attr);
|
||||
}
|
||||
int sub_readonly_replica_num(const ReplicaAttr &replica_attr) {
|
||||
return replica_attr_set_.sub_readonly_replica_num(replica_attr);
|
||||
}
|
||||
int sub_encryption_logonly_replica_num(const ReplicaAttr &replica_attr) {
|
||||
return replica_attr_set_.sub_encryption_logonly_replica_num(replica_attr);
|
||||
}
|
||||
|
||||
int64_t get_paxos_replica_num() const {
|
||||
return get_full_replica_num() + get_logonly_replica_num() + get_encryption_logonly_replica_num();
|
||||
}
|
||||
@ -359,57 +357,6 @@ struct ObZoneReplicaAttrSet
|
||||
|
||||
typedef ObZoneReplicaAttrSet ObZoneReplicaNumSet;
|
||||
|
||||
struct ObReplicaNumSet
|
||||
{
|
||||
ObReplicaNumSet() : full_replica_num_(0),
|
||||
logonly_replica_num_(0),
|
||||
readonly_replica_num_(0),
|
||||
encryption_logonly_replica_num_(0)
|
||||
{ reset(); }
|
||||
virtual ~ObReplicaNumSet() {}
|
||||
bool operator==(const ObReplicaNumSet &that) {
|
||||
return full_replica_num_ == that.full_replica_num_
|
||||
&& logonly_replica_num_ == that.logonly_replica_num_
|
||||
&& readonly_replica_num_ == that.readonly_replica_num_
|
||||
&& encryption_logonly_replica_num_ == that.encryption_logonly_replica_num_;
|
||||
}
|
||||
bool operator!=(const ObReplicaNumSet &that) {
|
||||
return (!(*this == that));
|
||||
}
|
||||
void reset() {
|
||||
full_replica_num_ = 0;
|
||||
logonly_replica_num_ = 0;
|
||||
readonly_replica_num_ = 0;
|
||||
encryption_logonly_replica_num_ = 0;
|
||||
}
|
||||
ObReplicaNumSet &operator=(const ObReplicaNumSet &that) {
|
||||
if (this != &that) {
|
||||
full_replica_num_ = that.full_replica_num_;
|
||||
logonly_replica_num_ = that.logonly_replica_num_;
|
||||
readonly_replica_num_ = that.readonly_replica_num_;
|
||||
encryption_logonly_replica_num_ = that.encryption_logonly_replica_num_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
void set_replica_num(
|
||||
int64_t full_replica_num,
|
||||
int64_t logonly_replica_num,
|
||||
int64_t readonly_replica_num,
|
||||
int64_t encryption_logonly_replica_num);
|
||||
|
||||
int64_t get_specific_replica_num() const;
|
||||
|
||||
TO_STRING_KV(K(full_replica_num_),
|
||||
K(logonly_replica_num_),
|
||||
K(readonly_replica_num_),
|
||||
K(logonly_replica_num_));
|
||||
|
||||
int64_t full_replica_num_;
|
||||
int64_t logonly_replica_num_;
|
||||
int64_t readonly_replica_num_;
|
||||
int64_t encryption_logonly_replica_num_;
|
||||
};
|
||||
|
||||
} // end namespace share
|
||||
} // end namespace oceanbase
|
||||
#endif
|
||||
|
@ -4078,7 +4078,7 @@ int ObAdminAlterLSReplicaArg::init_add(
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!ls_id.is_valid())
|
||||
|| OB_UNLIKELY(!server_addr.is_valid())
|
||||
|| OB_UNLIKELY(replica_type != REPLICA_TYPE_FULL && replica_type != REPLICA_TYPE_READONLY)
|
||||
|| OB_UNLIKELY(!ObReplicaTypeCheck::is_replica_type_valid(replica_type))
|
||||
|| OB_UNLIKELY(paxos_replica_num < 0)
|
||||
|| OB_UNLIKELY(!is_valid_tenant_id(tenant_id))) {
|
||||
//data_source and paxos_replica_num is optional parameter
|
||||
@ -4157,7 +4157,7 @@ int ObAdminAlterLSReplicaArg::init_modify_replica(
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!ls_id.is_valid())
|
||||
|| OB_UNLIKELY(!server_addr.is_valid())
|
||||
|| OB_UNLIKELY(replica_type != REPLICA_TYPE_FULL && replica_type != REPLICA_TYPE_READONLY)
|
||||
|| OB_UNLIKELY(!ObReplicaTypeCheck::is_replica_type_valid(replica_type))
|
||||
|| OB_UNLIKELY(paxos_replica_num < 0)
|
||||
|| OB_UNLIKELY(!is_valid_tenant_id(tenant_id))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
@ -4218,7 +4218,7 @@ void ObAdminAlterLSReplicaArg::reset()
|
||||
ls_id_.reset();
|
||||
server_addr_.reset();
|
||||
destination_addr_.reset();
|
||||
replica_type_ = common::REPLICA_TYPE_MAX;
|
||||
replica_type_ = common::REPLICA_TYPE_INVALID;
|
||||
tenant_id_ = OB_INVALID_TENANT_ID;
|
||||
task_id_.reset();
|
||||
data_source_.reset();
|
||||
@ -6235,98 +6235,6 @@ OB_SERIALIZE_MEMBER(ObSyncPGPartitionMTFinishArg, server_, version_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObCheckDanglingReplicaFinishArg, server_, version_, dangling_count_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObMemberListAndLeaderArg,
|
||||
member_list_,
|
||||
leader_,
|
||||
self_,
|
||||
lower_list_,
|
||||
replica_type_,
|
||||
property_,
|
||||
role_);
|
||||
|
||||
bool ObMemberListAndLeaderArg::is_valid() const
|
||||
{
|
||||
return member_list_.count() > 0
|
||||
&& self_.is_valid()
|
||||
&& common::REPLICA_TYPE_MAX != replica_type_
|
||||
&& property_.is_valid()
|
||||
&& (common::INVALID_ROLE <= role_ && role_ <= common::STANDBY_LEADER);
|
||||
}
|
||||
|
||||
// If it is a leader, you need to ensure the consistency of role_, leader_/restore_leader_, and self_
|
||||
bool ObMemberListAndLeaderArg::check_leader_is_valid() const
|
||||
{
|
||||
bool bret = true;
|
||||
if (is_leader_by_election(role_)) {
|
||||
bret = (leader_.is_valid() && self_ == leader_);
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
void ObMemberListAndLeaderArg::reset()
|
||||
{
|
||||
member_list_.reset();
|
||||
leader_.reset();
|
||||
self_.reset();
|
||||
lower_list_.reset();
|
||||
replica_type_ = common::REPLICA_TYPE_MAX;
|
||||
role_ = common::INVALID_ROLE;
|
||||
}
|
||||
|
||||
int ObMemberListAndLeaderArg::assign(const ObMemberListAndLeaderArg &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(member_list_.assign(other.member_list_))) {
|
||||
LOG_WARN("fail to assign member_list", KR(ret), K_(member_list));
|
||||
} else if (OB_FAIL(lower_list_.assign(other.lower_list_))) {
|
||||
LOG_WARN("fail to assign lower_list", KR(ret), K_(lower_list));
|
||||
} else {
|
||||
leader_ = other.leader_;
|
||||
self_ = other.self_;
|
||||
replica_type_ = other.replica_type_;
|
||||
property_ = other.property_;
|
||||
role_ = other.role_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObGetMemberListAndLeaderResult,
|
||||
member_list_,
|
||||
leader_,
|
||||
self_,
|
||||
lower_list_,
|
||||
replica_type_,
|
||||
property_);
|
||||
|
||||
void ObGetMemberListAndLeaderResult::reset()
|
||||
{
|
||||
member_list_.reset();
|
||||
leader_.reset();
|
||||
self_.reset();
|
||||
lower_list_.reset();
|
||||
replica_type_ = common::REPLICA_TYPE_MAX;
|
||||
}
|
||||
|
||||
int ObGetMemberListAndLeaderResult::assign(const ObGetMemberListAndLeaderResult &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
reset();
|
||||
if (OB_UNLIKELY(!other.is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(other));
|
||||
} else if (OB_FAIL(member_list_.assign(other.member_list_))) {
|
||||
LOG_WARN("failed to assign member list", K(ret));
|
||||
} else if (OB_FAIL(lower_list_.assign(other.lower_list_))) {
|
||||
LOG_WARN("fail to assign member list", K(ret));
|
||||
} else {
|
||||
leader_ = other.leader_;
|
||||
self_ = other.self_;
|
||||
replica_type_ = other.replica_type_;
|
||||
property_ = other.property_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObBatchGetRoleResult, results_);
|
||||
|
||||
void ObBatchGetRoleResult::reset()
|
||||
@ -7580,7 +7488,7 @@ bool TenantServerUnitConfig::is_valid() const
|
||||
return common::OB_INVALID_ID != tenant_id_
|
||||
&& ((lib::Worker::CompatMode::INVALID != compat_mode_
|
||||
&& unit_config_.is_valid()
|
||||
&& replica_type_ != common::ObReplicaType::REPLICA_TYPE_MAX)
|
||||
&& replica_type_ != common::ObReplicaType::REPLICA_TYPE_INVALID)
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
// root_key can be invalid
|
||||
#endif
|
||||
@ -7648,7 +7556,7 @@ void TenantServerUnitConfig::reset()
|
||||
unit_id_ = OB_INVALID_ID;
|
||||
compat_mode_ = lib::Worker::CompatMode::INVALID;
|
||||
unit_config_.reset();
|
||||
replica_type_ = common::ObReplicaType::REPLICA_TYPE_MAX;
|
||||
replica_type_ = common::ObReplicaType::REPLICA_TYPE_INVALID;
|
||||
if_not_grant_ = false;
|
||||
is_delete_ = false;
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
@ -8909,7 +8817,7 @@ bool ObCreateLSArg::is_valid() const
|
||||
{
|
||||
return OB_INVALID_TENANT_ID != tenant_id_
|
||||
&& id_.is_valid()
|
||||
&& REPLICA_TYPE_MAX != replica_type_
|
||||
&& ObReplicaTypeCheck::is_replica_type_valid(replica_type_)
|
||||
&& replica_property_.is_valid()
|
||||
&& tenant_info_.is_valid()
|
||||
&& create_scn_.is_valid()
|
||||
@ -8921,7 +8829,7 @@ void ObCreateLSArg::reset()
|
||||
{
|
||||
tenant_id_ = OB_INVALID_TENANT_ID;
|
||||
id_.reset();
|
||||
replica_type_ = REPLICA_TYPE_MAX;
|
||||
replica_type_ = REPLICA_TYPE_INVALID;
|
||||
replica_property_.reset();
|
||||
tenant_info_.reset();
|
||||
create_scn_.reset();
|
||||
@ -8960,7 +8868,7 @@ int ObCreateLSArg::init(const int64_t tenant_id,
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(OB_INVALID_TENANT_ID == tenant_id
|
||||
||!id.is_valid()
|
||||
|| REPLICA_TYPE_MAX == replica_type
|
||||
|| !ObReplicaTypeCheck::is_replica_type_valid(replica_type)
|
||||
|| !replica_property.is_valid()
|
||||
|| !tenant_info.is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
|
@ -3414,7 +3414,7 @@ public:
|
||||
CREATE_WITH_PALF,
|
||||
};
|
||||
ObCreateLSArg() : tenant_id_(OB_INVALID_TENANT_ID), id_(),
|
||||
replica_type_(REPLICA_TYPE_MAX),
|
||||
replica_type_(REPLICA_TYPE_INVALID),
|
||||
replica_property_(), tenant_info_(),
|
||||
create_scn_(),
|
||||
compat_mode_(lib::Worker::CompatMode::INVALID),
|
||||
@ -4339,7 +4339,7 @@ public:
|
||||
: ls_id_(),
|
||||
server_addr_(),
|
||||
destination_addr_(),
|
||||
replica_type_(common::REPLICA_TYPE_MAX),
|
||||
replica_type_(common::REPLICA_TYPE_INVALID),
|
||||
tenant_id_(OB_INVALID_TENANT_ID),
|
||||
task_id_(),
|
||||
data_source_(),
|
||||
@ -4411,7 +4411,7 @@ private:
|
||||
bool is_add_valid_() const {
|
||||
return ls_id_.is_valid()
|
||||
&& server_addr_.is_valid()
|
||||
&& REPLICA_TYPE_MAX != replica_type_
|
||||
&& ObReplicaTypeCheck::is_replica_type_valid(replica_type_)
|
||||
&& is_valid_tenant_id(tenant_id_)
|
||||
&& paxos_replica_num_ >= 0;
|
||||
}
|
||||
@ -4430,7 +4430,7 @@ private:
|
||||
bool is_modify_replica_valid_() const {
|
||||
return ls_id_.is_valid()
|
||||
&& server_addr_.is_valid()
|
||||
&& REPLICA_TYPE_MAX != replica_type_
|
||||
&& ObReplicaTypeCheck::is_replica_type_valid(replica_type_)
|
||||
&& is_valid_tenant_id(tenant_id_)
|
||||
&& paxos_replica_num_ >= 0;
|
||||
}
|
||||
@ -6918,65 +6918,6 @@ public:
|
||||
int64_t dangling_count_;
|
||||
};
|
||||
|
||||
struct ObGetMemberListAndLeaderResult final
|
||||
{
|
||||
OB_UNIS_VERSION(1);
|
||||
public:
|
||||
ObGetMemberListAndLeaderResult()
|
||||
: member_list_(),
|
||||
leader_(),
|
||||
self_(),
|
||||
lower_list_(),
|
||||
replica_type_(common::REPLICA_TYPE_MAX),
|
||||
property_() {}
|
||||
void reset();
|
||||
inline bool is_valid() const {
|
||||
return member_list_.count() > 0
|
||||
&& self_.is_valid()
|
||||
&& common::REPLICA_TYPE_MAX != replica_type_
|
||||
&& property_.is_valid();
|
||||
}
|
||||
|
||||
int assign(const ObGetMemberListAndLeaderResult &other);
|
||||
TO_STRING_KV(K_(member_list), K_(leader), K_(self), K_(lower_list), K_(replica_type), K_(property));
|
||||
|
||||
common::ObSEArray<common::ObMember, common::OB_MAX_MEMBER_NUMBER,
|
||||
common::ObNullAllocator, false> member_list_; // copy won't fail
|
||||
common::ObAddr leader_;
|
||||
common::ObAddr self_;
|
||||
common::ObSEArray<common::ObReplicaMember, common::OB_MAX_CHILD_MEMBER_NUMBER> lower_list_; //Cascaded downstream information
|
||||
common::ObReplicaType replica_type_; //The type of copy actually stored in the local copy
|
||||
common::ObReplicaProperty property_;
|
||||
};
|
||||
|
||||
struct ObMemberListAndLeaderArg
|
||||
{
|
||||
OB_UNIS_VERSION(1);
|
||||
public:
|
||||
ObMemberListAndLeaderArg()
|
||||
: member_list_(),
|
||||
leader_(),
|
||||
self_(),
|
||||
lower_list_(),
|
||||
replica_type_(common::REPLICA_TYPE_MAX),
|
||||
property_(),
|
||||
role_(common::INVALID_ROLE) {}
|
||||
void reset();
|
||||
bool is_valid() const;
|
||||
bool check_leader_is_valid() const;
|
||||
int assign(const ObMemberListAndLeaderArg &other);
|
||||
TO_STRING_KV(K_(member_list), K_(leader), K_(self), K_(lower_list),
|
||||
K_(replica_type), K_(property), K_(role));
|
||||
|
||||
common::ObSArray<common::ObAddr> member_list_; // copy won't fail
|
||||
common::ObAddr leader_;
|
||||
common::ObAddr self_;
|
||||
common::ObSArray<common::ObReplicaMember> lower_list_; //Cascaded downstream information
|
||||
common::ObReplicaType replica_type_; //The type of copy actually stored in the local copy
|
||||
common::ObReplicaProperty property_;
|
||||
common::ObRole role_;
|
||||
};
|
||||
|
||||
struct ObBatchGetRoleResult
|
||||
{
|
||||
OB_UNIS_VERSION(1);
|
||||
@ -9917,7 +9858,7 @@ public:
|
||||
unit_id_(common::OB_INVALID_ID),
|
||||
compat_mode_(lib::Worker::CompatMode::INVALID),
|
||||
unit_config_(),
|
||||
replica_type_(common::ObReplicaType::REPLICA_TYPE_MAX),
|
||||
replica_type_(common::ObReplicaType::REPLICA_TYPE_INVALID),
|
||||
if_not_grant_(false),
|
||||
is_delete_(false)
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
|
@ -186,30 +186,8 @@ int ObShareUtil::check_compat_version_for_arbitration_service(
|
||||
const uint64_t tenant_id,
|
||||
bool &is_compatible)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_compatible = false;
|
||||
uint64_t data_version = 0;
|
||||
if (OB_UNLIKELY(OB_INVALID_TENANT_ID == tenant_id)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(GET_MIN_DATA_VERSION(OB_SYS_TENANT_ID, data_version))) {
|
||||
LOG_WARN("fail to get sys tenant data version", KR(ret));
|
||||
} else if (DATA_VERSION_4_1_0_0 > data_version) {
|
||||
is_compatible = false;
|
||||
} else if (!is_sys_tenant(tenant_id)
|
||||
&& OB_FAIL(GET_MIN_DATA_VERSION(gen_user_tenant_id(tenant_id), data_version))) {
|
||||
LOG_WARN("fail to get user tenant data version", KR(ret), "tenant_id", gen_user_tenant_id(tenant_id));
|
||||
} else if (!is_sys_tenant(tenant_id) && DATA_VERSION_4_1_0_0 > data_version) {
|
||||
is_compatible = false;
|
||||
} else if (!is_sys_tenant(tenant_id)
|
||||
&& OB_FAIL(GET_MIN_DATA_VERSION(gen_meta_tenant_id(tenant_id), data_version))) {
|
||||
LOG_WARN("fail to get meta tenant data version", KR(ret), "tenant_id", gen_meta_tenant_id(tenant_id));
|
||||
} else if (!is_sys_tenant(tenant_id) && DATA_VERSION_4_1_0_0 > data_version) {
|
||||
is_compatible = false;
|
||||
} else {
|
||||
is_compatible = true;
|
||||
}
|
||||
return ret;
|
||||
return check_compat_data_version_(DATA_VERSION_4_1_0_0, true/*check_meta*/, true/*check_user*/,
|
||||
tenant_id, is_compatible);
|
||||
}
|
||||
|
||||
int ObShareUtil::generate_arb_replica_num(
|
||||
@ -239,25 +217,16 @@ int ObShareUtil::check_compat_version_for_readonly_replica(
|
||||
const uint64_t tenant_id,
|
||||
bool &is_compatible)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t data_version = 0;
|
||||
is_compatible = false;
|
||||
if (OB_UNLIKELY(OB_INVALID_TENANT_ID == tenant_id)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(GET_MIN_DATA_VERSION(OB_SYS_TENANT_ID, data_version))) {
|
||||
LOG_WARN("fail to get sys tenant data version", KR(ret));
|
||||
} else if (DATA_VERSION_4_2_0_0 > data_version) {
|
||||
is_compatible = false;
|
||||
} else if (!is_sys_tenant(tenant_id)
|
||||
&& OB_FAIL(GET_MIN_DATA_VERSION(gen_meta_tenant_id(tenant_id), data_version))) {
|
||||
LOG_WARN("fail to get meta tenant data version", KR(ret), "tenant_id", gen_meta_tenant_id(tenant_id));
|
||||
} else if (!is_sys_tenant(tenant_id) && DATA_VERSION_4_2_0_0 > data_version) {
|
||||
is_compatible = false;
|
||||
} else {
|
||||
is_compatible = true;
|
||||
}
|
||||
return ret;
|
||||
return check_compat_data_version_(DATA_VERSION_4_2_0_0, true/*check_meta*/, false/*check_user*/,
|
||||
tenant_id, is_compatible);
|
||||
}
|
||||
|
||||
int ObShareUtil::check_compat_version_for_columnstore_replica(
|
||||
const uint64_t tenant_id,
|
||||
bool &is_compatible)
|
||||
{
|
||||
return check_compat_data_version_(DATA_VERSION_4_3_3_0, true/*check_meta*/, false/*check_user*/,
|
||||
tenant_id, is_compatible);
|
||||
}
|
||||
|
||||
int ObShareUtil::fetch_current_cluster_version(
|
||||
@ -450,34 +419,42 @@ bool ObShareUtil::is_tenant_enable_transfer(const uint64_t tenant_id)
|
||||
|
||||
return bret;
|
||||
}
|
||||
int ObShareUtil::check_compat_version_for_tenant(
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t target_data_version,
|
||||
bool &is_compatible)
|
||||
|
||||
int ObShareUtil::check_compat_data_version_(
|
||||
const uint64_t required_data_version,
|
||||
const bool check_meta_tenant,
|
||||
const bool check_user_tenant,
|
||||
const uint64_t tenant_id,
|
||||
bool &is_compatible)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_compatible = false;
|
||||
is_compatible = true;
|
||||
uint64_t data_version = 0;
|
||||
if (OB_UNLIKELY(OB_INVALID_TENANT_ID == tenant_id)
|
||||
|| OB_UNLIKELY(0 == target_data_version)) {
|
||||
|| OB_UNLIKELY(0 == required_data_version)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id), K(target_data_version));
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id), K(required_data_version));
|
||||
} else if (OB_FAIL(GET_MIN_DATA_VERSION(OB_SYS_TENANT_ID, data_version))) {
|
||||
LOG_WARN("fail to get sys tenant data version", KR(ret));
|
||||
} else if (target_data_version > data_version) {
|
||||
} else if (required_data_version > data_version) {
|
||||
is_compatible = false;
|
||||
} else if (is_sys_tenant(tenant_id)) {
|
||||
is_compatible = true;
|
||||
} else if (OB_FAIL(GET_MIN_DATA_VERSION(gen_user_tenant_id(tenant_id), data_version))) {
|
||||
LOG_WARN("fail to get user tenant data version", KR(ret), "tenant_id", gen_user_tenant_id(tenant_id));
|
||||
} else if (target_data_version > data_version) {
|
||||
is_compatible = false;
|
||||
} else if (OB_FAIL(GET_MIN_DATA_VERSION(gen_meta_tenant_id(tenant_id), data_version))) {
|
||||
LOG_WARN("fail to get meta tenant data version", KR(ret), "tenant_id", gen_meta_tenant_id(tenant_id));
|
||||
} else if (target_data_version > data_version) {
|
||||
is_compatible = false;
|
||||
} else {
|
||||
is_compatible = true;
|
||||
} else if (!is_sys_tenant(tenant_id)) {
|
||||
if (check_meta_tenant) {
|
||||
if (OB_FAIL(GET_MIN_DATA_VERSION(gen_meta_tenant_id(tenant_id), data_version))) {
|
||||
LOG_WARN("fail to get meta tenant data version", KR(ret), "tenant_id", gen_meta_tenant_id(tenant_id));
|
||||
} else if (required_data_version > data_version) {
|
||||
is_compatible = false;
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret) || !is_compatible) {
|
||||
// skip
|
||||
} else if (check_user_tenant) {
|
||||
if (OB_FAIL(GET_MIN_DATA_VERSION(gen_user_tenant_id(tenant_id), data_version))) {
|
||||
LOG_WARN("fail to get user tenant data version", KR(ret), "tenant_id", gen_user_tenant_id(tenant_id));
|
||||
} else if (required_data_version > data_version) {
|
||||
is_compatible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -492,8 +469,8 @@ int ObShareUtil::check_compat_version_for_clone_standby_tenant(
|
||||
if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(check_compat_version_for_tenant(
|
||||
tenant_id, target_data_version, is_compatible))) {
|
||||
} else if (OB_FAIL(check_compat_data_version_(target_data_version,
|
||||
true/*check_meta*/, true/*check_user*/, tenant_id, is_compatible))) {
|
||||
LOG_WARN("fail to check data version for clone tenant", KR(ret),
|
||||
K(tenant_id), K(target_data_version));
|
||||
}
|
||||
@ -510,8 +487,8 @@ int ObShareUtil::check_compat_version_for_clone_tenant(
|
||||
if (OB_UNLIKELY(OB_INVALID_TENANT_ID == tenant_id)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(check_compat_version_for_tenant(
|
||||
tenant_id, target_data_version, is_compatible))) {
|
||||
} else if (OB_FAIL(check_compat_data_version_(target_data_version,
|
||||
true/*check_meta*/, true/*check_user*/, tenant_id, is_compatible))) {
|
||||
LOG_WARN("fail to check data version for clone tenant", KR(ret),
|
||||
K(tenant_id), K(target_data_version));
|
||||
}
|
||||
@ -551,5 +528,77 @@ int ObShareUtil::check_compat_version_for_clone_tenant_with_tenant_role(
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char *ObShareUtil::replica_type_to_string(const ObReplicaType type)
|
||||
{
|
||||
const char *str = NULL;
|
||||
switch (type) {
|
||||
case ObReplicaType::REPLICA_TYPE_FULL: {
|
||||
str = FULL_REPLICA_STR;
|
||||
break;
|
||||
}
|
||||
case ObReplicaType::REPLICA_TYPE_BACKUP: {
|
||||
str = BACKUP_REPLICA_STR;
|
||||
break;
|
||||
}
|
||||
case ObReplicaType::REPLICA_TYPE_LOGONLY: {
|
||||
str = LOGONLY_REPLICA_STR;
|
||||
break;
|
||||
}
|
||||
case ObReplicaType::REPLICA_TYPE_READONLY: {
|
||||
str = READONLY_REPLICA_STR;
|
||||
break;
|
||||
}
|
||||
case ObReplicaType::REPLICA_TYPE_MEMONLY: {
|
||||
str = MEMONLY_REPLICA_STR;
|
||||
break;
|
||||
}
|
||||
case ObReplicaType::REPLICA_TYPE_ENCRYPTION_LOGONLY: {
|
||||
str = ENCRYPTION_LOGONLY_REPLICA_STR;
|
||||
break;
|
||||
}
|
||||
case ObReplicaType::REPLICA_TYPE_COLUMNSTORE: {
|
||||
str = COLUMNSTORE_REPLICA_STR;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
str = "INVALID";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
// retrun REPLICA_TYPE_INVALID if str is invaild
|
||||
ObReplicaType ObShareUtil::string_to_replica_type(const char *str)
|
||||
{
|
||||
return string_to_replica_type(ObString(str));
|
||||
}
|
||||
|
||||
// retrun REPLICA_TYPE_INVALID if str is invaild
|
||||
ObReplicaType ObShareUtil::string_to_replica_type(const ObString &str)
|
||||
{
|
||||
ObReplicaType replica_type = REPLICA_TYPE_INVALID;
|
||||
if (OB_UNLIKELY(str.empty())) {
|
||||
replica_type = REPLICA_TYPE_INVALID;
|
||||
} else if (0 == str.case_compare(FULL_REPLICA_STR) || 0 == str.case_compare(F_REPLICA_STR)) {
|
||||
replica_type = REPLICA_TYPE_FULL;
|
||||
} else if (0 == str.case_compare(READONLY_REPLICA_STR) || 0 == str.case_compare(R_REPLICA_STR)) {
|
||||
replica_type = REPLICA_TYPE_READONLY;
|
||||
} else if (0 == str.case_compare(COLUMNSTORE_REPLICA_STR) || 0 == str.case_compare(C_REPLICA_STR)) {
|
||||
replica_type = REPLICA_TYPE_COLUMNSTORE;
|
||||
} else if (0 == str.case_compare(LOGONLY_REPLICA_STR) || 0 == str.case_compare(L_REPLICA_STR)) {
|
||||
replica_type = REPLICA_TYPE_LOGONLY;
|
||||
} else if (0 == str.case_compare(ENCRYPTION_LOGONLY_REPLICA_STR) || 0 == str.case_compare(E_REPLICA_STR)) {
|
||||
replica_type = REPLICA_TYPE_ENCRYPTION_LOGONLY;
|
||||
} else if (0 == str.case_compare(BACKUP_REPLICA_STR) || 0 == str.case_compare(B_REPLICA_STR)) {
|
||||
replica_type = REPLICA_TYPE_BACKUP;
|
||||
} else if (0 == str.case_compare(MEMONLY_REPLICA_STR) || 0 == str.case_compare(M_REPLICA_STR)) {
|
||||
replica_type = REPLICA_TYPE_MEMONLY;
|
||||
} else {
|
||||
replica_type = REPLICA_TYPE_INVALID;
|
||||
}
|
||||
return replica_type;
|
||||
}
|
||||
|
||||
} //end namespace share
|
||||
} //end namespace oceanbase
|
||||
|
@ -78,14 +78,6 @@ public:
|
||||
static int check_compat_version_for_arbitration_service(
|
||||
const uint64_t tenant_id,
|
||||
bool &is_compatible);
|
||||
// check whether sys/meta/user tenant has been promoted to target data version
|
||||
// params[in] tenant_id, which tenant to check
|
||||
// params[in] target_data_version, data version to check
|
||||
// params[out] is_compatible, whether tenants are promoted to target data version
|
||||
static int check_compat_version_for_tenant(
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t target_data_version,
|
||||
bool &is_compatible);
|
||||
// tenant data version should up to 430 when cloning primary tenant
|
||||
// tenant data version should up to 432 when cloning standby tenant
|
||||
// params[in] tenant_id, which tenant to check
|
||||
@ -122,6 +114,13 @@ public:
|
||||
const uint64_t tenant_id,
|
||||
bool &is_compatible);
|
||||
|
||||
// data version must up to 4.3.2 with column-store replica
|
||||
// @params[in] tenant_id, which tenant to check
|
||||
// @params[out] is_compatible, whether it is over 4.3.2
|
||||
static int check_compat_version_for_columnstore_replica(
|
||||
const uint64_t tenant_id,
|
||||
bool &is_compatible);
|
||||
|
||||
static int fetch_current_cluster_version(
|
||||
common::ObISQLClient &client,
|
||||
uint64_t &cluster_version);
|
||||
@ -148,6 +147,16 @@ public:
|
||||
SCN &ora_rowscn);
|
||||
static bool is_tenant_enable_rebalance(const uint64_t tenant_id);
|
||||
static bool is_tenant_enable_transfer(const uint64_t tenant_id);
|
||||
static const char *replica_type_to_string(const ObReplicaType type);
|
||||
static ObReplicaType string_to_replica_type(const char *str);
|
||||
static ObReplicaType string_to_replica_type(const ObString &str);
|
||||
private:
|
||||
static int check_compat_data_version_(
|
||||
const uint64_t required_data_version,
|
||||
const bool check_meta_tenant,
|
||||
const bool check_user_tenant,
|
||||
const uint64_t tenant_id,
|
||||
bool &is_compatible);
|
||||
};
|
||||
}//end namespace share
|
||||
}//end namespace oceanbase
|
||||
|
@ -311,6 +311,20 @@ int ObTabletReplicaChecksumItem::verify_checksum(const ObTabletReplicaChecksumIt
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletReplicaChecksumItem::verify_column_checksum(const ObTabletReplicaChecksumItem &other) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (compaction_scn_ == other.compaction_scn_) {
|
||||
bool column_meta_equal = false;
|
||||
if (OB_FAIL(column_meta_.check_equal(other.column_meta_, column_meta_equal))) {
|
||||
LOG_WARN("fail to check column meta equal", KR(ret), K(other), K(*this));
|
||||
} else if (!column_meta_equal) {
|
||||
ret = OB_CHECKSUM_ERROR;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletReplicaChecksumItem::assign_key(const ObTabletReplicaChecksumItem &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -901,5 +915,45 @@ int ObTabletReplicaChecksumOperator::get_hex_column_meta(
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ----------------------- ObTabletDataChecksumChecker -----------------------
|
||||
ObTabletDataChecksumChecker::ObTabletDataChecksumChecker()
|
||||
: normal_ckm_item_(nullptr),
|
||||
cs_replica_ckm_item_(nullptr)
|
||||
{}
|
||||
|
||||
ObTabletDataChecksumChecker::~ObTabletDataChecksumChecker()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
void ObTabletDataChecksumChecker::reset()
|
||||
{
|
||||
normal_ckm_item_ = nullptr;
|
||||
cs_replica_ckm_item_ = nullptr;
|
||||
}
|
||||
|
||||
int ObTabletDataChecksumChecker::check_data_checksum(const ObTabletReplicaChecksumItem& curr_item, bool is_cs_replica)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (is_cs_replica) {
|
||||
if (OB_ISNULL(cs_replica_ckm_item_)) {
|
||||
cs_replica_ckm_item_ = &curr_item;
|
||||
} else if (cs_replica_ckm_item_->compaction_scn_ != curr_item.compaction_scn_) {
|
||||
LOG_INFO("no need to check data checksum", K(curr_item), KPC(this));
|
||||
} else if (cs_replica_ckm_item_->data_checksum_ != curr_item.data_checksum_) {
|
||||
ret = OB_CHECKSUM_ERROR;
|
||||
}
|
||||
} else {
|
||||
if (OB_ISNULL(normal_ckm_item_)) {
|
||||
normal_ckm_item_ = &curr_item;
|
||||
} else if (normal_ckm_item_->compaction_scn_ != curr_item.compaction_scn_) {
|
||||
LOG_INFO("no need to check data checksum", K(curr_item), KPC(this));
|
||||
} else if (normal_ckm_item_->data_checksum_ != curr_item.data_checksum_) {
|
||||
ret = OB_CHECKSUM_ERROR;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // share
|
||||
} // oceanbase
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
bool is_valid() const;
|
||||
bool is_same_tablet(const ObTabletReplicaChecksumItem &other) const;
|
||||
int verify_checksum(const ObTabletReplicaChecksumItem &other) const;
|
||||
int verify_column_checksum(const ObTabletReplicaChecksumItem &other) const;
|
||||
int assign_key(const ObTabletReplicaChecksumItem &other);
|
||||
int assign(const ObTabletReplicaChecksumItem &other);
|
||||
int set_tenant_id(const uint64_t tenant_id);
|
||||
@ -270,6 +271,18 @@ int ObTabletReplicaChecksumOperator::construct_batch_get_sql_str_(
|
||||
return ret;
|
||||
}
|
||||
|
||||
class ObTabletDataChecksumChecker
|
||||
{
|
||||
public:
|
||||
ObTabletDataChecksumChecker();
|
||||
~ObTabletDataChecksumChecker();
|
||||
void reset();
|
||||
int check_data_checksum(const ObTabletReplicaChecksumItem& curr_item, bool is_cs_replica);
|
||||
TO_STRING_KV(KPC_(normal_ckm_item), KPC_(cs_replica_ckm_item));
|
||||
private:
|
||||
const ObTabletReplicaChecksumItem *normal_ckm_item_;
|
||||
const ObTabletReplicaChecksumItem *cs_replica_ckm_item_;
|
||||
};
|
||||
|
||||
} // share
|
||||
} // oceanbase
|
||||
|
@ -101,6 +101,8 @@ DAG_SCHEDULER_DAG_TYPE_DEF(DAG_TYPE_START_PREPARE_MIGRATION, ObDagPrio::DAG_PRIO
|
||||
true, 3, {"tenant_id", "ls_id", "op_type"})
|
||||
DAG_SCHEDULER_DAG_TYPE_DEF(DAG_TYPE_FINISH_PREPARE_MIGRATION, ObDagPrio::DAG_PRIO_HA_HIGH, ObSysTaskType::MIGRATION_TASK, "FINISH_PREPARE_MIGRATION", "MIGRATE",
|
||||
true, 3, {"tenant_id", "ls_id", "op_type"})
|
||||
DAG_SCHEDULER_DAG_TYPE_DEF(DAG_TYPE_TABLET_CHECK_CONVERT, ObDagPrio::DAG_PRIO_HA_HIGH, ObSysTaskType::MIGRATION_TASK, "TABLET_CHECKE_CONVERT", "MIGRATE",
|
||||
true, 3, {"tenant_id", "ls_id", "op_type"})
|
||||
// DAG_TYPE_MIGRATE END
|
||||
DAG_SCHEDULER_DAG_TYPE_DEF(DAG_TYPE_FAST_MIGRATE, ObDagPrio::DAG_PRIO_HA_MID, ObSysTaskType::MIGRATION_TASK, "FAST_MIGRATE", "MIGRATE",
|
||||
false, 0, {})
|
||||
|
@ -226,6 +226,7 @@ public:
|
||||
TASK_TYPE_START_REBUILD_TABLET_TASK = 70,
|
||||
TASK_TYPE_TABLET_REBUILD_TASK = 71,
|
||||
TASK_TYPE_FINISH_REBUILD_TABLET_TASK = 72,
|
||||
TASK_TYPE_CHECK_CONVERT_TABLET = 73,
|
||||
TASK_TYPE_MAX,
|
||||
};
|
||||
|
||||
@ -599,6 +600,7 @@ public:
|
||||
void init_dag_id();
|
||||
int set_dag_id(const ObDagId &dag_net_id);
|
||||
const ObDagId &get_dag_id() const { return dag_net_id_; }
|
||||
void set_dag_net_id(const ObDagId &dag_net_id) { dag_net_id_ = dag_net_id; }
|
||||
void set_add_time() { add_time_ = ObTimeUtility::fast_current_time(); }
|
||||
int64_t get_add_time() const { return add_time_; }
|
||||
void set_start_time() { start_time_ = ObTimeUtility::fast_current_time(); }
|
||||
|
@ -1835,6 +1835,12 @@ void ObTenantSchema::reset_zone_replica_attr_array()
|
||||
free(encryption_logonly_attr_set.get_base_address());
|
||||
encryption_logonly_attr_set.reset();
|
||||
}
|
||||
SchemaReplicaAttrArray &columnstore_attr_set
|
||||
= static_cast<SchemaReplicaAttrArray &>(zone_locality.replica_attr_set_.get_columnstore_replica_attr_array());
|
||||
if (nullptr != columnstore_attr_set.get_base_address()) {
|
||||
free(columnstore_attr_set.get_base_address());
|
||||
columnstore_attr_set.reset();
|
||||
}
|
||||
}
|
||||
free(zone_replica_attr_array_.get_base_address());
|
||||
zone_replica_attr_array_.reset();
|
||||
@ -1906,6 +1912,10 @@ int ObTenantSchema::set_zone_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_encryption_logonly_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_encryption_logonly_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else if (OB_FAIL(set_specific_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_columnstore_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_columnstore_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else if (OB_FAIL(deep_copy_string_array(src_replica_attr_set.zone_set_, this_schema_set->zone_set_))) {
|
||||
LOG_WARN("fail to copy schema replica attr set zone set", K(ret));
|
||||
} else {
|
||||
@ -1952,6 +1962,10 @@ int ObTenantSchema::set_zone_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_encryption_logonly_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_encryption_logonly_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else if (OB_FAIL(set_specific_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_columnstore_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_columnstore_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else {
|
||||
common::ObArray<common::ObString> zone_set_ptrs;
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < src_replica_attr_set.zone_set_.count(); ++j) {
|
||||
@ -2635,267 +2649,6 @@ int ObDatabaseSchema::get_primary_zone_inherit(
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/*-------------------------------------------------------------------------------------------------
|
||||
* ------------------------------ObLocality-------------------------------------------
|
||||
----------------------------------------------------------------------------------------------------*/
|
||||
void ObLocality::reset_zone_replica_attr_array()
|
||||
{
|
||||
if (NULL != schema_ && NULL != zone_replica_attr_array_.get_base_address()) {
|
||||
for (int64_t i = 0; i < zone_replica_attr_array_.count(); ++i) {
|
||||
SchemaZoneReplicaAttrSet &zone_locality = zone_replica_attr_array_.at(i);
|
||||
schema_->reset_string_array(zone_locality.zone_set_);
|
||||
SchemaReplicaAttrArray &full_attr_set
|
||||
= static_cast<SchemaReplicaAttrArray &>(zone_locality.replica_attr_set_.get_full_replica_attr_array());
|
||||
if (nullptr != full_attr_set.get_base_address()) {
|
||||
schema_->free(full_attr_set.get_base_address());
|
||||
full_attr_set.reset();
|
||||
}
|
||||
SchemaReplicaAttrArray &logonly_attr_set
|
||||
= static_cast<SchemaReplicaAttrArray &>(zone_locality.replica_attr_set_.get_logonly_replica_attr_array());
|
||||
if (nullptr != logonly_attr_set.get_base_address()) {
|
||||
schema_->free(logonly_attr_set.get_base_address());
|
||||
logonly_attr_set.reset();
|
||||
}
|
||||
SchemaReplicaAttrArray &readonly_attr_set
|
||||
= static_cast<SchemaReplicaAttrArray &>(zone_locality.replica_attr_set_.get_readonly_replica_attr_array());
|
||||
if (nullptr != readonly_attr_set.get_base_address()) {
|
||||
schema_->free(readonly_attr_set.get_base_address());
|
||||
readonly_attr_set.reset();
|
||||
}
|
||||
SchemaReplicaAttrArray &encryption_logonly_attr_set
|
||||
= static_cast<SchemaReplicaAttrArray &>(zone_locality.replica_attr_set_.get_encryption_logonly_replica_attr_array());
|
||||
if (nullptr != encryption_logonly_attr_set.get_base_address()) {
|
||||
schema_->free(encryption_logonly_attr_set.get_base_address());
|
||||
encryption_logonly_attr_set.reset();
|
||||
}
|
||||
}
|
||||
schema_->free(zone_replica_attr_array_.get_base_address());
|
||||
zone_replica_attr_array_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
int ObLocality::set_specific_replica_attr_array(
|
||||
SchemaReplicaAttrArray &this_schema_set,
|
||||
const common::ObIArray<ReplicaAttr> &src)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t count = src.count();
|
||||
if (count > 0) {
|
||||
const int64_t size = count * static_cast<int64_t>(sizeof(share::ReplicaAttr));
|
||||
void *ptr = nullptr;
|
||||
if (nullptr == (ptr = schema_->alloc(size))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("alloc failed", K(ret), K(size));
|
||||
} else if (FALSE_IT(this_schema_set.init(count, static_cast<ReplicaAttr *>(ptr), count))) {
|
||||
// shall never by here
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < src.count(); ++i) {
|
||||
const share::ReplicaAttr &src_replica_attr = src.at(i);
|
||||
ReplicaAttr *dst_replica_attr = &this_schema_set.at(i);
|
||||
if (nullptr == (dst_replica_attr = new (dst_replica_attr) ReplicaAttr(
|
||||
src_replica_attr.num_, src_replica_attr.memstore_percent_))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("placement new return nullptr", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocality::set_zone_replica_attr_array(const common::ObIArray<SchemaZoneReplicaAttrSet> &src)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(schema_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(schema_));
|
||||
} else {
|
||||
reset_zone_replica_attr_array();
|
||||
const int64_t alloc_size = src.count() * static_cast<int64_t>(sizeof(SchemaZoneReplicaAttrSet));
|
||||
void *buf = NULL;
|
||||
if (src.count() <= 0) {
|
||||
// do nothing
|
||||
} else if (NULL == (buf = schema_->alloc(alloc_size))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("alloc failed", K(ret), K(alloc_size));
|
||||
} else {
|
||||
zone_replica_attr_array_.init(src.count(), static_cast<SchemaZoneReplicaAttrSet *>(buf), src.count());
|
||||
// call construct func in advance to avoid core status
|
||||
//
|
||||
ARRAY_NEW_CONSTRUCT(SchemaZoneReplicaAttrSet, zone_replica_attr_array_);
|
||||
for (int64_t i = 0; i < src.count() && OB_SUCC(ret); ++i) {
|
||||
const SchemaZoneReplicaAttrSet &src_replica_attr_set = src.at(i);
|
||||
SchemaZoneReplicaAttrSet *this_schema_set = &zone_replica_attr_array_.at(i);
|
||||
if (OB_FAIL(set_specific_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_full_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_full_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else if (OB_FAIL(set_specific_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_logonly_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_logonly_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else if (OB_FAIL(set_specific_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_readonly_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_readonly_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else if (OB_FAIL(set_specific_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_encryption_logonly_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_encryption_logonly_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else if (OB_FAIL(schema_->deep_copy_string_array(
|
||||
src_replica_attr_set.zone_set_, this_schema_set->zone_set_))) {
|
||||
LOG_WARN("fail to copy schema replica attr set zone set", K(ret));
|
||||
} else {
|
||||
this_schema_set->zone_ = src_replica_attr_set.zone_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocality::set_zone_replica_attr_array(const common::ObIArray<share::ObZoneReplicaAttrSet> &src)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(schema_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(schema_));
|
||||
} else {
|
||||
reset_zone_replica_attr_array();
|
||||
const int64_t alloc_size = src.count() * static_cast<int64_t>(sizeof(SchemaZoneReplicaAttrSet));
|
||||
void *buf = NULL;
|
||||
if (src.count() <= 0) {
|
||||
// do nothing
|
||||
} else if (NULL == (buf = schema_->alloc(alloc_size))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_ERROR("alloc failed", K(ret), K(alloc_size));
|
||||
} else {
|
||||
zone_replica_attr_array_.init(src.count(), static_cast<SchemaZoneReplicaAttrSet *>(buf), src.count());
|
||||
// call construct func in advance to avoid core status
|
||||
//
|
||||
ARRAY_NEW_CONSTRUCT(SchemaZoneReplicaAttrSet, zone_replica_attr_array_);
|
||||
for (int64_t i = 0; i < src.count() && OB_SUCC(ret); ++i) {
|
||||
const share::ObZoneReplicaAttrSet &src_replica_attr_set = src.at(i);
|
||||
SchemaZoneReplicaAttrSet *this_schema_set = &zone_replica_attr_array_.at(i);
|
||||
if (OB_FAIL(set_specific_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_full_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_full_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else if (OB_FAIL(set_specific_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_logonly_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_logonly_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else if (OB_FAIL(set_specific_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_readonly_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_readonly_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else if (OB_FAIL(set_specific_replica_attr_array(
|
||||
static_cast<SchemaReplicaAttrArray &>(this_schema_set->replica_attr_set_.get_encryption_logonly_replica_attr_array()),
|
||||
src_replica_attr_set.replica_attr_set_.get_encryption_logonly_replica_attr_array()))) {
|
||||
LOG_WARN("fail to set specific replica attr array", K(ret));
|
||||
} else {
|
||||
common::ObArray<common::ObString> zone_set_ptrs;
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < src_replica_attr_set.zone_set_.count(); ++j) {
|
||||
const common::ObZone &zone = src_replica_attr_set.zone_set_.at(j);
|
||||
if (OB_FAIL(zone_set_ptrs.push_back(common::ObString(zone.size(), zone.ptr())))) {
|
||||
LOG_WARN("fail to push back", K(ret));
|
||||
} else {} // no more to do
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(schema_->deep_copy_string_array(zone_set_ptrs, this_schema_set->zone_set_))) {
|
||||
LOG_WARN("fail to copy schema replica attr set zone set", K(ret));
|
||||
} else {
|
||||
this_schema_set->zone_ = src_replica_attr_set.zone_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocality::assign(const ObLocality &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(schema_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(schema_));
|
||||
} else if (OB_FAIL(schema_->deep_copy_str(other.locality_str_, locality_str_))) {
|
||||
LOG_WARN("fail to assign locality info", K(ret));
|
||||
} else if (OB_FAIL(set_zone_replica_attr_array(other.zone_replica_attr_array_))) {
|
||||
LOG_WARN("set zone replica attr array failed", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLocality::set_locality_str(const ObString &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(schema_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(schema_));
|
||||
} else if (OB_FAIL(schema_->deep_copy_str(other, locality_str_))) {
|
||||
LOG_WARN("fail to assign locality info", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t ObLocality::get_convert_size() const
|
||||
{
|
||||
int64_t convert_size = sizeof(*this);
|
||||
convert_size += zone_replica_attr_array_.count() * static_cast<int64_t>(sizeof(SchemaZoneReplicaAttrSet));
|
||||
for (int64_t i = 0; i < zone_replica_attr_array_.count(); ++i) {
|
||||
convert_size += zone_replica_attr_array_.at(i).get_convert_size();
|
||||
}
|
||||
convert_size += locality_str_.length() + 1;
|
||||
return convert_size;
|
||||
}
|
||||
|
||||
void ObLocality::reset()
|
||||
{
|
||||
if (OB_ISNULL(schema_)) {
|
||||
LOG_ERROR_RET(OB_ERR_UNEXPECTED, "invalid schema info", K(schema_));
|
||||
} else {
|
||||
reset_zone_replica_attr_array();
|
||||
if (!OB_ISNULL(locality_str_.ptr())) {
|
||||
schema_->free(locality_str_.ptr());
|
||||
}
|
||||
locality_str_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
OB_DEF_SERIALIZE(ObLocality)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
LST_DO_CODE(OB_UNIS_ENCODE, locality_str_);
|
||||
if (OB_FAIL(ret)) {
|
||||
LOG_WARN("func_SERIALIZE failed", K(ret));
|
||||
} else {} // no more to do
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_DEF_DESERIALIZE(ObLocality)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObString locality;
|
||||
LST_DO_CODE(OB_UNIS_DECODE, locality);
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_ISNULL(schema_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get invalid schema_ info", K(ret), K(schema_));
|
||||
} else if (OB_FAIL(schema_->deep_copy_str(locality, locality_str_))) {
|
||||
LOG_WARN("fail to deep copy str", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_DEF_SERIALIZE_SIZE(ObLocality)
|
||||
{
|
||||
int64_t len = 0;
|
||||
LST_DO_CODE(OB_UNIS_ADD_LEN, locality_str_);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------
|
||||
* ------------------------------ObPrimaryZone-------------------------------------------
|
||||
|
@ -1413,7 +1413,6 @@ typedef common::ObArray<ObZoneScore> ObPrimaryZoneArray;
|
||||
class ObSchema
|
||||
{
|
||||
public:
|
||||
friend class ObLocality;
|
||||
friend class ObPrimaryZone;
|
||||
ObSchema();
|
||||
//explicit ObSchema(common::ObDataBuffer &buffer);
|
||||
@ -1530,31 +1529,6 @@ struct SchemaObj
|
||||
TO_STRING_KV(K_(schema_type), K_(tenant_id), K_(schema_id), KP_(schema));
|
||||
};
|
||||
|
||||
class ObLocality
|
||||
{
|
||||
OB_UNIS_VERSION(1);
|
||||
public:
|
||||
explicit ObLocality(ObSchema *schema) : schema_(schema) {}
|
||||
int assign(const ObLocality &other);
|
||||
int set_locality_str(const common::ObString &locality);
|
||||
int set_zone_replica_attr_array(
|
||||
const common::ObIArray<share::ObZoneReplicaAttrSet> &src);
|
||||
int set_zone_replica_attr_array(
|
||||
const common::ObIArray<share::SchemaZoneReplicaAttrSet> &src);
|
||||
int set_specific_replica_attr_array(
|
||||
share::SchemaReplicaAttrArray &schema_replica_set,
|
||||
const common::ObIArray<ReplicaAttr> &src);
|
||||
void reset_zone_replica_attr_array();
|
||||
int64_t get_convert_size() const;
|
||||
inline const common::ObString &get_locality_str() const { return locality_str_; }
|
||||
void reset();
|
||||
TO_STRING_KV(K_(locality_str), K_(zone_replica_attr_array));
|
||||
public:
|
||||
common::ObString locality_str_;
|
||||
ZoneLocalityArray zone_replica_attr_array_;
|
||||
ObSchema *schema_;
|
||||
};
|
||||
|
||||
class ObPrimaryZone
|
||||
{
|
||||
OB_UNIS_VERSION(1);
|
||||
|
@ -212,7 +212,7 @@ int ObTableSchemaParam::convert(const ObTableSchema *schema)
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(tmp_cols_index.push_back(col_index))) {
|
||||
LOG_WARN("fail to push_back col_index", K(ret));
|
||||
} else if (use_cs && OB_FAIL(schema->get_column_group_index(*column, cg_idx))) {
|
||||
} else if (use_cs && OB_FAIL(schema->get_column_group_index(*column, false /*need_calculate_cg_idx*/, cg_idx))) {
|
||||
LOG_WARN("Fail to get column group index", K(ret));
|
||||
} else if (use_cs && OB_FAIL(tmp_cg_idxs.push_back(cg_idx))) {
|
||||
LOG_WARN("Fail to push back cg idx", K(ret));
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "observer/ob_server.h"
|
||||
#include "storage/ob_storage_schema.h"
|
||||
#include "storage/access/ob_table_read_info.h"
|
||||
#include "storage/column_store/ob_column_store_replica_util.h"
|
||||
#include "share/ob_lob_access_utils.h"
|
||||
|
||||
namespace oceanbase
|
||||
@ -916,7 +917,8 @@ int ObTableParam::construct_columns_and_projector(
|
||||
const common::ObIArray<uint64_t> & output_column_ids,
|
||||
const common::ObIArray<uint64_t> *tsc_out_cols,
|
||||
const bool force_mysql_mode,
|
||||
const sql::ObStoragePushdownFlag &pd_pushdown_flag)
|
||||
const sql::ObStoragePushdownFlag &pd_pushdown_flag,
|
||||
const bool query_cs_replica /*=false*/)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
static const int64_t COMMON_COLUMN_NUM = 16;
|
||||
@ -933,22 +935,19 @@ int ObTableParam::construct_columns_and_projector(
|
||||
bool is_cs = false;
|
||||
bool has_all_column_group = false;
|
||||
int64_t rowkey_count = 0;
|
||||
is_column_replica_table_ = false; // row store table schema does not contains cg, if true, need calculate cg idx by designed rules
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
bool is_table_row_store = false;
|
||||
if (OB_FAIL(table_schema.get_is_row_store(is_table_row_store))) {
|
||||
LOG_WARN("fail to get is talbe row store", K(ret));
|
||||
} else {
|
||||
is_cs = !is_table_row_store;
|
||||
}
|
||||
if (OB_FAIL(table_schema.get_is_column_store(is_cs))) {
|
||||
LOG_WARN("fail to get is table column store", K(ret), K(table_schema));
|
||||
} else if (!is_cs && query_cs_replica) {
|
||||
is_cs = true;
|
||||
is_column_replica_table_ = true;
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(table_schema.has_all_column_group(has_all_column_group))) {
|
||||
LOG_WARN("Failed to check if has all column group", K(ret));
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
} else {
|
||||
// column array
|
||||
const ObRowkeyInfo &rowkey_info = table_schema.get_rowkey_info();
|
||||
rowkey_count = rowkey_info.get_size();
|
||||
@ -992,7 +991,7 @@ int ObTableParam::construct_columns_and_projector(
|
||||
} else if (OB_FAIL(tmp_access_cols_extend.push_back(tmp_col_extend))) {
|
||||
LOG_WARN("fail to push_back tmp_access_cols_extend", K(ret));
|
||||
} else if (is_cs) {
|
||||
if (OB_FAIL(table_schema.get_column_group_index(*column, cg_idx))) {
|
||||
if (OB_FAIL(table_schema.get_column_group_index(*column, is_column_replica_table_, cg_idx))) {
|
||||
LOG_WARN("Fail to get column group index", K(ret));
|
||||
} else if (OB_FAIL(tmp_cg_idxs.push_back(cg_idx))) {
|
||||
LOG_WARN("Fail to push back cg idx", K(ret));
|
||||
@ -1066,7 +1065,7 @@ int ObTableParam::construct_columns_and_projector(
|
||||
} else if (OB_FAIL(tmp_access_cols_extend.push_back(tmp_col_extend))) {
|
||||
LOG_WARN("fail to push_back tmp_access_cols_extend", K(ret));
|
||||
} else if (is_cs) {
|
||||
if (OB_FAIL(table_schema.get_column_group_index(*column, cg_idx))) {
|
||||
if (OB_FAIL(table_schema.get_column_group_index(*column, is_column_replica_table_, cg_idx))) {
|
||||
LOG_WARN("Fail to get column group index", K(ret));
|
||||
} else if (OB_FAIL(tmp_cg_idxs.push_back(cg_idx))) {
|
||||
LOG_WARN("Fail to push back cg idx", K(ret));
|
||||
@ -1248,7 +1247,8 @@ int ObTableParam::convert(const ObTableSchema &table_schema,
|
||||
const ObIArray<uint64_t> &access_column_ids,
|
||||
const sql::ObStoragePushdownFlag &pd_pushdown_flag,
|
||||
const common::ObIArray<uint64_t> *tsc_out_cols,
|
||||
const bool force_mysql_mode)
|
||||
const bool force_mysql_mode,
|
||||
const bool query_cs_replica /*=false*/)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// if mocked rowid index is used
|
||||
@ -1256,7 +1256,8 @@ int ObTableParam::convert(const ObTableSchema &table_schema,
|
||||
table_id_ = table_schema.get_table_id();
|
||||
bool is_oracle_mode = false;
|
||||
const common::ObIArray<ObColumnParam *> *cols_param = nullptr;
|
||||
if (OB_FAIL(construct_columns_and_projector(table_schema, access_column_ids, tsc_out_cols, force_mysql_mode, pd_pushdown_flag))) {
|
||||
|
||||
if (OB_FAIL(construct_columns_and_projector(table_schema, access_column_ids, tsc_out_cols, force_mysql_mode, pd_pushdown_flag, query_cs_replica))) {
|
||||
LOG_WARN("construct failed", K(ret));
|
||||
} else if (OB_ISNULL(cols_param = main_read_info_.get_columns())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -1546,7 +1547,8 @@ int64_t ObTableParam::to_string(char *buf, const int64_t buf_len) const
|
||||
K_(rowid_projector),
|
||||
K_(enable_lob_locator_v2),
|
||||
K_(is_fts_index),
|
||||
K_(parser_name));
|
||||
K_(parser_name),
|
||||
K_(is_column_replica_table));
|
||||
J_OBJ_END();
|
||||
|
||||
return pos;
|
||||
|
@ -292,7 +292,8 @@ public:
|
||||
const common::ObIArray<uint64_t> &output_column_ids,
|
||||
const sql::ObStoragePushdownFlag &pd_pushdown_flag,
|
||||
const common::ObIArray<uint64_t> *tsc_out_cols = NULL,
|
||||
const bool force_mysql_mode = false);
|
||||
const bool force_mysql_mode = false,
|
||||
const bool query_cs_replica = false);
|
||||
|
||||
// convert aggregate column projector from 'aggregate_column_ids' and 'output_projector_'
|
||||
// convert group by column projector from 'group_by_column_ids' and 'output_projector_'
|
||||
@ -344,7 +345,8 @@ private:
|
||||
const common::ObIArray<uint64_t> &output_column_ids,
|
||||
const common::ObIArray<uint64_t> *tsc_out_cols,
|
||||
const bool force_mysql_mode,
|
||||
const sql::ObStoragePushdownFlag &pd_pushdown_flag);
|
||||
const sql::ObStoragePushdownFlag &pd_pushdown_flag,
|
||||
const bool query_cs_replica = false);
|
||||
|
||||
int filter_common_columns(const common::ObIArray<const ObColumnSchemaV2 *> &columns,
|
||||
common::ObIArray<const ObColumnSchemaV2 *> &new_columns);
|
||||
|
@ -8958,14 +8958,17 @@ int ObTableSchema::is_column_group_exist(const ObString &cg_name, bool &exist) c
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableSchema::get_column_group_index(const share::schema::ObColumnParam ¶m, int32_t &cg_idx) const
|
||||
int ObTableSchema::get_column_group_index(
|
||||
const share::schema::ObColumnParam ¶m,
|
||||
const bool need_calculate_cg_idx,
|
||||
int32_t &cg_idx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t column_id = param.get_column_id();
|
||||
const uint64_t column_id = param.get_column_id();
|
||||
cg_idx = -1;
|
||||
if (OB_UNLIKELY(1 >= column_group_cnt_)) {
|
||||
if (OB_UNLIKELY(1 >= column_group_cnt_ && !need_calculate_cg_idx)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("No column group exist", K(ret), K_(is_column_store_supported), K_(column_group_cnt));
|
||||
LOG_WARN("No column group exist", K(ret), K(need_calculate_cg_idx), K_(is_column_store_supported), K_(column_group_cnt));
|
||||
} else if (param.is_virtual_gen_col()) {
|
||||
cg_idx = -1;
|
||||
} else if (column_id < OB_END_RESERVED_COLUMN_ID_NUM &&
|
||||
@ -8974,7 +8977,9 @@ int ObTableSchema::get_column_group_index(const share::schema::ObColumnParam &pa
|
||||
common::OB_HIDDEN_PK_INCREMENT_COLUMN_ID != column_id) { // this has its own column group now
|
||||
if (common::OB_HIDDEN_TRANS_VERSION_COLUMN_ID == column_id ||
|
||||
common::OB_HIDDEN_SQL_SEQUENCE_COLUMN_ID == column_id) {
|
||||
if (OB_FAIL(get_base_rowkey_column_group_index(cg_idx))) {
|
||||
if (need_calculate_cg_idx) {
|
||||
cg_idx = OB_CS_COLUMN_REPLICA_ROWKEY_CG_IDX;
|
||||
} else if (OB_FAIL(get_base_rowkey_column_group_index(cg_idx))) {
|
||||
LOG_WARN("Fail to get base/rowkey column group index", K(ret), K(column_id));
|
||||
}
|
||||
} else {
|
||||
@ -8984,6 +8989,10 @@ int ObTableSchema::get_column_group_index(const share::schema::ObColumnParam &pa
|
||||
// common::OB_HIDDEN_GROUP_IDX_COLUMN_ID == column_id
|
||||
cg_idx = -1;
|
||||
}
|
||||
} else if (need_calculate_cg_idx) {
|
||||
if (OB_FAIL(calc_column_group_index_(column_id, cg_idx))) {
|
||||
LOG_WARN("Fail to calc_column_group_index", K(ret), K(column_id));
|
||||
}
|
||||
} else {
|
||||
bool found = false;
|
||||
int64_t cg_column_cnt = 0;
|
||||
@ -9018,6 +9027,29 @@ int ObTableSchema::get_column_group_index(const share::schema::ObColumnParam &pa
|
||||
LOG_WARN("Unexpected, can not find cg idx", K(ret), K(column_id));
|
||||
}
|
||||
}
|
||||
LOG_TRACE("[CS-Replica] get column group index", K(ret), K(need_calculate_cg_idx), K(cg_idx));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableSchema::calc_column_group_index_(const uint64_t column_id, int32_t &cg_idx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
cg_idx = -1;
|
||||
// for cs replica, constructed cg schemas start with rowkey cg so the cg idx of row key cg is ALWAYS 0
|
||||
// and cg idx of normal cg is shifted by offset 1.
|
||||
for (int64_t i = 0; i < column_cnt_; i++) {
|
||||
ObColumnSchemaV2 *column = column_array_[i];
|
||||
if (OB_NOT_NULL(column) && column->get_column_id() == column_id) {
|
||||
cg_idx = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_UNLIKELY(-1 == cg_idx)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Unexpected cg idx", K(ret));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -975,6 +975,8 @@ public:
|
||||
inline bool is_mlog_table() const { return is_mlog_table(table_type_); }
|
||||
inline static bool is_mlog_table(share::schema::ObTableType table_type)
|
||||
{ return MATERIALIZED_VIEW_LOG == table_type; }
|
||||
inline static bool is_user_data_table(share::schema::ObTableType table_type)
|
||||
{ return USER_TABLE == table_type; }
|
||||
inline bool is_in_recyclebin() const
|
||||
{ return common::OB_RECYCLEBIN_SCHEMA_ID == database_id_; }
|
||||
virtual inline bool is_external_table() const override { return EXTERNAL_TABLE == table_type_; }
|
||||
@ -1681,8 +1683,9 @@ public:
|
||||
int get_all_cg_type_column_group(const ObColumnGroupSchema *&column_group) const;
|
||||
int get_each_column_group(ObIArray<ObColumnGroupSchema*> &each_cgs) const;
|
||||
int is_partition_key_match_rowkey_prefix(bool &is_prefix) const;
|
||||
int get_column_group_index(const share::schema::ObColumnParam ¶m, int32_t &cg_idx) const;
|
||||
|
||||
int get_column_group_index(const share::schema::ObColumnParam ¶m,
|
||||
const bool need_calculate_cg_idx,
|
||||
int32_t &cg_idx) const;
|
||||
int is_column_group_exist(const common::ObString &cg_name, bool &exist) const;
|
||||
|
||||
int get_all_column_ids(ObIArray<uint64_t> &column_ids) const;
|
||||
@ -1877,6 +1880,7 @@ private:
|
||||
ObRowkeyInfo &rowkey_info);
|
||||
int alter_view_column_internal(ObColumnSchemaV2 &column_schema);
|
||||
int get_base_rowkey_column_group_index(int32_t &cg_idx) const;
|
||||
int calc_column_group_index_(const uint64_t column_id, int32_t &cg_idx) const;
|
||||
|
||||
protected:
|
||||
uint64_t max_used_column_id_;
|
||||
|
@ -62,6 +62,7 @@ const char *ObSysVarObRoutePolicy::OB_ROUTE_POLICY_NAMES[] = {
|
||||
"ONLY_READONLY_ZONE",
|
||||
"UNMERGE_ZONE_FIRST",
|
||||
"UNMERGE_FOLLOWER_FIRST",
|
||||
"COLUMN_STORE_ONLY",
|
||||
0
|
||||
};
|
||||
const char *ObSysVarObEnableJit::OB_ENABLE_JIT_NAMES[] = {
|
||||
|
@ -1852,7 +1852,7 @@ static struct VarsInit{
|
||||
ObSysVars[127].info_ = "the routing policy of obproxy/java client and observer internal retry, 1=READONLY_ZONE_FIRST, 2=ONLY_READONLY_ZONE, 3=UNMERGE_ZONE_FIRST, 4=UNMERGE_FOLLOWER_FIRST" ;
|
||||
ObSysVars[127].name_ = "ob_route_policy" ;
|
||||
ObSysVars[127].data_type_ = ObIntType ;
|
||||
ObSysVars[127].enum_names_ = "[u'', u'READONLY_ZONE_FIRST', u'ONLY_READONLY_ZONE', u'UNMERGE_ZONE_FIRST', u'UNMERGE_FOLLOWER_FIRST']" ;
|
||||
ObSysVars[127].enum_names_ = "[u'', u'READONLY_ZONE_FIRST', u'ONLY_READONLY_ZONE', u'UNMERGE_ZONE_FIRST', u'UNMERGE_FOLLOWER_FIRST', u'COLUMN_STORE_ONLY']" ;
|
||||
ObSysVars[127].flags_ = ObSysVarFlag::GLOBAL_SCOPE | ObSysVarFlag::SESSION_SCOPE | ObSysVarFlag::INFLUENCE_PLAN | ObSysVarFlag::NEED_SERIALIZE ;
|
||||
ObSysVars[127].id_ = SYS_VAR_OB_ROUTE_POLICY ;
|
||||
cur_max_var_id = MAX(cur_max_var_id, static_cast<int64_t>(SYS_VAR_OB_ROUTE_POLICY)) ;
|
||||
|
@ -1844,7 +1844,8 @@
|
||||
"READONLY_ZONE_FIRST",
|
||||
"ONLY_READONLY_ZONE",
|
||||
"UNMERGE_ZONE_FIRST",
|
||||
"UNMERGE_FOLLOWER_FIRST"
|
||||
"UNMERGE_FOLLOWER_FIRST",
|
||||
"COLUMN_STORE_ONLY"
|
||||
],
|
||||
"publish_version": "",
|
||||
"info_cn": "",
|
||||
|
@ -1036,7 +1036,7 @@ public:
|
||||
schema_version_(common::OB_INVALID_VERSION),
|
||||
tablet_id_(common::ObTabletID::INVALID_TABLET_ID),
|
||||
role_(common::ObRole::INVALID_ROLE),
|
||||
replica_type_(common::ObReplicaType::REPLICA_TYPE_MAX),
|
||||
replica_type_(common::ObReplicaType::REPLICA_TYPE_INVALID),
|
||||
part_renew_time_(0),
|
||||
reserved_(0)
|
||||
{}
|
||||
|
@ -212,7 +212,10 @@ int ObTscCgService::generate_table_param(const ObLogTableScan &op,
|
||||
const bool pd_agg = scan_ctdef.pd_expr_spec_.pd_storage_flag_.is_aggregate_pushdown();
|
||||
const bool pd_group_by = scan_ctdef.pd_expr_spec_.pd_storage_flag_.is_group_by_pushdown();
|
||||
ObSqlSchemaGuard *schema_guard = cg_.opt_ctx_->get_sql_schema_guard();
|
||||
CK(OB_NOT_NULL(schema_guard));
|
||||
ObBasicSessionInfo *session_info = cg_.opt_ctx_->get_session_info();
|
||||
int64_t route_policy = 0;
|
||||
bool is_cs_replica_query = false;
|
||||
CK(OB_NOT_NULL(schema_guard), OB_NOT_NULL(session_info));
|
||||
if (OB_UNLIKELY(pd_agg && 0 == scan_ctdef.aggregate_column_ids_.count()) ||
|
||||
OB_UNLIKELY(pd_group_by && 0 == scan_ctdef.group_by_column_ids_.count())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
@ -231,6 +234,10 @@ int ObTscCgService::generate_table_param(const ObLogTableScan &op,
|
||||
} else if (table_schema->is_multivalue_index_aux() && FALSE_IT(scan_ctdef.table_param_.set_is_multivalue_index(true))) {
|
||||
} else if (OB_FAIL(extract_das_output_column_ids(op, scan_ctdef, *table_schema, tsc_out_cols))) {
|
||||
LOG_WARN("extract tsc output column ids failed", K(ret));
|
||||
} else if (OB_FAIL(session_info->get_sys_variable(SYS_VAR_OB_ROUTE_POLICY, route_policy))) {
|
||||
LOG_WARN("get route policy failed", K(ret));
|
||||
} else {
|
||||
is_cs_replica_query = ObRoutePolicyType::COLUMN_STORE_ONLY == route_policy;
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
@ -240,7 +247,8 @@ int ObTscCgService::generate_table_param(const ObLogTableScan &op,
|
||||
scan_ctdef.access_column_ids_,
|
||||
scan_ctdef.pd_expr_spec_.pd_storage_flag_,
|
||||
&tsc_out_cols,
|
||||
is_oracle_mapping_real_virtual_table(op.get_ref_table_id())))) {/* for real agent table , use mysql mode compulsory*/
|
||||
is_oracle_mapping_real_virtual_table(op.get_ref_table_id()), /* for real agent table , use mysql mode compulsory*/
|
||||
is_cs_replica_query))) {
|
||||
LOG_WARN("convert schema failed", K(ret), K(*table_schema),
|
||||
K(scan_ctdef.access_column_ids_), K(op.get_index_back()));
|
||||
} else if ((pd_agg || pd_group_by) &&
|
||||
@ -1080,9 +1088,12 @@ int ObTscCgService::generate_table_loc_meta(uint64_t table_loc_id,
|
||||
loc_meta.is_external_files_on_disk_ =
|
||||
ObSQLUtils::is_external_files_on_local_disk(table_schema.get_external_file_location());
|
||||
bool is_weak_read = false;
|
||||
int64_t route_policy = 0;
|
||||
if (OB_ISNULL(cg_.opt_ctx_) || OB_ISNULL(cg_.opt_ctx_->get_exec_ctx())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(cg_.opt_ctx_), K(ret));
|
||||
} else if (OB_FAIL(session.get_sys_variable(SYS_VAR_OB_ROUTE_POLICY, route_policy))) {
|
||||
LOG_WARN("get route policy failed", K(ret));
|
||||
} else if (stmt.get_query_ctx()->has_dml_write_stmt_) {
|
||||
loc_meta.select_leader_ = 1;
|
||||
loc_meta.is_weak_read_ = 0;
|
||||
@ -1101,6 +1112,7 @@ int ObTscCgService::generate_table_loc_meta(uint64_t table_loc_id,
|
||||
loc_meta.select_leader_ = 1;
|
||||
loc_meta.is_weak_read_ = 0;
|
||||
}
|
||||
loc_meta.route_policy_ = route_policy;
|
||||
if (OB_SUCC(ret) && !table_schema.is_global_index_table()) {
|
||||
TableLocRelInfo *rel_info = nullptr;
|
||||
ObTableID data_table_id = table_schema.is_index_table() && !table_schema.is_rowkey_doc_id() ?
|
||||
|
@ -792,7 +792,8 @@ ObDASLocationRouter::~ObDASLocationRouter()
|
||||
|
||||
int ObDASLocationRouter::nonblock_get_readable_replica(const uint64_t tenant_id,
|
||||
const ObTabletID &tablet_id,
|
||||
ObDASTabletLoc &tablet_loc)
|
||||
ObDASTabletLoc &tablet_loc,
|
||||
const ObRoutePolicyType route_policy)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLSLocation ls_loc;
|
||||
@ -836,7 +837,10 @@ int ObDASLocationRouter::nonblock_get_readable_replica(const uint64_t tenant_id,
|
||||
} else if (OB_FAIL(ObBLService::get_instance().check_in_black_list(bl_key, in_black_list))) {
|
||||
LOG_WARN("check in black list failed", K(ret));
|
||||
} else if (!in_black_list) {
|
||||
if (tmp_replica_loc.get_server() == GCTX.self_addr()) {
|
||||
if (route_policy == COLUMN_STORE_ONLY && tmp_replica_loc.get_replica_type() != REPLICA_TYPE_COLUMNSTORE) {
|
||||
// skip the tmp_replica_loc
|
||||
LOG_TRACE("skip the replica due to the COLUMN_STORE_ONLY policy.", K(ret), K(tmp_replica_loc));
|
||||
} else if (tmp_replica_loc.get_server() == GCTX.self_addr()) {
|
||||
//prefer choose the local replica
|
||||
local_replica = &tmp_replica_loc;
|
||||
} else if (OB_FAIL(remote_replicas.push_back(&tmp_replica_loc))) {
|
||||
@ -849,6 +853,10 @@ int ObDASLocationRouter::nonblock_get_readable_replica(const uint64_t tenant_id,
|
||||
if (OB_SUCC(ret)) {
|
||||
if (local_replica != nullptr) {
|
||||
tablet_loc.server_ = local_replica->get_server();
|
||||
} else if (route_policy == COLUMN_STORE_ONLY && remote_replicas.empty()) {
|
||||
//do not retry
|
||||
ret = OB_NO_REPLICA_VALID;
|
||||
LOG_USER_ERROR(OB_NO_REPLICA_VALID);
|
||||
} else if (remote_replicas.empty()) {
|
||||
ret = OB_NO_READABLE_REPLICA;
|
||||
LOG_WARN("there has no readable replica", K(ret), K(tablet_id), K(ls_loc));
|
||||
@ -972,7 +980,8 @@ int ObDASLocationRouter::get_tablet_loc(const ObDASTableLocMeta &loc_meta,
|
||||
//if this statement is retried because of OB_NOT_MASTER, we will choose the leader directly
|
||||
ret = nonblock_get_leader(tenant_id, tablet_id, tablet_loc);
|
||||
} else {
|
||||
ret = nonblock_get_readable_replica(tenant_id, tablet_id, tablet_loc);
|
||||
ret = nonblock_get_readable_replica(tenant_id, tablet_id, tablet_loc,
|
||||
static_cast<ObRoutePolicyType>(loc_meta.route_policy_));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "share/schema/ob_schema_struct.h"
|
||||
#include "lib/container/ob_fixed_array.h"
|
||||
#include "sql/das/ob_das_define.h"
|
||||
#include "sql/optimizer/ob_route_policy.h"
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace common
|
||||
@ -346,7 +347,8 @@ private:
|
||||
share::ObLSLocation &location);
|
||||
int nonblock_get_readable_replica(const uint64_t tenant_id,
|
||||
const common::ObTabletID &tablet_id,
|
||||
ObDASTabletLoc &tablet_loc);
|
||||
ObDASTabletLoc &tablet_loc,
|
||||
const ObRoutePolicyType route_policy);
|
||||
private:
|
||||
int last_errno_;
|
||||
int cur_errno_;
|
||||
|
@ -34,7 +34,7 @@ int ObIntersectRoutePolicy::init_candidate_replicas(const ObList<common::ObAddr,
|
||||
auto server_iter = candidate_server_list.begin();
|
||||
CandidateReplica candi_replica;
|
||||
for (; OB_SUCC(ret) && server_iter != candidate_server_list.end(); ++server_iter) {
|
||||
candi_replica.set_replica_type(REPLICA_TYPE_MAX);//fixme(hanting) : ignore replica type for mv
|
||||
candi_replica.set_replica_type(REPLICA_TYPE_INVALID);//fixme(hanting) : ignore replica type for mv
|
||||
candi_replica.set_server(*server_iter);
|
||||
if (OB_FAIL(init_candidate_replica(server_locality_array_, candi_replica))) {
|
||||
LOG_WARN("fail to init candidate replica", K(server_locality_array_), K(candi_replica), K(ret));
|
||||
|
@ -1932,6 +1932,7 @@ int ObJoinOrder::init_column_store_est_info(const uint64_t table_id,
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect null plan", K(ret));
|
||||
} else if (OB_FAIL(get_plan()->will_use_column_store(OB_INVALID_ID,
|
||||
ref_id,
|
||||
ref_id,
|
||||
index_back_will_use_column_store,
|
||||
index_back_will_use_row_store))) {
|
||||
@ -2808,6 +2809,7 @@ int ObJoinOrder::create_access_paths(const uint64_t table_id,
|
||||
LOG_WARN("failed to check will use skip scan", K(ret));
|
||||
} else if (OB_FAIL(get_plan()->will_use_column_store(table_id,
|
||||
valid_index_ids.at(i),
|
||||
ref_table_id,
|
||||
use_column_store,
|
||||
use_row_store))) {
|
||||
LOG_WARN("failed to check will use column store", K(ret));
|
||||
@ -10891,6 +10893,7 @@ int ObJoinOrder::find_possible_join_filter_tables(const ObLogPlanHint &log_plan_
|
||||
info.use_column_store_ = true;
|
||||
} else if (OB_FAIL(get_plan()->will_use_column_store(info.table_id_,
|
||||
info.index_id_,
|
||||
info.ref_table_id_,
|
||||
will_use_column_store,
|
||||
will_use_row_store))) {
|
||||
LOG_WARN("failed to check will use column store", K(ret));
|
||||
|
@ -630,12 +630,16 @@ int ObLogPlan::mock_base_rel_detectors(ObJoinOrder *&base_rel)
|
||||
int ObLogPlan::select_location(ObIArray<ObTablePartitionInfo *> &tbl_part_info_list)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t route_policy = 0;
|
||||
ObExecContext *exec_ctx = optimizer_context_.get_exec_ctx();
|
||||
ObSEArray<const ObTableLocation*, 1> tbl_loc_list;
|
||||
ObSEArray<ObCandiTableLoc*, 1> phy_tbl_loc_info_list;
|
||||
if (OB_ISNULL(exec_ctx)) {
|
||||
ObSQLSessionInfo* session_info = optimizer_context_.get_session_info();
|
||||
if (OB_ISNULL(exec_ctx) || OB_ISNULL(session_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("exec ctx is NULL", K(ret));
|
||||
} else if (OB_FAIL(session_info->get_sys_variable(SYS_VAR_OB_ROUTE_POLICY, route_policy))) {
|
||||
LOG_WARN("get route policy failed", K(ret));
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < tbl_part_info_list.count(); ++i) {
|
||||
ObTablePartitionInfo *tbl_part_info = tbl_part_info_list.at(i);
|
||||
@ -649,6 +653,8 @@ int ObLogPlan::select_location(ObIArray<ObTablePartitionInfo *> &tbl_part_info_l
|
||||
&tbl_part_info->get_phy_tbl_location_info_for_update()))) {
|
||||
LOG_WARN("fail to push back phy tble loc info",
|
||||
K(ret), K(tbl_part_info->get_phy_tbl_location_info_for_update()));
|
||||
} else {
|
||||
tbl_part_info->get_table_location().get_loc_meta().route_policy_ = route_policy;
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
@ -742,6 +748,9 @@ int ObLogPlan::select_replicas(ObExecContext &exec_ctx,
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (COLUMN_STORE_ONLY == route_policy_type) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "when route policy is COLUMN_STORE_ONLY, weak read request");
|
||||
} else {
|
||||
const bool sess_in_retry = session->get_is_in_retry_for_dup_tbl(); //重试状态下不优化复制表的副本选择
|
||||
if (OB_FAIL(ObLogPlan::strong_select_replicas(local_server, phy_tbl_loc_info_list, is_hit_partition, sess_in_retry))) {
|
||||
@ -13202,6 +13211,7 @@ int ObLogPlan::find_possible_join_filter_tables(ObLogicalOperator *op,
|
||||
info.use_column_store_ = true;
|
||||
} else if (OB_FAIL(will_use_column_store(info.table_id_,
|
||||
info.index_id_,
|
||||
info.ref_table_id_,
|
||||
use_column_store,
|
||||
use_row_store))) {
|
||||
LOG_WARN("failed to check will use column store", K(ret));
|
||||
@ -13359,6 +13369,7 @@ int ObLogPlan::find_possible_join_filter_tables(ObLogicalOperator *op,
|
||||
|
||||
int ObLogPlan::will_use_column_store(const uint64_t table_id,
|
||||
const uint64_t index_id,
|
||||
const uint64_t ref_table_id,
|
||||
bool &use_column_store,
|
||||
bool &use_row_store)
|
||||
{
|
||||
@ -13378,6 +13389,10 @@ int ObLogPlan::will_use_column_store(const uint64_t table_id,
|
||||
OB_ISNULL(session_info=get_optimizer_context().get_session_info())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("NULL pointer error", K(stmt), K(schema_guard), K(ret));
|
||||
} else if (get_optimizer_context().use_column_store_replica() &&
|
||||
index_id == ref_table_id) {
|
||||
use_column_store = true;
|
||||
use_row_store = false;
|
||||
} else if (OB_FALSE_IT(session_disable_column_store=!session_info->is_enable_column_store())) {
|
||||
} else if (OB_FALSE_IT(is_link=ObSqlSchemaGuard::is_link_table(stmt, table_id))) {
|
||||
} else if (is_link) {
|
||||
|
@ -1396,6 +1396,7 @@ public:
|
||||
|
||||
int will_use_column_store(const uint64_t table_id,
|
||||
const uint64_t index_id,
|
||||
const uint64_t ref_table_id,
|
||||
bool &use_column_store,
|
||||
bool &use_row_store);
|
||||
|
||||
|
@ -543,6 +543,8 @@ int ObOptimizer::init_env_info(ObDMLStmt &stmt)
|
||||
LOG_WARN("fail to check enable pdml", K(ret));
|
||||
} else if (OB_FAIL(init_parallel_policy(stmt, *session_info))) { // call after check pdml enabled
|
||||
LOG_WARN("fail to check enable pdml", K(ret));
|
||||
} else if (OB_FAIL(init_replica_policy(stmt, *session_info))) {
|
||||
LOG_WARN("fail to check enable column store replica", K(ret));
|
||||
} else if (OB_FAIL(init_correlation_model(stmt, *session_info))) {
|
||||
LOG_WARN("failed to init correlation model", K(ret));
|
||||
}
|
||||
@ -694,6 +696,24 @@ int ObOptimizer::init_parallel_policy(ObDMLStmt &stmt, const ObSQLSessionInfo &s
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObOptimizer::init_replica_policy(ObDMLStmt &dml_stmt, const ObSQLSessionInfo &session)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t route_policy_type = 0;
|
||||
if (OB_FAIL(session.get_sys_variable(SYS_VAR_OB_ROUTE_POLICY, route_policy_type))) {
|
||||
LOG_WARN("fail to get sys variable", K(ret));
|
||||
} else if (COLUMN_STORE_ONLY == static_cast<ObRoutePolicyType>(route_policy_type)) {
|
||||
if (dml_stmt.get_query_ctx()->has_dml_write_stmt_ ||
|
||||
dml_stmt.get_query_ctx()->is_contain_select_for_update_) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "when route policy is COLUMN_STORE_ONLY, read query request");
|
||||
} else {
|
||||
ctx_.set_use_column_store_replica(true);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObOptimizer::init_correlation_model(ObDMLStmt &stmt, const ObSQLSessionInfo &session)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -203,6 +203,7 @@ namespace sql
|
||||
int extract_opt_ctx_basic_flags(const ObDMLStmt &stmt,
|
||||
ObSQLSessionInfo &session);
|
||||
int init_parallel_policy(ObDMLStmt &stmt, const ObSQLSessionInfo &session);
|
||||
int init_replica_policy(ObDMLStmt &stmt, const ObSQLSessionInfo &session);
|
||||
int set_auto_dop_params(const ObSQLSessionInfo &session);
|
||||
int check_pdml_enabled(const ObDMLStmt &stmt,
|
||||
const ObSQLSessionInfo &session);
|
||||
|
@ -244,7 +244,8 @@ ObOptimizerContext(ObSQLSessionInfo *session_info,
|
||||
storage_estimation_enabled_(false),
|
||||
das_keep_order_enabled_(true),
|
||||
generate_random_plan_(false),
|
||||
correlation_type_(ObEstCorrelationType::MAX)
|
||||
correlation_type_(ObEstCorrelationType::MAX),
|
||||
use_column_store_replica_(false)
|
||||
{ }
|
||||
inline common::ObOptStatManager *get_opt_stat_manager() { return opt_stat_manager_; }
|
||||
inline void set_opt_stat_manager(common::ObOptStatManager *sm) { opt_stat_manager_ = sm; }
|
||||
@ -618,6 +619,8 @@ ObOptimizerContext(ObSQLSessionInfo *session_info,
|
||||
inline const OptSystemStat& get_system_stat() const { return system_stat_; }
|
||||
inline bool generate_random_plan() const { return generate_random_plan_; }
|
||||
inline void set_generate_random_plan(bool rand_plan) { generate_random_plan_ = rand_plan; }
|
||||
inline bool use_column_store_replica() const { return use_column_store_replica_; }
|
||||
inline void set_use_column_store_replica(bool use) { use_column_store_replica_ = use; }
|
||||
|
||||
inline void set_correlation_type(ObEstCorrelationType type) { correlation_type_ = type; }
|
||||
inline ObEstCorrelationType get_correlation_type() const { return correlation_type_; }
|
||||
@ -708,6 +711,7 @@ private:
|
||||
|
||||
bool generate_random_plan_;
|
||||
ObEstCorrelationType correlation_type_;
|
||||
bool use_column_store_replica_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,13 @@ ObReplicaCompare::ObReplicaCompare(ObRoutePolicyType policy_type)
|
||||
policy_type_(policy_type),
|
||||
readonly_zone_first_{IS_OTHER_REGION, ZONE_TYPE, MERGE_STATUS, POS_TYPE},
|
||||
only_readonly_zone_{ZONE_TYPE, IS_OTHER_REGION, MERGE_STATUS, POS_TYPE,},
|
||||
unmerge_zone_first_{IS_OTHER_REGION, MERGE_STATUS, ZONE_TYPE, POS_TYPE}
|
||||
unmerge_zone_first_{IS_OTHER_REGION, MERGE_STATUS, ZONE_TYPE, POS_TYPE},
|
||||
column_store_only_{ZONE_TYPE, IS_OTHER_REGION, MERGE_STATUS, POS_TYPE}
|
||||
{
|
||||
static_assert(sizeof(readonly_zone_first_) == sizeof(only_readonly_zone_), "invalid array size");
|
||||
static_assert(sizeof(readonly_zone_first_) == sizeof(unmerge_zone_first_), "invalid array size");
|
||||
static_assert((sizeof(readonly_zone_first_)/sizeof(CompareType)) == (sizeof(cmp_func_array_)/sizeof(CmpFuncPtr)), "invalid array size");
|
||||
static_assert(sizeof(readonly_zone_first_) == sizeof(column_store_only_), "invalid array size");
|
||||
|
||||
cmp_func_array_[IS_OTHER_REGION] = &ObReplicaCompare::compare_other_region;
|
||||
cmp_func_array_[ZONE_TYPE] = &ObReplicaCompare::compare_zone_type;
|
||||
@ -50,6 +52,8 @@ bool ObReplicaCompare::operator()(const ObRoutePolicy::CandidateReplica &replica
|
||||
cmp_type_array = only_readonly_zone_;
|
||||
} else if (UNMERGE_ZONE_FIRST == policy_type_) {
|
||||
cmp_type_array = unmerge_zone_first_;
|
||||
} else if (COLUMN_STORE_ONLY == policy_type_) {
|
||||
cmp_type_array = column_store_only_;
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected policy type", K(policy_type_), K(ret));
|
||||
|
@ -59,6 +59,7 @@ private:
|
||||
CompareType readonly_zone_first_[CMP_CNT];
|
||||
CompareType only_readonly_zone_[CMP_CNT];
|
||||
CompareType unmerge_zone_first_[CMP_CNT];
|
||||
CompareType column_store_only_[CMP_CNT];
|
||||
};
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "sql/optimizer/ob_phy_table_location_info.h"
|
||||
#include "sql/optimizer/ob_log_plan.h"
|
||||
#include "storage/ob_locality_manager.h"
|
||||
#include "lib/ob_define.h"
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::share;
|
||||
using namespace oceanbase::storage;
|
||||
@ -82,6 +83,8 @@ int ObRoutePolicy::filter_replica(const ObAddr &local_server,
|
||||
} else {
|
||||
LOG_TRACE("check ls readable", K(ctx), K(ls_id), K(cur_replica.get_server()), K(can_read));
|
||||
if ((policy_type == ONLY_READONLY_ZONE && cur_replica.attr_.zone_type_ == ZONE_TYPE_READWRITE)
|
||||
|| (policy_type == COLUMN_STORE_ONLY && !ObReplicaTypeCheck::is_columnstore_replica(cur_replica.get_replica_type()))
|
||||
|| (policy_type != COLUMN_STORE_ONLY && ObReplicaTypeCheck::is_columnstore_replica(cur_replica.get_replica_type()))
|
||||
|| cur_replica.attr_.zone_status_ == ObZoneStatus::INACTIVE
|
||||
|| cur_replica.attr_.server_status_ != ObServerStatus::OB_SERVER_ACTIVE
|
||||
|| cur_replica.attr_.start_service_time_ == 0
|
||||
@ -102,6 +105,18 @@ int ObRoutePolicy::filter_replica(const ObAddr &local_server,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && policy_type == COLUMN_STORE_ONLY) {
|
||||
for (int64_t i = candi_replicas.count()-1; OB_SUCC(ret) && i >= 0; --i) {
|
||||
CandidateReplica &cur_replica = candi_replicas.at(i);
|
||||
if (cur_replica.is_filter_ && OB_FAIL(candi_replicas.remove(i))) {
|
||||
LOG_WARN("failed to remove filted replica", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && candi_replicas.count() == 0) {
|
||||
ret = OB_NO_REPLICA_VALID;
|
||||
LOG_USER_ERROR(OB_NO_REPLICA_VALID);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ enum ObRoutePolicyType
|
||||
// 即使客户端将请求路由到partition主上, 也在本地执行,
|
||||
// 区别在于返回给OCJ && ObProxy的反馈不同;
|
||||
UNMERGE_FOLLOWER_FIRST = 4,
|
||||
COLUMN_STORE_ONLY = 5,
|
||||
POLICY_TYPE_MAX
|
||||
};
|
||||
|
||||
@ -228,7 +229,9 @@ protected:
|
||||
// 集群为读写zone时, 且ob_route_policy为UNMERGE_FOLLOWER_FIRST时,同样按照READONLY_ZONE_FIRST处理, 但会增加反馈内容
|
||||
// 集群为有只读zone时,且ob_route_policy为UNMERGE_FOLLOWER_FIRST时, 同样按照READONLY_ZONE_FIRST处理,此时不会增加反馈内容
|
||||
ObRoutePolicyType type = INVALID_POLICY;
|
||||
if (has_readonly_zone_) {
|
||||
if (COLUMN_STORE_ONLY == ctx.policy_type_) {
|
||||
type = ctx.policy_type_;
|
||||
} else if (has_readonly_zone_) {
|
||||
if (UNMERGE_FOLLOWER_FIRST == ctx.policy_type_) {
|
||||
type = READONLY_ZONE_FIRST;
|
||||
} else {
|
||||
|
@ -1386,6 +1386,19 @@ int ObTableLocation::get_is_weak_read(const ObDMLStmt &dml_stmt,
|
||||
is_weak_read = (ObTxConsistencyType::BOUNDED_STALENESS_READ == trans_consistency_type);
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && !is_weak_read) {
|
||||
int64_t route_policy_type = 0;
|
||||
if (OB_FAIL(session->get_sys_variable(SYS_VAR_OB_ROUTE_POLICY, route_policy_type))) {
|
||||
LOG_WARN("fail to get sys variable", K(ret));
|
||||
} else if (COLUMN_STORE_ONLY == static_cast<ObRoutePolicyType>(route_policy_type)) {
|
||||
if (dml_stmt.get_query_ctx()->is_contain_inner_table_) {
|
||||
is_weak_read = true;
|
||||
} else {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "when route policy is COLUMN_STORE_ONLY, weak read request");
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "common/ob_region.h"
|
||||
#include "lib/string/ob_sql_string.h"
|
||||
#include "share/schema/ob_schema_getter_guard.h"
|
||||
#include "share/ob_locality_parser.h"
|
||||
#include "share/ob_time_utility2.h"
|
||||
#include "share/ob_encryption_util.h"
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
@ -142,8 +141,40 @@ int ObAlterSystemResolverUtil::resolve_replica_type(const ParseNode *parse_tree,
|
||||
} else {
|
||||
int64_t len = parse_tree->str_len_;
|
||||
const char *str = parse_tree->str_value_;
|
||||
if (OB_FAIL(ObLocalityParser::parse_type(str, len, replica_type))) {
|
||||
// do nothing, error log will print inside parse_type
|
||||
if (OB_ISNULL(str)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid replica type string. null!", K(ret));
|
||||
LOG_USER_ERROR(OB_INVALID_ARGUMENT, "replica_type, replica_type should not be null");
|
||||
} else {
|
||||
replica_type = share::ObShareUtil::string_to_replica_type(str);
|
||||
if (REPLICA_TYPE_INVALID == replica_type) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid replica type string", K(str), K(ret));
|
||||
LOG_USER_ERROR(OB_INVALID_ARGUMENT, "replica_type, unrecognized replica_type");
|
||||
} else if (! ObReplicaTypeCheck::is_replica_type_valid(replica_type)) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
char err_msg[64] = {0};
|
||||
(void)snprintf(err_msg, sizeof(err_msg), "%s replica", ObShareUtil::replica_type_to_string(replica_type));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, err_msg);
|
||||
} else {
|
||||
// good, valid replica_type
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObAlterSystemResolverUtil::check_compatibility_for_replica_type(const ObReplicaType replica_type, const uint64_t tenant_id)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (ObReplicaTypeCheck::is_columnstore_replica(replica_type)) {
|
||||
bool is_compatible = false;
|
||||
if (OB_FAIL(ObShareUtil::check_compat_version_for_columnstore_replica(tenant_id, is_compatible))) {
|
||||
LOG_WARN("failed to check compat version for C-replcia", KR(ret), K(tenant_id));
|
||||
} else if (OB_UNLIKELY(!is_compatible)) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("data_version lower than 4.3.3, C-replica not supported");
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "data_version is lower than 4.3.3, C-replica");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -2984,7 +3015,7 @@ int ObAddLSReplicaResolver::resolve(const ParseNode &parse_tree)
|
||||
|
||||
int64_t ls_id = 0;
|
||||
common::ObAddr server_addr;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_MAX;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_INVALID;
|
||||
common::ObAddr data_source;
|
||||
int64_t paxos_replica_num = 0;
|
||||
uint64_t tenant_id = OB_INVALID_TENANT_ID;
|
||||
@ -3000,6 +3031,8 @@ int ObAddLSReplicaResolver::resolve(const ParseNode &parse_tree)
|
||||
LOG_WARN("resolve server failed", KR(ret), KP(server_addr_node));
|
||||
} else if (OB_FAIL(Util::resolve_replica_type(replica_type_node, replica_type))) {
|
||||
LOG_WARN("resolve replica type failed", KR(ret), KP(replica_type_node));
|
||||
} else if (OB_FAIL(Util::check_compatibility_for_replica_type(replica_type, tenant_id))) {
|
||||
LOG_WARN("check compatibility for replica_type failed", KR(ret), K(replica_type), K(tenant_id));
|
||||
} else if (OB_FAIL(Util::check_and_get_data_source(data_source_node, data_source))) {
|
||||
LOG_WARN("check and get data source failed", KR(ret), KP(data_source_node));
|
||||
} else if (OB_FAIL(Util::check_and_get_paxos_replica_num(paxos_replica_num_node, paxos_replica_num))) {
|
||||
@ -3178,7 +3211,7 @@ int ObModifyLSReplicaResolver::resolve(const ParseNode &parse_tree)
|
||||
ParseNode *tenant_name_node = parse_tree.children_[4];
|
||||
int64_t ls_id = 0;
|
||||
common::ObAddr server_addr;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_MAX;
|
||||
common::ObReplicaType replica_type = REPLICA_TYPE_INVALID;
|
||||
int64_t paxos_replica_num = 0;
|
||||
uint64_t tenant_id = OB_INVALID_TENANT_ID;
|
||||
if (OB_FAIL(Util::do_check_for_alter_ls_replica(tenant_name_node,
|
||||
@ -3193,6 +3226,8 @@ int ObModifyLSReplicaResolver::resolve(const ParseNode &parse_tree)
|
||||
LOG_WARN("resolve server failed", KR(ret), KP(server_addr_node));
|
||||
} else if (OB_FAIL(Util::resolve_replica_type(replica_type_node, replica_type))) {
|
||||
LOG_WARN("resolve replica type failed", KR(ret), KP(replica_type_node));
|
||||
} else if (OB_FAIL(Util::check_compatibility_for_replica_type(replica_type, tenant_id))) {
|
||||
LOG_WARN("check compatibility for replica_type failed", KR(ret), K(replica_type), K(tenant_id));
|
||||
} else if (OB_FAIL(Util::check_and_get_paxos_replica_num(paxos_replica_num_node, paxos_replica_num))) {
|
||||
LOG_WARN("check and get paxos replica num failed", KR(ret), KP(paxos_replica_num_node));
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
static int resolve_replica_type(const ParseNode *parse_tree,
|
||||
common::ObReplicaType &replica_type);
|
||||
static int check_compatibility_for_replica_type(const ObReplicaType replica_type, const uint64_t tenant_id);
|
||||
static int resolve_memstore_percent(const ParseNode *parse_tree,
|
||||
ObReplicaProperty &replica_property);
|
||||
static int resolve_string(const ParseNode *parse_tree, common::ObString &string);
|
||||
|
@ -106,6 +106,10 @@ int ObResourcePoolOptionResolver<T>::resolve_option(T *stmt, ParseNode *option_n
|
||||
SQL_RESV_LOG(WARN, "invalid replica type option_node", K(ret), K(option_node));
|
||||
} else if (OB_FAIL(ObAlterSystemResolverUtil::resolve_replica_type(option_node->children_[0], type))) {
|
||||
SQL_RESV_LOG(WARN, "fail to resove repilca type", K(ret));
|
||||
} else if (REPLICA_TYPE_FULL != type) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("replica_type of resource pool other than FULL not supported.", KR(ret), K(type));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "replica_type of resource pool other than FULL replica");
|
||||
} else {
|
||||
stmt->set_replica_type(type);
|
||||
}
|
||||
|
@ -235,6 +235,7 @@ ob_set_subtarget(ob_storage high_availability
|
||||
high_availability/ob_ls_block_tx_service.cpp
|
||||
high_availability/ob_storage_ha_diagnose_mgr.cpp
|
||||
high_availability/ob_storage_ha_diagnose_service.cpp
|
||||
high_availability/ob_cs_replica_migration.cpp
|
||||
)
|
||||
|
||||
ob_set_subtarget(ob_storage restore
|
||||
@ -516,6 +517,7 @@ ob_set_subtarget(ob_storage column_store
|
||||
column_store/ob_virtual_cg_scanner.cpp
|
||||
column_store/ob_column_store_util.cpp
|
||||
column_store/ob_cg_group_by_scanner.cpp
|
||||
column_store/ob_column_store_replica_util.cpp
|
||||
)
|
||||
|
||||
ob_set_subtarget(ob_storage access
|
||||
|
@ -59,7 +59,8 @@ ObTableIterParam::ObTableIterParam()
|
||||
auto_split_filter_type_(OB_INVALID_ID),
|
||||
auto_split_filter_(nullptr),
|
||||
auto_split_params_(nullptr),
|
||||
is_tablet_spliting_(false)
|
||||
is_tablet_spliting_(false),
|
||||
is_column_replica_table_(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -111,6 +112,7 @@ void ObTableIterParam::reset()
|
||||
auto_split_filter_ = nullptr;
|
||||
auto_split_params_ = nullptr;
|
||||
is_tablet_spliting_ = false;
|
||||
is_column_replica_table_ = false;
|
||||
ObSSTableIndexFilterFactory::destroy_sstable_index_filter(sstable_index_filter_);
|
||||
}
|
||||
|
||||
@ -316,6 +318,7 @@ int ObTableAccessParam::init(
|
||||
iter_param_.table_scan_opt_.storage_rowsets_size_ = 1;
|
||||
}
|
||||
iter_param_.pushdown_filter_ = scan_param.pd_storage_filters_;
|
||||
iter_param_.is_column_replica_table_ = table_param.is_column_replica_table();
|
||||
// disable blockscan if scan order is KeepOrder(for iterator iterator and table api)
|
||||
// disable blockscan if use index skip scan as no large range to scan
|
||||
if (OB_UNLIKELY(ObQueryFlag::KeepOrder == scan_param.scan_flag_.scan_order_ ||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user