Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
caoersss
oceanbase
提交
69facd62
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,发现更多精彩内容 >>
提交
69facd62
编写于
4月 11, 2022
作者:
G
godyangfight
提交者:
LINGuanRen
4月 11, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix weak read get tenant schema version using wrong backup snapshot version
上级
a26f56ec
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
98 addition
and
45 deletion
+98
-45
deps/oblib/src/lib/utility/ob_tracepoint.h
deps/oblib/src/lib/utility/ob_tracepoint.h
+2
-0
src/share/backup/ob_backup_scheduler.cpp
src/share/backup/ob_backup_scheduler.cpp
+95
-45
src/share/backup/ob_backup_scheduler.h
src/share/backup/ob_backup_scheduler.h
+1
-0
未找到文件。
deps/oblib/src/lib/utility/ob_tracepoint.h
浏览文件 @
69facd62
...
...
@@ -447,6 +447,8 @@ public:
EN_BACKUP_CHECK_BACKUP_POINT_EXIST
=
185
,
EN_STOP_TENANT_LOG_ARCHIVE_BACKUP
=
186
,
EN_BACKUP_SERVER_DISK_IS_FULL
=
188
,
EN_BACKUP_DATA_CLEAN_ERROR
=
189
,
EN_BACKUP_SCHEDULER_WEAK_READ
=
191
,
EN_CHECK_STANDBY_CLUSTER_SCHEMA_CONDITION
=
201
,
EN_ALLOCATE_LOB_BUF_FAILED
=
202
,
EN_ALLOCATE_DESERIALIZE_LOB_BUF_FAILED
=
203
,
...
...
src/share/backup/ob_backup_scheduler.cpp
浏览文件 @
69facd62
...
...
@@ -155,12 +155,22 @@ int ObBackupScheduler::check_backup_schema_version_(const uint64_t tenant_id, co
int
ret
=
OB_SUCCESS
;
int
hash_ret
=
OB_SUCCESS
;
int64_t
schema_version
=
0
;
int64_t
weak_read_schema_version
=
0
;
if
(
!
is_inited_
)
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"backup scheduler do not init"
,
K
(
ret
));
}
else
if
(
tenant_id
==
OB_SYS_TENANT_ID
)
{
// skip check sys tenant
}
else
if
(
OB_FAIL
(
fetch_schema_version
(
tenant_id
,
weak_read_schema_version
)))
{
LOG_WARN
(
"failed to fetch schema version"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
backup_schema_version
!=
weak_read_schema_version
)
{
ret
=
OB_NOT_SUPPORTED
;
FLOG_ERROR
(
"cannot backup tenant with weak read schema version bigger than backup schema version"
,
K
(
ret
),
K
(
tenant_id
),
K
(
backup_schema_version
),
K
(
weak_read_schema_version
));
}
else
if
(
OB_SUCCESS
!=
(
hash_ret
=
frozen_schema_version_map_
.
get_refactored
(
tenant_id
,
schema_version
)))
{
if
(
OB_HASH_NOT_EXIST
==
hash_ret
)
{
LOG_INFO
(
"tenant not freeze, skip check schema version"
,
K
(
ret
),
K
(
tenant_id
));
...
...
@@ -211,7 +221,9 @@ int ObBackupScheduler::get_tenant_ids(ObIArray<uint64_t>& tenant_ids)
LOG_WARN
(
"backup scheduler do not init"
,
K
(
ret
));
}
else
{
if
(
is_cluster_backup_
)
{
if
(
OB_FAIL
(
get_tenant_schema_version
(
OB_SYS_TENANT_ID
,
backup_schema_version
)))
{
if
(
OB_FAIL
(
prepare_tenant_schema_version_
(
OB_SYS_TENANT_ID
)))
{
LOG_WARN
(
"failed to prepare tenant schema version"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
get_tenant_schema_version
(
OB_SYS_TENANT_ID
,
backup_schema_version
)))
{
LOG_WARN
(
"failed to get tenant schem version"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
ObBackupUtils
::
retry_get_tenant_schema_guard
(
OB_SYS_TENANT_ID
,
*
schema_service_
,
backup_schema_version
,
guard
)))
{
...
...
@@ -222,10 +234,17 @@ int ObBackupScheduler::get_tenant_ids(ObIArray<uint64_t>& tenant_ids)
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
tmp_tenant_ids
.
count
();
++
i
)
{
const
uint64_t
tenant_id
=
tmp_tenant_ids
.
at
(
i
);
bool
can_backup
=
false
;
if
(
OB_FAIL
(
get_tenant_schema_version
(
tenant_id
,
backup_schema_version
)))
{
if
(
OB_SYS_TENANT_ID
==
tenant_id
)
{
can_backup
=
true
;
}
else
if
(
OB_FAIL
(
prepare_tenant_schema_version_
(
tenant_id
)))
{
LOG_WARN
(
"failed to prepare tenant schema version"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
OB_FAIL
(
get_tenant_schema_version
(
tenant_id
,
backup_schema_version
)))
{
LOG_WARN
(
"failed to get tenant schem version"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
OB_FAIL
(
check_tenant_can_backup
(
tenant_id
,
backup_schema_version
,
can_backup
)))
{
LOG_WARN
(
"failed to check tenant can backup"
,
K
(
ret
),
K
(
tenant_id
),
K
(
backup_schema_version
));
}
if
(
OB_FAIL
(
ret
))
{
}
else
if
(
!
can_backup
)
{
// do nothing
}
else
if
(
OB_FAIL
(
tenant_ids
.
push_back
(
tenant_id
)))
{
...
...
@@ -520,17 +539,8 @@ int ObBackupScheduler::get_tenant_schema_version(const uint64_t tenant_id, int64
}
else
if
(
OB_INVALID_ID
==
tenant_id
)
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"get tenant schema version get invalid argument"
,
K
(
ret
),
K
(
tenant_id
));
}
else
{
hash_ret
=
schema_version_map_
.
get_refactored
(
tenant_id
,
backup_schema_version
);
if
(
OB_SUCCESS
==
hash_ret
)
{
}
else
if
(
OB_HASH_NOT_EXIST
!=
hash_ret
)
{
ret
=
hash_ret
;
LOG_WARN
(
"get schema version map error"
,
K
(
ret
),
K
(
hash_ret
),
K
(
tenant_id
));
}
else
if
(
OB_FAIL
(
fetch_schema_version
(
tenant_id
,
backup_schema_version
)))
{
LOG_WARN
(
"failed to fetch schema version"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
OB_FAIL
(
schema_version_map_
.
set_refactored
(
tenant_id
,
backup_schema_version
)))
{
LOG_WARN
(
"failed to set backup schema version into map"
,
K
(
ret
),
K
(
tenant_id
),
K
(
backup_schema_version
));
}
}
else
if
(
OB_FAIL
(
schema_version_map_
.
get_refactored
(
tenant_id
,
backup_schema_version
)))
{
LOG_WARN
(
"failed to get tenant schema version"
,
K
(
ret
),
K
(
tenant_id
));
}
return
ret
;
}
...
...
@@ -540,19 +550,34 @@ int ObBackupScheduler::fetch_schema_version(const uint64_t tenant_id, int64_t& b
// TODO() backup weak read without snapshot_version is wrong, fix it later
int
ret
=
OB_SUCCESS
;
backup_schema_version
=
0
;
if
(
backup_snapshot_version_
<=
0
)
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"backup snapshot version should not smaller than 0"
,
K
(
ret
),
K
(
backup_snapshot_version_
));
}
else
{
SMART_VAR
(
ObMySQLProxy
::
MySQLResult
,
res
)
{
ObMySQLResult
*
result
=
NULL
;
ObMySQLResult
*
result
=
NULL
;
ObSqlString
sql
;
bool
did_use_weak
=
true
;
bool
did_use_retry
=
false
;
bool
check_sys_variable
=
true
;
#ifdef ERRSIM
ret
=
E
(
EventTable
::
EN_BACKUP_SCHEDULER_WEAK_READ
)
OB_SUCCESS
;
LOG_INFO
(
"before set backup snapshot"
,
K
(
ret
),
K
(
backup_snapshot_version_
));
if
(
OB_SUCCESS
!=
ret
)
{
backup_snapshot_version_
=
0
;
LOG_INFO
(
"after set backup snapshot"
,
K
(
ret
),
K
(
backup_snapshot_version_
));
ret
=
OB_SUCCESS
;
}
#endif
ObSQLClientRetryWeak
sql_client_retry_weak
(
proxy_
,
did_use_weak
,
did_use_retry
,
backup_snapshot_version_
,
check_sys_variable
);
if
(
OB_FAIL
(
sql
.
append_fmt
(
"SELECT max(schema_version) as version FROM %s"
,
OB_ALL_DDL_OPERATION_TNAME
)))
{
LOG_WARN
(
"append sql failed"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
OB_FAIL
(
sql_client_retry_weak
.
read
(
res
,
tenant_id
,
sql
.
ptr
())))
{
LOG_WARN
(
"execute sql failed"
,
K
(
ret
),
K
(
tenant_id
),
K
(
sql
));
LOG_WARN
(
"execute sql failed"
,
K
(
ret
),
K
(
tenant_id
),
K
(
sql
),
K
(
backup_snapshot_version_
));
}
else
if
(
OB_UNLIKELY
(
NULL
==
(
result
=
res
.
get_result
())))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"fail to get result"
,
K
(
ret
));
...
...
@@ -579,6 +604,7 @@ int ObBackupScheduler::fetch_schema_version(const uint64_t tenant_id, int64_t& b
}
}
}
}
return
ret
;
}
...
...
@@ -942,5 +968,29 @@ int ObBackupScheduler::prepare_backup_point_(
return
ret
;
}
int
ObBackupScheduler
::
prepare_tenant_schema_version_
(
const
uint64_t
tenant_id
)
{
int
ret
=
OB_SUCCESS
;
ObSchemaGetterGuard
guard
;
int64_t
schema_version
=
0
;
const
int64_t
latest_schema_version
=
-
1
;
if
(
!
is_inited_
)
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"backup scheduler do not init"
,
K
(
ret
));
}
else
if
(
OB_INVALID_ID
==
tenant_id
)
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"prepare tenant schema version get invalid argument"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
OB_FAIL
(
ObBackupUtils
::
retry_get_tenant_schema_guard
(
tenant_id
,
*
schema_service_
,
latest_schema_version
,
guard
)))
{
LOG_WARN
(
"failed to get tenant schema guard"
,
K
(
ret
),
K
(
latest_schema_version
));
}
else
if
(
OB_FAIL
(
guard
.
get_schema_version
(
tenant_id
,
schema_version
)))
{
LOG_WARN
(
"failed to get schema version"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
OB_FAIL
(
schema_version_map_
.
set_refactored
(
tenant_id
,
schema_version
)))
{
LOG_WARN
(
"failed to set tenant schema version into map"
,
K
(
ret
),
K
(
tenant_id
),
K
(
schema_version
));
}
return
ret
;
}
}
// namespace share
}
// namespace oceanbase
src/share/backup/ob_backup_scheduler.h
浏览文件 @
69facd62
...
...
@@ -58,6 +58,7 @@ private:
int
check_log_archive_status
();
int
check_tenant_backup_data_version
(
const
uint64_t
tenant_id
,
ObBackupInfoManager
&
info_manager
,
bool
&
can_backup
);
int
prepare_backup_point_
(
const
common
::
ObIArray
<
uint64_t
>
&
tenant_ids
,
ObBackupInfoManager
&
info_manager
);
int
prepare_tenant_schema_version_
(
const
uint64_t
tenant_id
);
private:
static
const
int64_t
MAX_TENANT_BUCKET
=
1024
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录