modify the usage of schema guard, release the pin memory

This commit is contained in:
obdev
2023-03-23 05:11:37 +00:00
committed by ob-robot
parent dd3b5c62fd
commit 08f87b82c7
6 changed files with 53 additions and 18 deletions

View File

@ -2915,15 +2915,15 @@ int ObServer::clean_up_invalid_tables_by_tenant(
int tmp_ret = OB_SUCCESS;
ObSchemaGetterGuard schema_guard;
const ObDatabaseSchema *database_schema = NULL;
ObSEArray<const ObTableSchema *, 512> table_schemas;
const int64_t CONNECT_TIMEOUT_VALUE = 50L * 60L * 60L * 1000L * 1000L; //default value is 50hrs
ObArray<uint64_t> table_ids;
obrpc::ObDropTableArg drop_table_arg;
obrpc::ObTableItem table_item;
obrpc::ObCommonRpcProxy *common_rpc_proxy = NULL;
char create_host_str[OB_MAX_HOST_NAME_LENGTH];
if (OB_FAIL(schema_service_.get_tenant_schema_guard(tenant_id, schema_guard))) {
LOG_WARN("fail to get schema guard", K(ret));
} else if (OB_FAIL(schema_guard.get_table_schemas_in_tenant(tenant_id, table_schemas))) {
} else if (OB_FAIL(schema_guard.get_table_ids_in_tenant(tenant_id, table_ids))) {
LOG_WARN("fail to get table schema", K(ret), K(tenant_id));
} else {
ObCTASCleanUp ctas_cleanup(this, true);
@ -2931,11 +2931,19 @@ int ObServer::clean_up_invalid_tables_by_tenant(
drop_table_arg.to_recyclebin_ = false;
common_rpc_proxy = GCTX.rs_rpc_proxy_;
MYADDR.ip_port_to_string(create_host_str, OB_MAX_HOST_NAME_LENGTH);
for (int64_t i = 0; i < table_schemas.count() && OB_SUCC(tmp_ret); i++) {
// only OB_ISNULL(GCTX.session_mgr_) will exit the loop
for (int64_t i = 0; i < table_ids.count() && OB_SUCC(tmp_ret); i++) {
bool is_oracle_mode = false;
const ObTableSchema * table_schema = table_schemas.at(i);
if (OB_ISNULL(table_schema)) {
ret = OB_ERR_UNEXPECTED;
const ObTableSchema *table_schema = NULL;
const uint64_t table_id = table_ids.at(i);
// schema guard cannot be used repeatedly in iterative logic,
// otherwise it will cause a memory hike in schema cache
if (OB_FAIL(schema_service_.get_tenant_schema_guard(tenant_id, schema_guard))) {
LOG_WARN("get schema guard failed", K(ret), K(tenant_id));
} else if (OB_FAIL(schema_guard.get_table_schema(tenant_id, table_id, table_schema))) {
LOG_WARN("get table schema failed", K(ret), KT(table_id));
} else if (OB_ISNULL(table_schema)) {
ret = OB_TABLE_NOT_EXIST;
LOG_WARN("got invalid schema", KR(ret), K(i));
} else if (OB_FAIL(table_schema->check_if_oracle_compat_mode(is_oracle_mode))) {
LOG_WARN("fail to check table if oracle compat mode", KR(ret));