Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
caoersss
oceanbase
提交
65502050
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,发现更多精彩内容 >>
提交
65502050
编写于
3月 17, 2022
作者:
J
JiahuaChen
提交者:
LINGuanRen
3月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix slog reader doesnt switch file when theres no switch log at EOF
上级
9aa337ba
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
98 addition
and
5 deletion
+98
-5
src/storage/blocksstable/slog/ob_storage_log_reader.cpp
src/storage/blocksstable/slog/ob_storage_log_reader.cpp
+5
-3
unittest/storage/blocksstable/slog/test_storage_log_reader_writer.cpp
...rage/blocksstable/slog/test_storage_log_reader_writer.cpp
+93
-2
未找到文件。
src/storage/blocksstable/slog/ob_storage_log_reader.cpp
浏览文件 @
65502050
...
@@ -437,10 +437,12 @@ int ObStorageLogReader::load_buf()
...
@@ -437,10 +437,12 @@ int ObStorageLogReader::load_buf()
int
ObStorageLogReader
::
check_switch_file
(
const
int
get_ret
,
const
LogCommand
cmd
)
int
ObStorageLogReader
::
check_switch_file
(
const
int
get_ret
,
const
LogCommand
cmd
)
{
{
int
ret
=
get_ret
;
int
ret
=
get_ret
;
// Check switch file when meet below situation:
const
bool
fetch_log_again
=
(
OB_READ_NOTHING
==
get_ret
);
// 1) Meet switch log command
// Check switch file when meet below 2 situation:
// 1) Meet switch log command, or
// 2) read the last log (which may be incomplete and ignored)
// Otherwise directly ret
// Otherwise directly ret
if
(
common
::
OB_SUCCESS
==
get_ret
&&
OB_LOG_SWITCH_LOG
==
cmd
)
{
if
(
(
common
::
OB_SUCCESS
==
get_ret
&&
OB_LOG_SWITCH_LOG
==
cmd
)
||
fetch_log_again
)
{
STORAGE_REDO_LOG
(
INFO
,
"reach the end of log"
,
K_
(
file_id
));
STORAGE_REDO_LOG
(
INFO
,
"reach the end of log"
,
K_
(
file_id
));
if
(
OB_FAIL
(
close
()))
{
if
(
OB_FAIL
(
close
()))
{
STORAGE_REDO_LOG
(
ERROR
,
"close error"
,
K
(
ret
));
STORAGE_REDO_LOG
(
ERROR
,
"close error"
,
K
(
ret
));
...
...
unittest/storage/blocksstable/slog/test_storage_log_reader_writer.cpp
浏览文件 @
65502050
...
@@ -863,9 +863,100 @@ TEST_F(TestStorageLogReaderWriter, seek_to_end)
...
@@ -863,9 +863,100 @@ TEST_F(TestStorageLogReaderWriter, seek_to_end)
ASSERT_EQ
(
1
,
cnt
);
ASSERT_EQ
(
1
,
cnt
);
ret
=
reader
.
get_next_cursor
(
read_cursor
);
ret
=
reader
.
get_next_cursor
(
read_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
LOG_FILE_ID
,
read_cursor
.
file_id_
);
ASSERT_EQ
(
LOG_FILE_ID
+
1
,
read_cursor
.
file_id_
);
ASSERT_EQ
(
LOG_START_SEQ
+
2
,
read_cursor
.
log_id_
);
ASSERT_EQ
(
LOG_START_SEQ
+
2
,
read_cursor
.
log_id_
);
ASSERT_EQ
(
4096
*
2
,
read_cursor
.
offset_
);
ASSERT_EQ
(
0
,
read_cursor
.
offset_
);
}
TEST_F
(
TestStorageLogReaderWriter
,
read_multiple_files
)
{
int
ret
=
OB_SUCCESS
;
const
char
LOG_DIR
[
512
]
=
"./test_storage_log_rw"
;
const
int64_t
LOG_FILE_SIZE
=
64
<<
20
;
// 64MB
const
int64_t
CONCURRENT_TRANS_CNT
=
128
;
const
int64_t
LOG_BUFFER_SIZE
=
1966080L
;
// 1.875MB
const
int64_t
log_cnt_per_file
=
10
;
// write part
ObLogCursor
start_cursor
;
start_cursor
.
file_id_
=
1
;
start_cursor
.
log_id_
=
1
;
start_cursor
.
offset_
=
0
;
char
write_data
[
128
]
=
"this is read multiple files test."
;
ObBaseStorageLogBuffer
log_buf
;
ret
=
log_buf
.
assign
(
write_data
,
1024
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ret
=
log_buf
.
set_pos
(
strlen
(
write_data
));
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ObStorageLogWriter
writer
;
ret
=
writer
.
init
(
LOG_DIR
,
LOG_FILE_SIZE
,
LOG_BUFFER_SIZE
,
CONCURRENT_TRANS_CNT
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ret
=
writer
.
start_log
(
start_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
for
(
int64_t
i
=
0
;
i
<
log_cnt_per_file
;
++
i
)
{
ret
=
writer
.
flush_log
(
LogCommand
::
OB_LOG_DUMMY_LOG
,
log_buf
,
start_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
}
start_cursor
.
file_id_
=
2
;
start_cursor
.
offset_
=
0
;
start_cursor
.
log_id_
=
writer
.
get_cur_cursor
().
log_id_
;
writer
.
destroy
();
// manually switch file
ret
=
writer
.
init
(
LOG_DIR
,
LOG_FILE_SIZE
,
LOG_BUFFER_SIZE
,
CONCURRENT_TRANS_CNT
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ret
=
writer
.
start_log
(
start_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
for
(
int64_t
i
=
0
;
i
<
log_cnt_per_file
;
++
i
)
{
ret
=
writer
.
flush_log
(
LogCommand
::
OB_LOG_DUMMY_LOG
,
log_buf
,
start_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
}
writer
.
destroy
();
// read part
LogCommand
cmd
=
LogCommand
::
OB_LOG_UNKNOWN
;
uint64_t
seq
=
0
;
int64_t
read_len
=
0
;
char
*
read_data
=
NULL
;
ObLogCursor
read_cursor
;
ObStorageLogReader
reader
;
ret
=
reader
.
init
(
LOG_DIR
,
1
,
0
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
while
(
OB_SUCCESS
==
ret
)
{
// read dummy log
ret
=
reader
.
read_log
(
cmd
,
seq
,
read_data
,
read_len
);
}
ASSERT_EQ
(
OB_READ_NOTHING
,
ret
);
ret
=
reader
.
get_cursor
(
read_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
start_cursor
.
file_id_
+
1
,
read_cursor
.
file_id_
);
ASSERT_EQ
(
0
,
read_cursor
.
offset_
);
ASSERT_EQ
(
start_cursor
.
log_id_
+
1
,
read_cursor
.
log_id_
);
reader
.
reset
();
// read start from the end of file 1
ret
=
reader
.
init
(
LOG_DIR
,
1
,
21
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
while
(
OB_SUCCESS
==
ret
)
{
// read dummy log
ret
=
reader
.
read_log
(
cmd
,
seq
,
read_data
,
read_len
);
}
ASSERT_EQ
(
OB_READ_NOTHING
,
ret
);
ret
=
reader
.
get_cursor
(
read_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
start_cursor
.
file_id_
+
1
,
read_cursor
.
file_id_
);
ASSERT_EQ
(
0
,
read_cursor
.
offset_
);
ASSERT_EQ
(
start_cursor
.
log_id_
+
1
,
read_cursor
.
log_id_
);
reader
.
reset
();
}
}
}
// namespace blocksstable
}
// namespace blocksstable
}
// namespace oceanbase
}
// namespace oceanbase
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录