Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大炮V587
oceanbase
提交
fc105242
O
oceanbase
项目概览
大炮V587
/
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,发现更多精彩内容 >>
提交
fc105242
编写于
3月 15, 2022
作者:
H
handora
提交者:
LINGuanRen
3月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix max majority too much when switch leader to follower
上级
fb27693f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
61 addition
and
6 deletion
+61
-6
src/clog/ob_log_sliding_window.cpp
src/clog/ob_log_sliding_window.cpp
+3
-1
src/clog/ob_partition_log_service.cpp
src/clog/ob_partition_log_service.cpp
+5
-0
src/clog/ob_partition_log_service.h
src/clog/ob_partition_log_service.h
+2
-0
src/storage/ob_i_partition_group.h
src/storage/ob_i_partition_group.h
+1
-0
src/storage/ob_partition_group.cpp
src/storage/ob_partition_group.cpp
+15
-5
src/storage/ob_partition_group.h
src/storage/ob_partition_group.h
+1
-0
src/storage/transaction/ob_trans_part_ctx.cpp
src/storage/transaction/ob_trans_part_ctx.cpp
+27
-0
src/storage/transaction/ob_trans_part_ctx.h
src/storage/transaction/ob_trans_part_ctx.h
+1
-0
unittest/clog/mock_ob_partition_log_service.h
unittest/clog/mock_ob_partition_log_service.h
+5
-0
unittest/storage/mockcontainer/mock_ob_partition.h
unittest/storage/mockcontainer/mock_ob_partition.h
+1
-0
未找到文件。
src/clog/ob_log_sliding_window.cpp
浏览文件 @
fc105242
...
...
@@ -3155,11 +3155,13 @@ int ObLogSlidingWindow::majority_cb(
ret
=
OB_ERR_NULL_VALUE
;
}
else
{
log_task
=
static_cast
<
ObLogTask
*>
(
log_data
);
try_update_max_majority_log
(
log_id
,
log_task
->
get_submit_timestamp
());
if
(
OB_FAIL
(
log_task
->
submit_log_succ_cb
(
partition_key_
,
log_id
,
batch_committed
,
batch_first_participant
)))
{
CLOG_LOG
(
WARN
,
"submit log majority_cb failed"
,
K
(
ret
),
K_
(
partition_key
),
K
(
log_id
),
K
(
batch_committed
));
ret
=
OB_SUCCESS
;
}
if
(
ObLogType
::
OB_LOG_START_MEMBERSHIP
!=
log_task
->
get_log_type
())
{
try_update_max_majority_log
(
log_id
,
log_task
->
get_submit_timestamp
());
}
}
if
(
NULL
!=
ref
&&
OB_SUCCESS
!=
(
tmp_ret
=
sw_
.
revert
(
ref
)))
{
CLOG_LOG
(
ERROR
,
"revert failed"
,
K_
(
partition_key
),
K
(
tmp_ret
));
...
...
src/clog/ob_partition_log_service.cpp
浏览文件 @
fc105242
...
...
@@ -8161,6 +8161,11 @@ int ObPartitionLogService::process_check_rebuild_req(
return
ret
;
}
void
ObPartitionLogService
::
try_update_max_majority_log
(
const
uint64_t
log_id
,
const
int64_t
log_ts
)
{
sw_
.
try_update_max_majority_log
(
log_id
,
log_ts
);
}
void
ObPartitionLogService
::
get_max_majority_log
(
uint64_t
&
log_id
,
int64_t
&
log_ts
)
const
{
sw_
.
get_max_majority_log
(
log_id
,
log_ts
);
...
...
src/clog/ob_partition_log_service.h
浏览文件 @
fc105242
...
...
@@ -476,6 +476,7 @@ public:
virtual
int
process_check_rebuild_req
(
const
common
::
ObAddr
&
server
,
const
uint64_t
start_log_id
,
const
int64_t
cluster_id
)
=
0
;
virtual
void
get_max_majority_log
(
uint64_t
&
log_id
,
int64_t
&
log_ts
)
const
=
0
;
virtual
void
try_update_max_majority_log
(
const
uint64_t
log_id
,
const
int64_t
log_ts
)
=
0
;
virtual
int
set_archive_restore_state
(
const
int16_t
archive_restore_state
)
=
0
;
virtual
uint64_t
get_max_confirmed_log_id
()
const
=
0
;
virtual
bool
is_archive_restoring
()
const
=
0
;
...
...
@@ -700,6 +701,7 @@ public:
virtual
int
process_check_rebuild_req
(
const
common
::
ObAddr
&
server
,
const
uint64_t
start_log_id
,
const
int64_t
cluster_id
)
override
;
virtual
void
get_max_majority_log
(
uint64_t
&
log_id
,
int64_t
&
log_ts
)
const
override
;
virtual
void
try_update_max_majority_log
(
const
uint64_t
log_id
,
const
int64_t
log_ts
)
override
;
virtual
uint64_t
get_max_confirmed_log_id
()
const
override
;
public:
...
...
src/storage/ob_i_partition_group.h
浏览文件 @
fc105242
...
...
@@ -523,6 +523,7 @@ public:
virtual
int
reset_for_replay
()
=
0
;
virtual
int
inc_pending_batch_commit_count
(
memtable
::
ObMemtableCtx
&
mt_ctx
,
const
int64_t
log_ts
)
=
0
;
virtual
int
inc_pending_elr_count
(
memtable
::
ObMemtableCtx
&
mt_ctx
,
const
int64_t
log_ts
)
=
0
;
virtual
int
update_max_majority_log
(
const
uint64_t
log_id
,
const
int64_t
log_ts
)
=
0
;
TO_STRING_KV
(
K_
(
ref_cnt
));
protected:
...
...
src/storage/ob_partition_group.cpp
浏览文件 @
fc105242
...
...
@@ -3451,8 +3451,7 @@ int ObPartitionGroup::get_freeze_cut_(ObMemtable& frozen_memtable, const bool is
// max_log_ts as overflow(the requirement from the storage layer). while
// the data may already synced and we have no chance to mark the data
// except traversing all data in the memtable. So we choose to mark the
// end_log_ts as the max_majority_log_ts as well. The detailed issue can
// be found in https://work.aone.alibaba-inc.com/issue/33865988
// end_log_ts as the max_majority_log_ts as well.
//
// NB: we never maintain the max_mjority_log_ts for follower, so we just
// use the variable for the corner case of leader transfer.
...
...
@@ -3940,11 +3939,8 @@ int ObPartitionGroup::freeze(const bool emergency, const bool force, int64_t& fr
ObPartitionGroupLockGuard
guard
(
lock_
,
0
,
PGLOCKSTORAGE
);
if
(
with_data_
())
{
// https://open.oceanbase.com/docs/community/oceanbase-database/V3.1.1/replica-overview
// FULL(F)/ READONLY(R)replica have sstable and memtable, need to be frozen
ret
=
freeze_log_and_data_v2_
(
emergency
,
force
,
freeze_snapshot
);
}
else
{
// LOGONLY(L)replica or empty PG
ret
=
freeze_log_
(
force
);
}
...
...
@@ -6124,5 +6120,19 @@ int ObPartitionGroup::inc_pending_elr_count(memtable::ObMemtableCtx& mt_ctx, con
return
ret
;
}
int
ObPartitionGroup
::
update_max_majority_log
(
const
uint64_t
log_id
,
const
int64_t
log_ts
)
{
int
ret
=
OB_SUCCESS
;
if
(
OB_UNLIKELY
(
!
is_inited_
))
{
ret
=
OB_NOT_INIT
;
STORAGE_LOG
(
WARN
,
"Partition object not initialized"
,
K
(
ret
),
K
(
is_inited_
));
}
else
{
pls_
->
try_update_max_majority_log
(
log_id
,
log_ts
);
}
return
ret
;
}
}
// namespace storage
}
// end of namespace oceanbase
src/storage/ob_partition_group.h
浏览文件 @
fc105242
...
...
@@ -434,6 +434,7 @@ public:
virtual
int
register_txs_change_leader
(
const
common
::
ObAddr
&
server
,
ObTsWindows
&
changing_leader_windows
)
override
;
virtual
int
check_physical_split
(
bool
&
finished
)
override
;
virtual
int
update_max_majority_log
(
const
uint64_t
log_id
,
const
int64_t
log_ts
)
override
;
TO_STRING_KV
(
K_
(
pkey
),
K_
(
replay_status
),
K_
(
partition_state
));
private:
...
...
src/storage/transaction/ob_trans_part_ctx.cpp
浏览文件 @
fc105242
...
...
@@ -4779,11 +4779,38 @@ int ObPartTransCtx::replay_start_working_log(const int64_t timestamp, const uint
TRANS_STAT_ABORT_TRANS_INC
(
tenant_id_
);
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
update_max_majority_log
(
log_id
,
timestamp
)))
{
TRANS_LOG
(
ERROR
,
"update max majority log failed"
,
K
(
ret
),
K
(
*
this
));
}
}
REC_TRANS_TRACE_EXT
(
tlog_
,
replay_start_working_log
,
OB_ID
(
ret
),
ret
,
OB_ID
(
uref
),
get_uref
());
return
ret
;
}
int
ObPartTransCtx
::
update_max_majority_log
(
const
uint64_t
log_id
,
const
int64_t
log_ts
)
{
int
ret
=
OB_SUCCESS
;
storage
::
ObIPartitionGroupGuard
pg_guard
;
if
(
OB_NOT_NULL
(
pg_
))
{
if
(
OB_FAIL
(
pg_
->
update_max_majority_log
(
log_id
,
log_ts
)))
{
TRANS_LOG
(
WARN
,
"update max majority log error"
,
K
(
*
this
));
}
}
else
if
(
OB_FAIL
(
partition_service_
->
get_partition
(
self_
,
pg_guard
)))
{
TRANS_LOG
(
WARN
,
"get partition error"
,
KR
(
ret
),
"context"
,
*
this
);
}
else
if
(
NULL
==
pg_guard
.
get_partition_group
())
{
TRANS_LOG
(
ERROR
,
"partition is null, unexpected error"
,
KP
(
pg_guard
.
get_partition_group
()),
"context"
,
*
this
);
ret
=
OB_ERR_UNEXPECTED
;
}
else
if
(
OB_FAIL
(
pg_guard
.
get_partition_group
()
->
update_max_majority_log
(
log_id
,
log_ts
)))
{
TRANS_LOG
(
WARN
,
"update max majority log error"
,
K
(
*
this
));
}
return
ret
;
}
// The txn that have been prepared but not yet committed
bool
ObPartTransCtx
::
is_prepared
()
const
{
...
...
src/storage/transaction/ob_trans_part_ctx.h
浏览文件 @
fc105242
...
...
@@ -390,6 +390,7 @@ public:
virtual
int64_t
get_part_trans_action
()
const
override
;
int
rollback_stmt
(
const
int64_t
from_sql_no
,
const
int64_t
to_sql_no
);
bool
need_update_schema_version
(
const
uint64_t
log_id
,
const
int64_t
log_ts
);
int
update_max_majority_log
(
const
uint64_t
log_id
,
const
int64_t
log_ts
);
public:
INHERIT_TO_STRING_KV
(
"ObDistTransCtx"
,
ObDistTransCtx
,
K_
(
snapshot_version
),
K_
(
local_trans_version
),
...
...
unittest/clog/mock_ob_partition_log_service.h
浏览文件 @
fc105242
...
...
@@ -189,6 +189,11 @@ public:
UNUSED
(
idc
);
return
OB_SUCCESS
;
}
virtual
void
try_update_max_majority_log
(
const
uint64_t
log_id
,
const
int64_t
log_ts
)
{
UNUSED
(
log_id
);
UNUSED
(
log_ts
);
}
virtual
int
fetch_register_server_resp_v2
(
const
common
::
ObAddr
&
sender
,
const
bool
is_assign_parent_succeed
,
const
share
::
ObCascadMemberList
&
candidate_list
,
const
int32_t
msg_type
)
{
...
...
unittest/storage/mockcontainer/mock_ob_partition.h
浏览文件 @
fc105242
...
...
@@ -249,6 +249,7 @@ public:
MOCK_METHOD1
(
get_checkpoint
,
int
(
int64_t
&
checkpoint
));
MOCK_METHOD1
(
update_last_checkpoint
,
int
(
const
int64_t
checkpoint
));
MOCK_METHOD1
(
set_replay_checkpoint
,
int
(
const
int64_t
checkpoint
));
MOCK_METHOD2
(
update_max_majority_log
,
int
(
const
uint64_t
log_id
,
const
int64_t
log_ts
));
// MOCK_METHOD1(get_replay_checkpoint, int(int64_t &checkpoint));
int
get_replay_checkpoint
(
int64_t
&
checkpoint
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录