Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
oceanbase
提交
8309758e
O
oceanbase
项目概览
oceanbase
/
oceanbase
大约 1 年 前同步成功
通知
261
Star
6084
Fork
1301
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
8309758e
编写于
2月 07, 2024
作者:
O
obdev
提交者:
ob-robot
2月 07, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Observer adapted rs wake-up transfer task retry mechanism
上级
b414155c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
73 addition
and
42 deletion
+73
-42
src/observer/ob_rpc_processor_simple.cpp
src/observer/ob_rpc_processor_simple.cpp
+10
-2
src/share/ob_rpc_struct.cpp
src/share/ob_rpc_struct.cpp
+6
-6
src/share/ob_rpc_struct.h
src/share/ob_rpc_struct.h
+5
-5
src/storage/high_availability/ob_finish_transfer.cpp
src/storage/high_availability/ob_finish_transfer.cpp
+2
-15
src/storage/high_availability/ob_ls_migration.cpp
src/storage/high_availability/ob_ls_migration.cpp
+8
-7
src/storage/high_availability/ob_ls_prepare_migration.cpp
src/storage/high_availability/ob_ls_prepare_migration.cpp
+8
-7
src/storage/high_availability/ob_storage_ha_utils.cpp
src/storage/high_availability/ob_storage_ha_utils.cpp
+33
-0
src/storage/high_availability/ob_storage_ha_utils.h
src/storage/high_availability/ob_storage_ha_utils.h
+1
-0
未找到文件。
src/observer/ob_rpc_processor_simple.cpp
浏览文件 @
8309758e
...
...
@@ -73,6 +73,7 @@
#include "sql/session/ob_sql_session_info.h"
#include "sql/session/ob_sess_info_verify.h"
#include "observer/table/ttl/ob_ttl_service.h"
#include "storage/high_availability/ob_storage_ha_utils.h"
namespace
oceanbase
{
...
...
@@ -2580,8 +2581,10 @@ int ObRpcStartTransferTaskP::process()
{
int
ret
=
OB_SUCCESS
;
ObTransferService
*
transfer_service
=
nullptr
;
if
(
OB_UNLIKELY
(
arg_
.
get_tenant_id
()
!=
MTL_ID
()))
{
const
share
::
ObLSID
&
src_ls
=
arg_
.
get_src_ls
();
const
uint64_t
tenant_id
=
arg_
.
get_tenant_id
();
bool
is_leader
=
false
;
if
(
OB_UNLIKELY
(
tenant_id
!=
MTL_ID
()))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_ERROR
(
"ObRpcStartTransferTaskP::process tenant not match"
,
KR
(
ret
),
K_
(
arg
));
}
else
if
(
OB_UNLIKELY
(
!
arg_
.
is_valid
()))
{
...
...
@@ -2590,6 +2593,11 @@ int ObRpcStartTransferTaskP::process()
}
else
if
(
OB_ISNULL
(
transfer_service
=
MTL
(
ObTransferService
*
)))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"ls service should not be null"
,
K
(
ret
),
KP
(
transfer_service
));
}
else
if
(
OB_FAIL
(
storage
::
ObStorageHAUtils
::
check_ls_is_leader
(
tenant_id
,
src_ls
,
is_leader
)))
{
LOG_WARN
(
"fail to check ls is leader"
,
K
(
ret
),
K
(
tenant_id
),
K
(
src_ls
));
}
else
if
(
!
is_leader
)
{
ret
=
OB_NOT_MASTER
;
LOG_WARN
(
"ls is not leader, please retry"
,
K
(
ret
),
K
(
is_leader
));
}
else
{
transfer_service
->
wakeup
();
}
...
...
src/share/ob_rpc_struct.cpp
浏览文件 @
8309758e
...
...
@@ -9686,23 +9686,23 @@ int ObRlsContextDDLArg::assign(const ObRlsContextDDLArg &other)
return
ret
;
}
OB_SERIALIZE_MEMBER
(
ObStartTransferTaskArg
,
tenant_id_
,
task_id_
,
dest
_ls_
);
OB_SERIALIZE_MEMBER
(
ObStartTransferTaskArg
,
tenant_id_
,
task_id_
,
src
_ls_
);
int
ObStartTransferTaskArg
::
init
(
const
uint64_t
tenant_id
,
const
ObTransferTaskID
&
task_id
,
const
ObLSID
&
dest
_ls
)
const
ObLSID
&
src
_ls
)
{
int
ret
=
OB_SUCCESS
;
if
(
OB_UNLIKELY
(
!
is_valid_tenant_id
(
tenant_id
)
||
!
task_id
.
is_valid
())
||
!
dest
_ls
.
is_valid
())
{
||
!
src
_ls
.
is_valid
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid args"
,
KR
(
ret
),
K
(
tenant_id
),
K
(
task_id
),
K
(
dest
_ls
));
LOG_WARN
(
"invalid args"
,
KR
(
ret
),
K
(
tenant_id
),
K
(
task_id
),
K
(
src
_ls
));
}
else
{
tenant_id_
=
tenant_id
;
task_id_
=
task_id
;
dest_ls_
=
dest
_ls
;
src_ls_
=
src
_ls
;
}
return
ret
;
}
...
...
@@ -9712,7 +9712,7 @@ int ObStartTransferTaskArg::assign(const ObStartTransferTaskArg &other)
int
ret
=
OB_SUCCESS
;
tenant_id_
=
other
.
tenant_id_
;
task_id_
=
other
.
task_id_
;
dest_ls_
=
other
.
dest
_ls_
;
src_ls_
=
other
.
src
_ls_
;
return
ret
;
}
...
...
src/share/ob_rpc_struct.h
浏览文件 @
8309758e
...
...
@@ -9708,20 +9708,20 @@ struct ObStartTransferTaskArg final
{
OB_UNIS_VERSION
(
1
);
public:
ObStartTransferTaskArg
()
:
tenant_id_
(
OB_INVALID_TENANT_ID
),
task_id_
(),
dest
_ls_
()
{}
ObStartTransferTaskArg
()
:
tenant_id_
(
OB_INVALID_TENANT_ID
),
task_id_
(),
src
_ls_
()
{}
~
ObStartTransferTaskArg
()
{}
int
init
(
const
uint64_t
tenant_id
,
const
share
::
ObTransferTaskID
&
task_id
,
const
share
::
ObLSID
&
dest
_ls
);
int
init
(
const
uint64_t
tenant_id
,
const
share
::
ObTransferTaskID
&
task_id
,
const
share
::
ObLSID
&
src
_ls
);
uint64_t
get_tenant_id
()
const
{
return
tenant_id_
;
}
const
share
::
ObTransferTaskID
get_task_id
()
const
{
return
task_id_
;
}
const
share
::
ObLSID
&
get_
dest_ls
()
{
return
dest
_ls_
;
}
const
share
::
ObLSID
&
get_
src_ls
()
{
return
src
_ls_
;
}
bool
is_valid
()
const
{
return
is_valid_tenant_id
(
tenant_id_
)
&&
task_id_
.
is_valid
();
}
int
assign
(
const
ObStartTransferTaskArg
&
other
);
TO_STRING_KV
(
K_
(
tenant_id
),
K_
(
task_id
),
K_
(
dest
_ls
));
TO_STRING_KV
(
K_
(
tenant_id
),
K_
(
task_id
),
K_
(
src
_ls
));
private:
uint64_t
tenant_id_
;
share
::
ObTransferTaskID
task_id_
;
share
::
ObLSID
dest
_ls_
;
share
::
ObLSID
src
_ls_
;
DISALLOW_COPY_AND_ASSIGN
(
ObStartTransferTaskArg
);
};
...
...
src/storage/high_availability/ob_finish_transfer.cpp
浏览文件 @
8309758e
...
...
@@ -961,23 +961,10 @@ int ObTxFinishTransfer::report_result_(
int
ObTxFinishTransfer
::
check_self_ls_leader_
(
const
share
::
ObLSID
&
ls_id
,
bool
&
is_leader
)
{
int
ret
=
OB_SUCCESS
;
ObRole
role
=
ObRole
::
INVALID_ROLE
;
int64_t
proposal_id
=
0
;
ObLSHandle
ls_handle
;
ObLS
*
ls
=
nullptr
;
const
uint64_t
tenant_id
=
MTL_ID
();
is_leader
=
false
;
if
(
OB_FAIL
(
get_ls_handle_
(
tenant_id
,
ls_id
,
ls_handle
)))
{
LOG_WARN
(
"failed to get ls handle"
,
K
(
ret
),
K
(
tenant_id
),
K
(
ls_id
));
}
else
if
(
OB_ISNULL
(
ls
=
ls_handle
.
get_ls
()))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"ls should not be NULL"
,
K
(
ret
),
K
(
tenant_id
),
K
(
ls_id
));
}
else
if
(
OB_FAIL
(
ls
->
get_log_handler
()
->
get_role
(
role
,
proposal_id
)))
{
LOG_WARN
(
"failed to get role"
,
K
(
ret
),
K
(
tenant_id
),
K
(
ls_id
));
}
else
if
(
is_strong_leader
(
role
))
{
is_leader
=
true
;
}
else
{
is_leader
=
false
;
if
(
OB_FAIL
(
ObStorageHAUtils
::
check_ls_is_leader
(
tenant_id
,
ls_id
,
is_leader
)))
{
LOG_WARN
(
"failed to check ls leader"
,
K
(
ret
),
K
(
tenant_id
),
K
(
ls_id
));
}
return
ret
;
}
...
...
src/storage/high_availability/ob_ls_migration.cpp
浏览文件 @
8309758e
...
...
@@ -29,6 +29,7 @@
#include "share/ls/ob_ls_table_operator.h"
#include "ob_rebuild_service.h"
#include "share/ob_cluster_version.h"
#include "ob_storage_ha_utils.h"
namespace
oceanbase
{
...
...
@@ -1042,9 +1043,8 @@ int ObStartMigrationTask::deal_with_local_ls_()
int
ret
=
OB_SUCCESS
;
ObLSHandle
ls_handle
;
ObLS
*
ls
=
nullptr
;
ObRole
role
;
int64_t
proposal_id
=
0
;
ObLSMeta
local_ls_meta
;
bool
is_leader
=
false
;
if
(
!
is_inited_
)
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"start migration task do not init"
,
K
(
ret
));
...
...
@@ -1053,18 +1053,19 @@ int ObStartMigrationTask::deal_with_local_ls_()
}
else
if
(
OB_ISNULL
(
ls
=
ls_handle
.
get_ls
()))
{
ret
=
OB_ERR_SYS
;
LOG_ERROR
(
"log stream should not be NULL"
,
K
(
ret
),
K
(
*
ctx_
));
}
else
if
(
OB_FAIL
(
ls
->
get_log_handler
()
->
get_role
(
role
,
proposal_id
)))
{
LOG_WARN
(
"failed to get role"
,
K
(
ret
),
"arg"
,
ctx_
->
arg_
);
}
else
if
(
is_strong_leader
(
role
))
{
}
else
if
(
OB_FAIL
(
ObStorageHAUtils
::
check_ls_is_leader
(
ctx_
->
tenant_id_
,
ctx_
->
arg_
.
ls_id_
,
is_leader
)))
{
LOG_WARN
(
"failed to check ls leader"
,
K
(
ret
),
KPC
(
ctx_
));
}
else
if
(
is_leader
)
{
if
(
ObMigrationOpType
::
REBUILD_LS_OP
==
ctx_
->
arg_
.
type_
)
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_ERROR
(
"leader can not as rebuild dst"
,
K
(
ret
),
K
(
role
),
"myaddr"
,
MYADDR
,
"arg"
,
ctx_
->
arg_
);
LOG_ERROR
(
"leader can not as rebuild dst"
,
K
(
ret
),
K
(
is_leader
),
"myaddr"
,
MYADDR
,
"arg"
,
ctx_
->
arg_
);
}
else
if
(
ObMigrationOpType
::
ADD_LS_OP
==
ctx_
->
arg_
.
type_
||
ObMigrationOpType
::
MIGRATE_LS_OP
==
ctx_
->
arg_
.
type_
||
ObMigrationOpType
::
CHANGE_LS_OP
==
ctx_
->
arg_
.
type_
)
{
ret
=
OB_ERR_SYS
;
LOG_WARN
(
"leader cannot as add, migrate, change dst"
,
K
(
ret
),
K
(
role
),
"myaddr"
,
MYADDR
,
"arg"
,
ctx_
->
arg_
);
K
(
ret
),
K
(
is_leader
),
"myaddr"
,
MYADDR
,
"arg"
,
ctx_
->
arg_
);
}
}
else
if
(
OB_FAIL
(
ls
->
offline
()))
{
LOG_WARN
(
"failed to disable log"
,
K
(
ret
),
KPC
(
ctx_
));
...
...
src/storage/high_availability/ob_ls_prepare_migration.cpp
浏览文件 @
8309758e
...
...
@@ -20,6 +20,7 @@
#include "ob_transfer_service.h"
#include "storage/tablet/ob_tablet.h"
#include "ob_rebuild_service.h"
#include "ob_storage_ha_utils.h"
using
namespace
oceanbase
;
using
namespace
common
;
...
...
@@ -756,8 +757,7 @@ int ObStartPrepareMigrationTask::deal_with_local_ls_()
int
ret
=
OB_SUCCESS
;
ObLSHandle
ls_handle
;
ObLS
*
ls
=
nullptr
;
ObRole
role
;
int64_t
proposal_id
=
0
;
bool
is_leader
=
false
;
ObLSSavedInfo
saved_info
;
if
(
!
is_inited_
)
{
...
...
@@ -768,18 +768,19 @@ int ObStartPrepareMigrationTask::deal_with_local_ls_()
}
else
if
(
OB_ISNULL
(
ls
=
ls_handle
.
get_ls
()))
{
ret
=
OB_ERR_SYS
;
LOG_ERROR
(
"log stream should not be NULL"
,
K
(
ret
),
K
(
*
ctx_
));
}
else
if
(
OB_FAIL
(
ls
->
get_log_handler
()
->
get_role
(
role
,
proposal_id
)))
{
LOG_WARN
(
"failed to get role"
,
K
(
ret
),
"arg"
,
ctx_
->
arg_
);
}
else
if
(
is_strong_leader
(
role
))
{
}
else
if
(
OB_FAIL
(
ObStorageHAUtils
::
check_ls_is_leader
(
ctx_
->
tenant_id_
,
ctx_
->
arg_
.
ls_id_
,
is_leader
)))
{
LOG_WARN
(
"failed to check ls leader"
,
K
(
ret
),
KPC
(
ctx_
));
}
else
if
(
is_leader
)
{
if
(
ObMigrationOpType
::
REBUILD_LS_OP
==
ctx_
->
arg_
.
type_
)
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_ERROR
(
"leader can not as rebuild dst"
,
K
(
ret
),
K
(
role
),
"myaddr"
,
MYADDR
,
"arg"
,
ctx_
->
arg_
);
LOG_ERROR
(
"leader can not as rebuild dst"
,
K
(
ret
),
K
(
is_leader
),
"myaddr"
,
MYADDR
,
"arg"
,
ctx_
->
arg_
);
}
else
if
(
ObMigrationOpType
::
ADD_LS_OP
==
ctx_
->
arg_
.
type_
||
ObMigrationOpType
::
MIGRATE_LS_OP
==
ctx_
->
arg_
.
type_
||
ObMigrationOpType
::
CHANGE_LS_OP
==
ctx_
->
arg_
.
type_
)
{
ret
=
OB_ERR_SYS
;
LOG_WARN
(
"leader cannot as add, migrate, change dst"
,
K
(
ret
),
K
(
role
),
"myaddr"
,
MYADDR
,
"arg"
,
ctx_
->
arg_
);
K
(
ret
),
K
(
is_leader
),
"myaddr"
,
MYADDR
,
"arg"
,
ctx_
->
arg_
);
}
}
...
...
src/storage/high_availability/ob_storage_ha_utils.cpp
浏览文件 @
8309758e
...
...
@@ -34,6 +34,7 @@
#include "rootserver/ob_tenant_info_loader.h"
#include "src/observer/omt/ob_tenant_config.h"
#include "common/errsim_module/ob_errsim_module_type.h"
#include "common/ob_role.h"
using
namespace
oceanbase
::
share
;
...
...
@@ -382,6 +383,38 @@ int ObStorageHAUtils::calc_tablet_sstable_macro_block_cnt(
return
ret
;
}
int
ObStorageHAUtils
::
check_ls_is_leader
(
const
uint64_t
tenant_id
,
const
share
::
ObLSID
&
ls_id
,
bool
&
is_leader
)
{
int
ret
=
OB_SUCCESS
;
ObLSService
*
ls_srv
=
NULL
;
common
::
ObRole
role
=
common
::
ObRole
::
INVALID_ROLE
;
int64_t
proposal_id
=
0
;
ObLSHandle
ls_handle
;
ObLS
*
ls
=
nullptr
;
is_leader
=
false
;
if
(
OB_INVALID_ID
==
tenant_id
||
!
ls_id
.
is_valid
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid argument"
,
K
(
ret
),
K
(
ls_id
));
}
else
if
(
OB_ISNULL
(
ls_srv
=
MTL_WITH_CHECK_TENANT
(
ObLSService
*
,
tenant_id
)))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"log stream service is NULL"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
OB_FAIL
(
ls_srv
->
get_ls
(
ls_id
,
ls_handle
,
ObLSGetMod
::
STORAGE_MOD
)))
{
LOG_WARN
(
"failed to get log stream"
,
K
(
ret
),
K
(
tenant_id
),
K
(
ls_id
));
}
else
if
(
OB_ISNULL
(
ls
=
ls_handle
.
get_ls
()))
{
LOG_WARN
(
"ls should not be null"
,
K
(
ret
),
KP
(
ls
));
}
else
if
(
OB_FAIL
(
ls
->
get_log_handler
()
->
get_role
(
role
,
proposal_id
)))
{
LOG_WARN
(
"failed to get role"
,
K
(
ret
),
KP
(
ls
));
}
else
if
(
is_strong_leader
(
role
))
{
is_leader
=
true
;
}
else
{
is_leader
=
false
;
}
return
ret
;
}
bool
ObTransferUtils
::
is_need_retry_error
(
const
int
err
)
{
bool
bool_ret
=
false
;
...
...
src/storage/high_availability/ob_storage_ha_utils.h
浏览文件 @
8309758e
...
...
@@ -46,6 +46,7 @@ public:
static
int64_t
get_rpc_timeout
();
static
int
check_is_primary_tenant
(
const
uint64_t
tenant_id
,
bool
&
is_primary_tenant
);
static
int
check_disk_space
();
static
int
check_ls_is_leader
(
const
uint64_t
tenant_id
,
const
share
::
ObLSID
&
ls_id
,
bool
&
is_leader
);
static
int
calc_tablet_sstable_macro_block_cnt
(
const
ObTabletHandle
&
tablet_handle
,
int64_t
&
data_macro_block_count
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录