Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
ffd7bbdd
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看板
提交
ffd7bbdd
编写于
9月 06, 2021
作者:
D
dt0
提交者:
wangzelin.wzl
9月 06, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add last_restore_log_id clear trans for pg restored from 2.x
上级
2c57ef86
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
23 deletion
+45
-23
src/storage/ob_partition_group.cpp
src/storage/ob_partition_group.cpp
+8
-10
src/storage/transaction/ob_trans_ctx_mgr.h
src/storage/transaction/ob_trans_ctx_mgr.h
+1
-1
src/storage/transaction/ob_trans_part_ctx.cpp
src/storage/transaction/ob_trans_part_ctx.cpp
+35
-11
src/storage/transaction/ob_trans_part_ctx.h
src/storage/transaction/ob_trans_part_ctx.h
+1
-1
未找到文件。
src/storage/ob_partition_group.cpp
浏览文件 @
ffd7bbdd
...
...
@@ -6025,16 +6025,14 @@ int ObPartitionGroup::clear_trans_after_restore_log(const uint64_t last_restore_
}
else
if
(
OB_UNLIKELY
(
OB_INVALID_ID
==
last_restore_log_id
)
||
OB_UNLIKELY
(
OB_INVALID_TIMESTAMP
==
last_restore_log_ts
))
{
ret
=
OB_INVALID_ARGUMENT
;
STORAGE_LOG
(
WARN
,
"invalid last_restore_log_info"
,
KR
(
ret
),
K_
(
pkey
),
K
(
last_restore_log_id
),
K
(
last_restore_log_ts
));
}
else
if
(
OB_FAIL
(
pg_storage_
.
set_last_restore_log_info
(
last_restore_log_id
,
last_restore_log_ts
)))
{
STORAGE_LOG
(
WARN
,
"failed to set_last_restore_log_info"
,
K
(
ret
),
K_
(
pkey
),
K
(
last_restore_log_id
),
K
(
last_restore_log_ts
));
}
else
if
(
OB_FAIL
(
txs_
->
set_last_restore_log_info
(
pkey_
,
last_restore_log_id
,
last_restore_log_ts
)))
{
STORAGE_LOG
(
WARN
,
"failed to set_last_restore_log_ts"
,
KR
(
ret
),
K_
(
pkey
),
K
(
last_restore_log_id
),
K
(
last_restore_log_ts
));
STORAGE_LOG
(
WARN
,
"invalid last_restore_log_info"
,
KR
(
ret
),
K_
(
pkey
),
K
(
last_restore_log_id
),
K
(
last_restore_log_ts
));
}
else
if
(
OB_FAIL
(
pg_storage_
.
set_last_restore_log_info
(
last_restore_log_id
,
last_restore_log_ts
)))
{
STORAGE_LOG
(
WARN
,
"failed to set_last_restore_log_info"
,
K
(
ret
),
K_
(
pkey
),
K
(
last_restore_log_id
),
K
(
last_restore_log_ts
));
}
else
if
(
OB_FAIL
(
txs_
->
set_last_restore_log_info
(
pkey_
,
last_restore_log_id
,
last_restore_log_ts
)))
{
STORAGE_LOG
(
WARN
,
"failed to set_last_restore_log_info"
,
KR
(
ret
),
K_
(
pkey
),
K
(
last_restore_log_id
),
K
(
last_restore_log_ts
));
}
else
{
ATOMIC_SET
(
&
has_clear_trans_after_restore_
,
true
);
}
...
...
src/storage/transaction/ob_trans_ctx_mgr.h
浏览文件 @
ffd7bbdd
...
...
@@ -612,7 +612,7 @@ private:
// it is used to record the last restore log id pulling by physical backup and recovery
uint64_t
last_restore_log_id_
;
// it is used to record the last restore log ts pulling by physical backup and recovery
u
int64_t
last_restore_log_ts_
;
int64_t
last_restore_log_ts_
;
// the statistics for elr
// number of trans with prev
uint64_t
with_dependency_trx_count_
;
...
...
src/storage/transaction/ob_trans_part_ctx.cpp
浏览文件 @
ffd7bbdd
...
...
@@ -4123,21 +4123,35 @@ int ObPartTransCtx::replay_commit_log(const ObTransCommitLog& log, const int64_t
return
ret
;
}
// For pg restored in 3.x, restore_snapshot_version and last_restore_log_ts is used to
// rollback trans which is restored and superfluous
//
// For pg restored in 2.x, last_restore_log_id is used instead of last_restore_log_ts,
// as last_restore_log_ts is not maintained in pg restored from 2.x
bool
ObPartTransCtx
::
need_rollback_when_restore_
(
const
int64_t
commit_version
)
{
bool
bret
=
false
;
const
int64_t
restore_snapshot_version
=
partition_mgr_
->
get_restore_snapshot_version
();
const
uint64_t
last_restore_log_id
=
partition_mgr_
->
get_last_restore_log_id
();
return
restore_snapshot_version
>
0
&&
(
last_restore_log_id
==
OB_INVALID_ID
||
min_log_id_
<=
last_restore_log_id
)
&&
commit_version
>
restore_snapshot_version
;
const
int64_t
last_restore_log_ts
=
partition_mgr_
->
get_last_restore_log_ts
();
// restore_snapshot_version is invalid, all trans need not rollback
if
(
OB_INVALID_TIMESTAMP
==
restore_snapshot_version
)
{
bret
=
false
;
}
else
if
(
OB_INVALID_TIMESTAMP
!=
last_restore_log_ts
)
{
// last_restore_log_ts is valid, pg is restored in 3.x
bret
=
min_log_ts_
<=
last_restore_log_ts
&&
commit_version
>
restore_snapshot_version
;
}
else
if
(
OB_INVALID_ID
!=
last_restore_log_id
)
{
// last_restore_log_ts is invalid and last_restore_log_id is valid, pg is restored in 2.x
bret
=
min_log_id_
<=
last_restore_log_id
&&
commit_version
>
restore_snapshot_version
;
}
else
{
// last_restore_log_ts and last_restore_log_id are invalid, pg is in restoring
bret
=
commit_version
>
restore_snapshot_version
;
}
return
bret
;
}
// TODO: duotian
bool
ObPartTransCtx
::
need_update_schema_version
(
const
int64_t
log_id
,
const
int64_t
log_ts
)
bool
ObPartTransCtx
::
need_update_schema_version
(
const
uint64_t
log_id
,
const
int64_t
log_ts
)
{
UNUSED
(
log_id
);
UNUSED
(
log_ts
);
/*
const
int64_t
restore_snapshot_version
=
partition_mgr_
->
get_restore_snapshot_version
();
const
int64_t
last_restore_log_id
=
partition_mgr_
->
get_last_restore_log_id
();
bool
need_update
=
true
;
...
...
@@ -4146,8 +4160,6 @@ bool ObPartTransCtx::need_update_schema_version(const int64_t log_id, const int6
need_update
=
false
;
}
return
need_update
;
*/
return
true
;
}
int
ObPartTransCtx
::
trans_replay_commit_
(
const
int64_t
commit_version
,
const
int64_t
checksum
)
...
...
@@ -11800,6 +11812,7 @@ void ObPartTransCtx::get_audit_info(int64_t& lock_for_read_elapse) const
// which transactions should be kept and the log ts who is the last log ts during
// restore phase. fake_terminate_log_ts is mocked as terminate_log_ts of
// aborted dirty transaction. (See details in ObPartTransCtx::fake_kill_).
// For pg restored from 2.x, last_restore_log_id is used instead of last_restore_log_ts
// NB: We should also take dirty txn into account. Of course, Dirty txns are
// more complicated. For example, the transaction status of dirty txn may be
...
...
@@ -11811,8 +11824,19 @@ int ObPartTransCtx::clear_trans_after_restore(const int64_t restore_version, con
const
int64_t
last_restore_log_ts
,
const
int64_t
fake_terminate_log_ts
)
{
int
ret
=
OB_SUCCESS
;
bool
need_clear
=
false
;
CtxLockGuard
guard
(
lock_
);
const
int64_t
state
=
get_state_
();
{
// For pg restored from 2.x, last_restore_log_ts is invalid and last_restore_log_id is valid
if
(
OB_INVALID_TIMESTAMP
==
last_restore_log_ts
)
{
if
(
cluster_version_
<
CLUSTER_VERSION_3000
&&
OB_INVALID_ID
!=
last_restore_log_id
)
{
need_clear
=
min_log_id_
<=
last_restore_log_id
;
}
}
else
{
need_clear
=
min_log_ts_
<=
last_restore_log_ts
;
}
}
if
(
IS_NOT_INIT
)
{
// skip the uninitialized transactions
ret
=
OB_SUCCESS
;
...
...
@@ -11823,7 +11847,7 @@ int ObPartTransCtx::clear_trans_after_restore(const int64_t restore_version, con
K
(
last_restore_log_id
),
K
(
last_restore_log_ts
),
K
(
fake_terminate_log_ts
));
}
else
if
(
min_log_id_
>
last_restore_log_id
)
{
}
else
if
(
!
need_clear
)
{
// skip new transactions after restore completes
ret
=
OB_SUCCESS
;
TRANS_LOG
(
INFO
,
...
...
src/storage/transaction/ob_trans_part_ctx.h
浏览文件 @
ffd7bbdd
...
...
@@ -389,7 +389,7 @@ public:
bool
is_in_trans_table_state
();
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
int64_t
log_id
,
const
int64_t
log_ts
);
bool
need_update_schema_version
(
const
u
int64_t
log_id
,
const
int64_t
log_ts
);
public:
INHERIT_TO_STRING_KV
(
"ObDistTransCtx"
,
ObDistTransCtx
,
K_
(
snapshot_version
),
K_
(
local_trans_version
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录