Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
caoersss
oceanbase
提交
f51dd07d
O
oceanbase
项目概览
caoersss
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f51dd07d
编写于
1月 31, 2022
作者:
W
WenJinyu
提交者:
LINGuanRen
1月 31, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
delete backup clean redundant code
上级
77bb1d79
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
106 addition
and
1728 deletion
+106
-1728
src/rootserver/backup/ob_tenant_backup_data_clean_mgr.cpp
src/rootserver/backup/ob_tenant_backup_data_clean_mgr.cpp
+0
-430
src/rootserver/backup/ob_tenant_backup_data_clean_mgr.h
src/rootserver/backup/ob_tenant_backup_data_clean_mgr.h
+0
-28
src/rootserver/ob_backup_data_clean.cpp
src/rootserver/ob_backup_data_clean.cpp
+105
-994
src/rootserver/ob_backup_data_clean.h
src/rootserver/ob_backup_data_clean.h
+0
-67
src/rootserver/ob_backup_data_clean_scheduler.cpp
src/rootserver/ob_backup_data_clean_scheduler.cpp
+0
-201
src/rootserver/ob_backup_data_clean_scheduler.h
src/rootserver/ob_backup_data_clean_scheduler.h
+1
-8
未找到文件。
src/rootserver/backup/ob_tenant_backup_data_clean_mgr.cpp
浏览文件 @
f51dd07d
此差异已折叠。
点击以展开。
src/rootserver/backup/ob_tenant_backup_data_clean_mgr.h
浏览文件 @
f51dd07d
...
...
@@ -107,8 +107,6 @@ struct ObBackupDataCleanElement {
void
reset
();
bool
is_same_element
(
const
int64_t
cluster_id
,
const
int64_t
incarnation
,
const
share
::
ObBackupDest
&
backup_dest
)
const
;
int
set_backup_set_id
(
const
ObBackupSetId
&
backup_set_id
);
int
set_log_archive_round
(
const
ObLogArchiveRound
&
log_archive_round
);
TO_STRING_KV
(
K_
(
cluster_id
),
K_
(
incarnation
),
K_
(
backup_dest
),
K_
(
backup_set_id_array
),
K_
(
log_archive_round_array
),
K_
(
backup_dest_option
));
...
...
@@ -295,8 +293,6 @@ private:
const
ObExternBackupInfo
&
extern_backup_info
);
int
touch_backup_set_meta
(
const
ObBackupDataCleanElement
&
clean_element
,
const
ObBackupPath
&
path
);
int
delete_backup_set_meta
(
const
ObBackupDataCleanElement
&
clean_element
,
const
ObBackupPath
&
path
);
int
get_table_id_list
(
const
storage
::
ObPhyRestoreMetaIndexStore
::
MetaIndexMap
&
index_map
,
hash
::
ObHashSet
<
int64_t
>
&
table_id_set
);
// clean backup set
int
try_clean_backup_set_dir
(
const
uint64_t
tenant_id
,
const
ObBackupDataCleanElement
&
clean_element
,
...
...
@@ -333,30 +329,6 @@ public:
private:
int
do_inner_clean
(
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
const
ObBackupDataCleanElement
&
clean_element
,
const
int64_t
start_replay_log_ts
);
// TODO(muwei.ym) delete later
// do_inner_clean ~ try_clean_clog_data_dir
int
do_inner_clean
(
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
const
ObBackupDataCleanElement
&
clean_element
,
const
ObTenantBackupTaskInfo
&
clog_data_clean_point
);
int
clean_clog_data
(
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
const
ObBackupDataCleanElement
&
clean_element
,
const
ObTenantBackupTaskInfo
&
clog_data_clean_point
,
const
ObLogArchiveRound
&
log_archive_round
,
const
common
::
ObIArray
<
int64_t
>
&
table_id_array
,
ObBackupDataMgr
&
backup_data_mgr
);
int
do_clean_table_clog_data
(
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
const
ObBackupDataCleanElement
&
clean_element
,
const
ObTenantBackupTaskInfo
&
clog_data_clean_point
,
const
ObLogArchiveRound
&
log_archive_round
,
const
common
::
ObIArray
<
int64_t
>
&
table_id
,
ObBackupDataMgr
&
backup_data_mgr
);
int
set_partition_into_set
(
const
common
::
ObIArray
<
ObBackupMetaIndex
>
&
meta_index_array
);
int
check_and_delete_clog_data
(
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
const
ObBackupDataCleanElement
&
backup_clean_element
,
const
int64_t
clog_gc_snapshot
);
int
check_and_delete_clog_data_with_round
(
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
const
ObClusterBackupDest
&
cluster_backup_dest
,
const
ObLogArchiveRound
&
log_archive_round
,
const
int64_t
max_clean_clog_snapshot
);
int
get_clog_pkey_list_not_in_base_data
(
const
ObClusterBackupDest
&
cluster_backup_dest
,
const
int64_t
log_archive_round
,
const
uint64_t
tenant_id
,
common
::
ObIArray
<
ObPartitionKey
>
&
pkey_list
);
int
clean_interrputed_clog_data
(
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
const
ObBackupDataCleanElement
&
clean_element
,
const
ObLogArchiveRound
&
log_archive_round
);
int
try_clean_clog_data_dir
(
const
ObClusterBackupDest
&
cluster_backup_dest
,
const
uint64_t
tenant_id
,
const
int64_t
log_archive_round
,
const
char
*
storage_info
,
const
common
::
ObStorageType
&
device_type
);
int
generate_backup_piece_tasks
(
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
const
ObBackupDataCleanElement
&
clean_element
,
const
ObLogArchiveRound
&
log_archive_round
,
const
int64_t
start_replay_log_ts
);
...
...
src/rootserver/ob_backup_data_clean.cpp
浏览文件 @
f51dd07d
此差异已折叠。
点击以展开。
src/rootserver/ob_backup_data_clean.h
浏览文件 @
f51dd07d
...
...
@@ -105,30 +105,10 @@ public:
private:
int
get_need_clean_tenants
(
common
::
ObIArray
<
ObBackupDataCleanTenant
>
&
clean_tenants
);
int
get_server_clean_tenants
(
common
::
ObIArray
<
ObBackupDataCleanTenant
>
&
clean_tenants
);
int
get_extern_clean_tenants
(
hash
::
ObHashMap
<
uint64_t
,
ObSimpleBackupDataCleanTenant
>
&
clean_tenants_map
);
int
get_server_need_clean_info
(
const
uint64_t
tenant_id
,
bool
&
need_add
);
int
get_all_tenant_ids
(
common
::
ObIArray
<
uint64_t
>
&
tenant_ids
);
int
get_tenant_backup_task_his_info
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
common
::
ObISQLClient
&
trans
,
common
::
ObIArray
<
share
::
ObTenantBackupTaskInfo
>
&
tenant_infos
);
int
get_tenant_backup_task_info
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
common
::
ObISQLClient
&
trans
,
common
::
ObIArray
<
share
::
ObTenantBackupTaskInfo
>
&
tenant_infos
);
int
inner_get_tenant_backup_task_his_info
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
common
::
ObISQLClient
&
trans
,
common
::
ObIArray
<
share
::
ObTenantBackupTaskInfo
>
&
tenant_infos
);
int
get_tenant_backup_backupset_task_his_info
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
common
::
ObISQLClient
&
trans
,
common
::
ObIArray
<
share
::
ObTenantBackupBackupsetTaskInfo
>
&
tenant_infos
);
int
convert_backup_backupset_task_to_backup_task
(
const
common
::
ObIArray
<
share
::
ObTenantBackupBackupsetTaskInfo
>
&
backup_backupset_tasks
,
common
::
ObIArray
<
share
::
ObTenantBackupTaskInfo
>
&
backup_tasks
);
int
get_log_archive_info
(
const
int64_t
copy_id
,
const
uint64_t
tenant_id
,
common
::
ObISQLClient
&
trans
,
common
::
ObIArray
<
share
::
ObLogArchiveBackupInfo
>
&
log_archive_infos
);
int
get_log_archive_history_info
(
const
int64_t
copy_id
,
const
uint64_t
tenant_id
,
common
::
ObISQLClient
&
trans
,
common
::
ObIArray
<
share
::
ObLogArchiveBackupInfo
>
&
log_archive_infos
);
int
get_backup_clean_tenant
(
const
share
::
ObTenantBackupTaskInfo
&
task_info
,
hash
::
ObHashMap
<
uint64_t
,
ObSimpleBackupDataCleanTenant
>
&
clean_tenants_map
);
int
get_archive_clean_tenant
(
const
share
::
ObLogArchiveBackupInfo
&
log_archive_info
,
hash
::
ObHashMap
<
uint64_t
,
ObSimpleBackupDataCleanTenant
>
&
clean_tenants_map
);
int
get_backup_clean_elements
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
common
::
ObIArray
<
share
::
ObTenantBackupTaskInfo
>
&
task_infos
,
const
common
::
ObArray
<
share
::
ObLogArchiveBackupInfo
>
&
log_archive_infos
,
ObBackupDataCleanTenant
&
clean_tenant
);
...
...
@@ -155,30 +135,6 @@ private:
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanTenant
&
clean_tenant
);
int
mark_backup_meta_data_deleting
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanTenant
&
clean_tenant
);
int
mark_inner_table_his_data_deleted
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanTenant
&
clean_tenant
);
int
mark_backup_task_his_data_deleted
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanElement
&
clean_element
,
common
::
ObISQLClient
&
trans
);
int
inner_mark_backup_task_his_data_deleted
(
const
uint64_t
tenant_id
,
const
int64_t
incarnation
,
const
int64_t
backup_set_id
,
const
share
::
ObBackupDest
&
backup_dest
,
common
::
ObISQLClient
&
trans
);
int
inner_mark_backup_backup_task_his_data_deleted
(
const
uint64_t
tenant_id
,
const
int64_t
incarnation
,
const
int64_t
backup_set_id
,
const
int64_t
copy_id
,
const
share
::
ObBackupDest
&
backup_dest
,
common
::
ObISQLClient
&
trans
);
int
inner_mark_backup_set_file_data_deleting
(
const
uint64_t
tenant_id
,
const
int64_t
incarnation
,
const
int64_t
backup_set_id
,
const
int64_t
copy_id
,
common
::
ObISQLClient
&
trans
);
int
inner_mark_backup_set_file_data_deleted
(
const
uint64_t
tenant_id
,
const
int64_t
incarnation
,
const
int64_t
backup_set_id
,
const
int64_t
copy_id
,
common
::
ObISQLClient
&
trans
);
int
mark_log_archive_stauts_his_data_deleted
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanElement
&
clean_element
,
const
int64_t
clog_gc_snapshot
,
common
::
ObISQLClient
&
trans
);
int
mark_log_archive_round_data_deleted
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
int64_t
log_archive_round
,
const
int64_t
copy_id
,
const
int64_t
start_piece_id
,
const
int64_t
clog_gc_snapshot
,
common
::
ObISQLClient
&
trans
);
int
mark_log_archive_piece_data_deleting
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupPieceInfo
&
backup_piece_info
,
const
int64_t
clog_gc_snapshot
,
common
::
ObISQLClient
&
trans
);
int
mark_extern_backup_info_deleted
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanElement
&
clean_element
);
// for new interface
int
mark_backup_set_infos_deleting
(
...
...
@@ -189,7 +145,6 @@ private:
const
ObBackupDataCleanElement
&
clean_element
,
const
common
::
ObIArray
<
ObBackupSetId
>
&
backup_set_ids
);
int
mark_extern_backup_set_info_deleting
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanElement
&
clean_element
,
const
common
::
ObIArray
<
ObBackupSetId
>
&
backup_set_ids
);
int
mark_log_archive_infos_deleting
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanTenant
&
clean_tenant
);
int
mark_log_archive_info_deleting
(
...
...
@@ -232,21 +187,14 @@ private:
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanTenant
&
clean_tenant
);
int
delete_inner_table_his_data
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanTenant
&
clean_tenant
,
common
::
ObISQLClient
&
trans
);
int
delete_backup_extern_info
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanElement
&
clean_element
);
int
delete_extern_backup_info_deleted
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanElement
&
clean_element
,
const
common
::
ObIArray
<
ObBackupSetId
>
&
backup_set_ids
);
int
delete_extern_clog_info_deleted
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanElement
&
clean_element
,
const
common
::
ObIArray
<
ObLogArchiveRound
>
&
log_archive_rounds
);
int
delete_marked_backup_task_his_data
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanElement
&
clean_element
,
common
::
ObISQLClient
&
trans
);
int
inner_delete_marked_backup_backup_task_his_data
(
const
uint64_t
tenant_id
,
const
int64_t
job_id
,
const
int64_t
copy_id
,
const
int64_t
backup_set_id
,
common
::
ObISQLClient
&
trans
);
int
delete_marked_log_archive_status_his_data
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanElement
&
clean_element
,
common
::
ObISQLClient
&
trans
);
// new interface
int
delete_extern_tmp_files
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObBackupDataCleanElement
&
clean_element
);
...
...
@@ -260,11 +208,9 @@ private:
int
update_clean_info
(
const
uint64_t
tenant_id
,
const
share
::
ObBackupCleanInfo
&
src_clean_info
,
const
share
::
ObBackupCleanInfo
&
dest_clean_info
,
common
::
ObISQLClient
&
trans
);
int
do_with_status
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
ObBackupDataCleanTenant
&
clean_tenant
);
int
do_clean_scheduler
(
common
::
ObIArray
<
ObBackupDataCleanTenant
>
&
clean_tenants
);
int
do_schedule_clean_tenants
(
common
::
ObIArray
<
ObBackupDataCleanTenant
>
&
clean_tenants
);
int
do_check_clean_tenants_finished
(
const
common
::
ObIArray
<
ObBackupDataCleanTenant
>
&
clean_tenants
);
int
do_tenant_clean_scheduler
(
share
::
ObBackupCleanInfo
&
clean_info
,
ObBackupDataCleanTenant
&
clean_tenant
);
int
get_backup_clean_info
(
const
uint64_t
tenant_id
,
const
bool
for_update
,
common
::
ObISQLClient
&
sql_proxy
,
share
::
ObBackupCleanInfo
&
clean_info
);
...
...
@@ -304,7 +250,6 @@ private:
int
set_sys_clean_info_stop
(
const
share
::
ObBackupCleanInfo
&
backup_clean_info
,
ObISQLClient
&
trans
);
int
try_clean_tenant_backup_dir
(
const
ObBackupDataCleanTenant
&
clean_tenant
);
int
clean_tenant_backup_dir
(
const
uint64_t
tenant_id
,
const
ObBackupDataCleanElement
&
clean_element
);
int
clean_backup_tenant_info
(
const
ObBackupDataCleanTenant
&
sys_clean_tenant
,
const
common
::
ObIArray
<
ObSimpleBackupDataCleanTenant
>
&
normal_clean_tenants
);
int
inner_clean_backup_tenant_info
(
const
ObBackupDataCleanElement
&
clean_element
,
...
...
@@ -372,16 +317,9 @@ private:
int
set_tenant_clean_info_cancel
(
const
share
::
ObBackupCleanInfo
&
clean_info
);
int
set_normal_tenant_cancel
(
const
uint64_t
tenant_id
,
common
::
ObISQLClient
&
sys_tenant_trans
);
int
set_deleted_tenant_cancel
(
const
ObBackupCleanInfo
&
clean_info
,
common
::
ObISQLClient
&
sys_tenant_trans
);
int
get_sys_tenant_backup_dest
(
common
::
hash
::
ObHashSet
<
ObClusterBackupDest
>
&
cluster_backup_dest_set
);
int
do_scheduler_normal_tenant
(
share
::
ObBackupCleanInfo
&
clean_info
,
ObBackupDataCleanTenant
&
clean_tenant
,
common
::
ObIArray
<
ObTenantBackupTaskInfo
>
&
task_infos
,
common
::
ObIArray
<
ObLogArchiveBackupInfo
>
&
log_archive_infos
);
int
do_scheduler_deleted_tenant
(
share
::
ObBackupCleanInfo
&
clean_info
,
ObBackupDataCleanTenant
&
clean_tenant
,
common
::
ObIArray
<
ObTenantBackupTaskInfo
>
&
task_infos
,
common
::
ObIArray
<
ObLogArchiveBackupInfo
>
&
log_archive_infos
);
int
do_inner_scheduler_delete_tenant
(
const
ObClusterBackupDest
&
cluster_backup_dest
,
ObBackupDataCleanTenant
&
clean_tenant
,
common
::
ObIArray
<
ObTenantBackupTaskInfo
>
&
task_infos
,
common
::
ObIArray
<
ObLogArchiveBackupInfo
>
&
log_archive_infos
);
int
get_all_tenant_backup_infos
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
common
::
ObISQLClient
&
trans
,
common
::
ObIArray
<
ObTenantBackupTaskInfo
>
&
tenant_backup_infos
,
...
...
@@ -398,11 +336,6 @@ private:
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
common
::
ObISQLClient
&
trans
,
common
::
ObIArray
<
share
::
ObTenantBackupTaskInfo
>
&
tenant_backup_infos
,
common
::
ObIArray
<
share
::
ObLogArchiveBackupInfo
>
&
tenant_backup_log_infos
);
int
get_delete_backup_piece_infos
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
common
::
ObISQLClient
&
trans
,
common
::
ObIArray
<
share
::
ObTenantBackupTaskInfo
>
&
tenant_backup_infos
,
common
::
ObIArray
<
share
::
ObLogArchiveBackupInfo
>
&
tenant_backup_log_infos
);
int
get_tenant_backup_task_infos
(
const
share
::
ObBackupCleanInfo
&
clean_info
,
const
ObSimpleBackupDataCleanTenant
&
simple_clean_tenant
,
common
::
ObISQLClient
&
trans
,
common
::
ObIArray
<
share
::
ObTenantBackupTaskInfo
>
&
tenant_infos
);
...
...
src/rootserver/ob_backup_data_clean_scheduler.cpp
浏览文件 @
f51dd07d
...
...
@@ -479,206 +479,5 @@ int ObBackupDataCleanScheduler::schedule_sys_tenant_backup_data_clean()
return
ret
;
}
int
ObBackupDataCleanScheduler
::
schedule_tenants_backup_data_clean
(
const
common
::
ObIArray
<
uint64_t
>&
tenant_ids
)
{
int
ret
=
OB_SUCCESS
;
ObBackupCleanInfo
sys_clean_info
;
ObMySQLTransaction
trans
;
const
bool
for_update
=
true
;
if
(
!
is_inited_
)
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"backup data clean scheduler do not init"
,
K
(
ret
));
}
else
if
(
tenant_ids
.
empty
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"schedule get tenants backup get invalid argument"
,
K
(
ret
),
K
(
tenant_ids
));
}
else
if
(
OB_FAIL
(
trans
.
start
(
sql_proxy_
)))
{
LOG_WARN
(
"fail to start trans"
,
K
(
ret
));
}
else
{
if
(
OB_FAIL
(
get_backup_clean_info
(
OB_SYS_TENANT_ID
,
for_update
,
trans
,
sys_clean_info
)))
{
LOG_WARN
(
"failed to get backup clean info"
,
K
(
ret
),
K
(
sys_clean_info
));
}
else
if
((
is_cluster_clean_
&&
ObBackupCleanInfoStatus
::
PREPARE
!=
sys_clean_info
.
status_
)
||
(
!
is_cluster_clean_
&&
ObBackupCleanInfoStatus
::
STOP
!=
sys_clean_info
.
status_
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"sys backup info status is unexpected"
,
K
(
ret
),
K
(
sys_clean_info
));
}
else
{
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
tenant_ids
.
count
();
++
i
)
{
const
uint64_t
tenant_id
=
tenant_ids
.
at
(
i
);
if
(
OB_SYS_TENANT_ID
==
tenant_id
)
{
// do nothing
}
else
if
(
OB_FAIL
(
schedule_tenant_backup_data_clean
(
tenant_id
,
trans
)))
{
LOG_WARN
(
"failed to schedule tenant backup"
,
K
(
ret
),
K
(
tenant_id
));
}
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
trans
.
end
(
true
/*commit*/
)))
{
OB_LOG
(
WARN
,
"failed to commit"
,
K
(
ret
));
}
}
else
{
int
tmp_ret
=
OB_SUCCESS
;
if
(
OB_SUCCESS
!=
(
tmp_ret
=
trans
.
end
(
false
/* commit*/
)))
{
OB_LOG
(
WARN
,
"failed to rollback trans"
,
K
(
tmp_ret
));
}
}
}
return
ret
;
}
int
ObBackupDataCleanScheduler
::
schedule_tenant_backup_data_clean
(
const
uint64_t
tenant_id
,
ObISQLClient
&
sys_tenant_trans
)
{
int
ret
=
OB_SUCCESS
;
ObBackupCleanInfo
clean_info
;
ObBackupCleanInfo
dest_clean_info
;
ObMySQLTransaction
trans
;
const
bool
for_update
=
true
;
if
(
!
is_inited_
)
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"backup scheduler do not init"
,
K
(
ret
));
}
else
if
(
OB_SYS_TENANT_ID
==
tenant_id
)
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"tenant id should be sys tenant id"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
OB_FAIL
(
trans
.
start
(
sql_proxy_
)))
{
LOG_WARN
(
"fail to start trans"
,
K
(
ret
));
}
else
{
if
(
OB_FAIL
(
get_backup_clean_info
(
tenant_id
,
for_update
,
trans
,
clean_info
)))
{
LOG_WARN
(
"failed to get backup clean info"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
ObBackupCleanInfoStatus
::
STOP
!=
clean_info
.
status_
)
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"clean info status is unexpected"
,
K
(
ret
),
K
(
clean_info
));
}
else
{
dest_clean_info
=
clean_info
;
dest_clean_info
.
status_
=
ObBackupCleanInfoStatus
::
DOING
;
dest_clean_info
.
incarnation_
=
OB_START_INCARNATION
;
dest_clean_info
.
job_id_
=
max_job_id_
;
if
(
OB_FAIL
(
rootserver
::
ObBackupUtil
::
check_sys_clean_info_trans_alive
(
sys_tenant_trans
)))
{
LOG_WARN
(
"failed to check sys tenant trans alive"
,
K
(
ret
),
K
(
clean_info
));
}
else
if
(
OB_FAIL
(
set_backup_clean_info
(
tenant_id
,
dest_clean_info
)))
{
LOG_WARN
(
"failed to set backup clean info"
,
K
(
ret
),
K
(
tenant_id
),
K
(
dest_clean_info
));
}
else
if
(
OB_FAIL
(
update_backup_clean_info
(
clean_info
,
dest_clean_info
,
trans
)))
{
LOG_WARN
(
"failed to update backup clean info"
,
K
(
ret
),
K
(
clean_info
),
K
(
dest_clean_info
));
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
trans
.
end
(
true
/*commit*/
)))
{
OB_LOG
(
WARN
,
"failed to commit"
,
K
(
ret
));
}
}
else
{
int
tmp_ret
=
OB_SUCCESS
;
if
(
OB_SUCCESS
!=
(
tmp_ret
=
trans
.
end
(
false
/* commit*/
)))
{
OB_LOG
(
WARN
,
"failed to rollback trans"
,
K
(
tmp_ret
));
}
}
}
return
ret
;
}
int
ObBackupDataCleanScheduler
::
start_backup_clean
()
{
int
ret
=
OB_SUCCESS
;
if
(
!
is_inited_
)
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"backup data clean scheduler do not init"
,
K
(
ret
));
}
else
if
(
!
is_cluster_clean_
)
{
// do nothing
}
else
{
ObBackupCleanInfo
clean_info
;
ObBackupCleanInfo
dest_clean_info
;
ObMySQLTransaction
trans
;
const
uint64_t
tenant_id
=
OB_SYS_TENANT_ID
;
const
bool
for_update
=
true
;
if
(
OB_FAIL
(
trans
.
start
(
sql_proxy_
)))
{
LOG_WARN
(
"fail to start trans"
,
K
(
ret
));
}
else
{
if
(
OB_FAIL
(
get_backup_clean_info
(
tenant_id
,
for_update
,
trans
,
clean_info
)))
{
LOG_WARN
(
"failed to get backup clean info"
,
K
(
ret
),
K
(
clean_info
));
}
else
if
(
ObBackupCleanInfoStatus
::
PREPARE
!=
clean_info
.
status_
)
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"tenant backup clean info status is unexpected"
,
K
(
ret
),
K
(
clean_info
));
}
else
{
dest_clean_info
=
clean_info
;
dest_clean_info
.
status_
=
ObBackupCleanInfoStatus
::
PREPARE
;
if
(
OB_FAIL
(
update_backup_clean_info
(
clean_info
,
dest_clean_info
,
trans
)))
{
LOG_WARN
(
"failed to update backup clean info"
,
K
(
ret
),
K
(
clean_info
),
K
(
dest_clean_info
));
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
trans
.
end
(
true
/*commit*/
)))
{
OB_LOG
(
WARN
,
"failed to commit"
,
K
(
ret
));
}
}
else
{
int
tmp_ret
=
OB_SUCCESS
;
if
(
OB_SUCCESS
!=
(
tmp_ret
=
trans
.
end
(
false
/* commit*/
)))
{
OB_LOG
(
WARN
,
"failed to rollback trans"
,
K
(
tmp_ret
));
}
}
}
}
return
ret
;
}
int
ObBackupDataCleanScheduler
::
rollback_backup_clean_infos
(
const
common
::
ObIArray
<
uint64_t
>&
tenant_ids
)
{
int
ret
=
OB_SUCCESS
;
if
(
!
is_inited_
)
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"backup scheduler do not init"
,
K
(
ret
));
}
else
{
for
(
int64_t
i
=
tenant_ids
.
count
()
-
1
;
OB_SUCC
(
ret
)
&&
i
>=
0
;
--
i
)
{
const
uint64_t
tenant_id
=
tenant_ids
.
at
(
i
);
if
(
OB_FAIL
(
rollback_backup_clean_info
(
tenant_id
)))
{
LOG_WARN
(
"failed to rollback backup info"
,
K
(
ret
),
K
(
tenant_id
));
}
}
}
return
ret
;
}
int
ObBackupDataCleanScheduler
::
rollback_backup_clean_info
(
const
uint64_t
tenant_id
)
{
int
ret
=
OB_SUCCESS
;
ObBackupCleanInfo
clean_info
;
ObBackupCleanInfo
dest_clean_info
;
ObMySQLTransaction
trans
;
const
bool
for_update
=
true
;
if
(
!
is_inited_
)
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"backup data clean scheduler do not init"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
trans
.
start
(
sql_proxy_
)))
{
LOG_WARN
(
"fail to start trans"
,
K
(
ret
));
}
else
{
if
(
OB_FAIL
(
get_backup_clean_info
(
tenant_id
,
for_update
,
trans
,
clean_info
)))
{
LOG_WARN
(
"failed to get backup clean info"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
ObBackupCleanInfoStatus
::
STOP
==
clean_info
.
status_
)
{
// do nothing
}
else
{
dest_clean_info
.
tenant_id_
=
tenant_id
;
dest_clean_info
.
status_
=
ObBackupCleanInfoStatus
::
STOP
;
if
(
OB_FAIL
(
update_backup_clean_info
(
clean_info
,
dest_clean_info
,
trans
)))
{
LOG_WARN
(
"failed to update backup clean info"
,
K
(
ret
),
K
(
clean_info
),
K
(
dest_clean_info
));
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
trans
.
end
(
true
/*commit*/
)))
{
OB_LOG
(
WARN
,
"failed to commit"
,
K
(
ret
));
}
}
else
{
int
tmp_ret
=
OB_SUCCESS
;
if
(
OB_SUCCESS
!=
(
tmp_ret
=
trans
.
end
(
false
/* commit*/
)))
{
OB_LOG
(
WARN
,
"failed to rollback trans"
,
K
(
tmp_ret
));
}
}
}
return
ret
;
}
}
// namespace rootserver
}
// namespace oceanbase
src/rootserver/ob_backup_data_clean_scheduler.h
浏览文件 @
f51dd07d
...
...
@@ -42,14 +42,7 @@ private:
int
get_tenant_ids
(
common
::
ObIArray
<
uint64_t
>&
tenant_ids
);
int
schedule_backup_data_clean
(
const
common
::
ObIArray
<
uint64_t
>&
tenant_ids
);
int
schedule_sys_tenant_backup_data_clean
();
int
schedule_tenants_backup_data_clean
(
const
common
::
ObIArray
<
uint64_t
>&
tenant_ids
);
int
schedule_tenant_backup_data_clean
(
const
uint64_t
tenant_id
,
common
::
ObISQLClient
&
sys_tenant_trans
);
int
set_backup_clean_info
(
const
uint64_t
tenant_id
,
share
::
ObBackupCleanInfo
&
clean_info
);
int
start_backup_clean
();
int
rollback_backup_clean_infos
(
const
common
::
ObIArray
<
uint64_t
>&
tenant_ids
);
int
rollback_backup_clean_info
(
const
uint64_t
tenant_id
);
// delete backup set need to know incarnation
int
get_backup_incarnation
(
const
uint64_t
tenant_id
,
const
int64_t
backup_set_id
);
int
set_backup_clean_info
(
const
uint64_t
tenant_id
,
share
::
ObBackupCleanInfo
&
clean_info
);
private:
bool
is_inited_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录