Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
7c05e325
O
oceanbase
项目概览
Metz
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7c05e325
编写于
8月 11, 2021
作者:
Y
ym0
提交者:
wangzelin.wzl
8月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix auto drop tenant problem
上级
54e159ca
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
20 deletion
+52
-20
src/rootserver/ob_ddl_service.cpp
src/rootserver/ob_ddl_service.cpp
+6
-1
src/rootserver/ob_root_service.cpp
src/rootserver/ob_root_service.cpp
+18
-2
src/rootserver/restore/ob_restore_scheduler.cpp
src/rootserver/restore/ob_restore_scheduler.cpp
+28
-17
未找到文件。
src/rootserver/ob_ddl_service.cpp
浏览文件 @
7c05e325
...
...
@@ -13070,7 +13070,12 @@ int ObDDLService::modify_tenant(const ObModifyTenantArg& arg)
ObDDLOperator ddl_operator(*schema_service_, *sql_proxy_);
ObDDLSQLTransaction trans(schema_service_);
trans.set_end_tenant_id(OB_SYS_TENANT_ID);
if (orig_tenant_schema->get_tenant_id() <= OB_MAX_RESERVED_TENANT_ID) {
if (orig_tenant_schema->is_restore()) {
ret = OB_OP_NOT_ALLOW;
LOG_WARN(
"rename tenant while tenant is in physical restore status is not allowed", KR(ret), KPC(orig_tenant_schema));
LOG_USER_ERROR(OB_OP_NOT_ALLOW, "rename tenant while tenant is in physical restore status is");
} else if (orig_tenant_schema->get_tenant_id() <= OB_MAX_RESERVED_TENANT_ID) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("rename special tenant not supported", K(ret), K(orig_tenant_schema->get_tenant_id()));
LOG_USER_ERROR(OB_NOT_SUPPORTED, "rename special tenant");
src/rootserver/ob_root_service.cpp
浏览文件 @
7c05e325
...
...
@@ -8350,6 +8350,7 @@ int ObRootService::physical_restore_tenant(const obrpc::ObPhysicalRestoreTenantA
int64_t
current_timestamp
=
ObTimeUtility
::
current_time
();
const
int64_t
RESTORE_TIMESTAMP_DETA
=
10
*
1000
*
1000L
;
// prevent to recovery to a certain time in the future
int64_t
job_id
=
OB_INVALID_ID
;
ObSchemaGetterGuard
schema_guard
;
if
(
!
inited_
)
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"not init"
,
K
(
ret
));
...
...
@@ -8374,6 +8375,9 @@ int ObRootService::physical_restore_tenant(const obrpc::ObPhysicalRestoreTenantA
}
else
if
(
arg
.
restore_timestamp_
+
RESTORE_TIMESTAMP_DETA
>=
current_timestamp
)
{
ret
=
OB_EAGAIN
;
LOG_WARN
(
"restore_timestamp is too new"
,
K
(
ret
),
K
(
current_timestamp
),
K
(
arg
));
}
else
if
(
OB_FAIL
(
ddl_service_
.
get_tenant_schema_guard_with_version_in_inner_table
(
OB_SYS_TENANT_ID
,
schema_guard
)))
{
LOG_WARN
(
"fail to get sys tenant's schema guard"
,
KR
(
ret
));
}
else
{
ObMySQLTransaction
trans
;
ObPhysicalRestoreJob
job_info
;
...
...
@@ -8387,8 +8391,20 @@ int ObRootService::physical_restore_tenant(const obrpc::ObPhysicalRestoreTenantA
LOG_WARN
(
"invalid job_id"
,
K
(
ret
),
K
(
job_id
));
}
else
if
(
OB_FAIL
(
ObRestoreUtil
::
fill_physical_restore_job
(
job_id
,
arg
,
job_info
)))
{
LOG_WARN
(
"fail to fill physical restore job"
,
K
(
ret
),
K
(
job_id
),
K
(
arg
));
}
else
if
(
FALSE_IT
(
job_info
.
restore_start_ts_
=
current_timestamp
))
{
}
else
if
(
OB_FAIL
(
ObRestoreUtil
::
record_physical_restore_job
(
trans
,
job_info
)))
{
}
else
{
job_info
.
restore_start_ts_
=
current_timestamp
;
// check if tenant exists
const
ObTenantSchema
*
tenant_schema
=
NULL
;
ObString
tenant_name
(
job_info
.
tenant_name_
);
if
(
OB_FAIL
(
schema_guard
.
get_tenant_info
(
tenant_name
,
tenant_schema
)))
{
LOG_WARN
(
"fail to get tenant schema"
,
KR
(
ret
),
K
(
job_info
));
}
else
if
(
OB_NOT_NULL
(
tenant_schema
))
{
ret
=
OB_OP_NOT_ALLOW
;
LOG_WARN
(
"restore tenant with existed tenant name is not allowed"
,
KR
(
ret
),
K
(
tenant_name
));
LOG_USER_ERROR
(
OB_OP_NOT_ALLOW
,
"restore tenant with existed tenant name is"
);
}
}
if
(
FAILEDx
(
ObRestoreUtil
::
record_physical_restore_job
(
trans
,
job_info
)))
{
LOG_WARN
(
"fail to record physical restore job"
,
K
(
ret
),
K
(
job_id
),
K
(
arg
));
}
else
{
restore_scheduler_
.
wakeup
();
...
...
src/rootserver/restore/ob_restore_scheduler.cpp
浏览文件 @
7c05e325
...
...
@@ -2765,26 +2765,37 @@ int ObRestoreScheduler::drop_tenant_force_if_necessary(const ObPhysicalRestoreJo
const
bool
need_force_drop
=
GCONF
.
_auto_drop_tenant_if_restore_failed
;
if
(
!
inited_
)
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"not inited"
,
K
(
ret
));
LOG_WARN
(
"not inited"
,
K
R
(
ret
));
}
else
if
(
OB_FAIL
(
check_stop
()))
{
LOG_WARN
(
"restore scheduler stopped"
,
K
(
ret
));
LOG_WARN
(
"restore scheduler stopped"
,
K
R
(
ret
));
}
else
if
(
need_force_drop
)
{
obrpc
::
ObDropTenantArg
arg
;
arg
.
exec_tenant_id_
=
OB_SYS_TENANT_ID
;
arg
.
tenant_name_
=
job_info
.
tenant_name_
;
arg
.
if_exist_
=
true
;
arg
.
delay_to_drop_
=
false
;
ObSqlString
sql
;
const
int64_t
TIMEOUT_PER_RPC
=
GCONF
.
rpc_timeout
;
// default 2s
const
int64_t
DEFAULT_TIMEOUT
=
10
*
1000
*
1000L
;
// 10s
int64_t
rpc_timeout
=
max
(
TIMEOUT_PER_RPC
,
DEFAULT_TIMEOUT
);
if
(
OB_FAIL
(
sql
.
append_fmt
(
"DROP TENANT IF EXISTS %s FORCE"
,
arg
.
tenant_name_
.
ptr
())))
{
LOG_WARN
(
"fail to generate sql"
,
K
(
ret
),
K
(
arg
));
}
else
if
(
FALSE_IT
(
arg
.
ddl_stmt_str_
=
sql
.
string
()))
{
}
else
if
(
OB_FAIL
(
rpc_proxy_
->
timeout
(
rpc_timeout
).
drop_tenant
(
arg
)))
{
LOG_WARN
(
"fail to drop tenant"
,
K
(
ret
),
K
(
arg
));
ObSchemaGetterGuard
schema_guard
;
ObString
tenant_name
(
job_info
.
tenant_name_
);
const
ObTenantSchema
*
tenant_schema
=
NULL
;
if
(
OB_FAIL
(
schema_service_
->
get_tenant_schema_guard
(
OB_SYS_TENANT_ID
,
schema_guard
)))
{
LOG_WARN
(
"fail to get tenant schema guard"
,
KR
(
ret
));
}
else
if
(
OB_FAIL
(
schema_guard
.
get_tenant_info
(
tenant_name
,
tenant_schema
)))
{
LOG_WARN
(
"fail to get tenant schema"
,
KR
(
ret
),
K
(
tenant_name
));
}
else
if
(
OB_ISNULL
(
tenant_schema
)
||
!
tenant_schema
->
is_restore
())
{
LOG_INFO
(
"tenant not exist or tenant is not in physical restore status, just skip"
,
K
(
tenant_name
));
}
else
{
LOG_INFO
(
"drop_tenant_force after restore fail"
,
K
(
job_info
));
obrpc
::
ObDropTenantArg
arg
;
arg
.
exec_tenant_id_
=
OB_SYS_TENANT_ID
;
arg
.
tenant_name_
=
tenant_name
;
arg
.
if_exist_
=
true
;
arg
.
delay_to_drop_
=
false
;
ObSqlString
sql
;
const
int64_t
TIMEOUT_PER_RPC
=
GCONF
.
rpc_timeout
;
// default 2s
const
int64_t
DEFAULT_TIMEOUT
=
10
*
1000
*
1000L
;
// 10s
int64_t
rpc_timeout
=
max
(
TIMEOUT_PER_RPC
,
DEFAULT_TIMEOUT
);
if
(
OB_FAIL
(
sql
.
append_fmt
(
"DROP TENANT IF EXISTS %s FORCE"
,
arg
.
tenant_name_
.
ptr
())))
{
LOG_WARN
(
"fail to generate sql"
,
KR
(
ret
),
K
(
arg
));
}
else
if
(
FALSE_IT
(
arg
.
ddl_stmt_str_
=
sql
.
string
()))
{
}
else
if
(
OB_FAIL
(
rpc_proxy_
->
timeout
(
rpc_timeout
).
drop_tenant
(
arg
)))
{
LOG_WARN
(
"fail to drop tenant"
,
KR
(
ret
),
K
(
arg
));
}
else
{
LOG_INFO
(
"drop_tenant_force after restore fail"
,
K
(
job_info
));
}
}
}
else
{
LOG_INFO
(
"no need to drop tenant after restore fail"
,
K
(
job_info
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录