Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
49242ede
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看板
提交
49242ede
编写于
4月 14, 2022
作者:
C
cw0
提交者:
LINGuanRen
4月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix slog switch_file bug
上级
8958d59b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
134 addition
and
0 deletion
+134
-0
src/storage/blocksstable/slog/ob_storage_log_reader.cpp
src/storage/blocksstable/slog/ob_storage_log_reader.cpp
+3
-0
unittest/storage/blocksstable/slog/test_storage_log_reader_writer.cpp
...rage/blocksstable/slog/test_storage_log_reader_writer.cpp
+131
-0
未找到文件。
src/storage/blocksstable/slog/ob_storage_log_reader.cpp
浏览文件 @
49242ede
...
@@ -453,6 +453,9 @@ int ObStorageLogReader::check_switch_file(const int get_ret, const LogCommand cm
...
@@ -453,6 +453,9 @@ int ObStorageLogReader::check_switch_file(const int get_ret, const LogCommand cm
if
(
OB_READ_NOTHING
!=
ret
)
{
if
(
OB_READ_NOTHING
!=
ret
)
{
STORAGE_REDO_LOG
(
WARN
,
"open next log failed"
,
K_
(
file_id
),
K
(
ret
));
STORAGE_REDO_LOG
(
WARN
,
"open next log failed"
,
K_
(
file_id
),
K
(
ret
));
}
}
}
else
if
(
fetch_log_again
)
{
ret
=
OB_EAGAIN
;
STORAGE_REDO_LOG
(
INFO
,
"fetch log again"
,
K
(
file_id_
),
K
(
log_buffer_
));
}
}
}
}
}
}
...
...
unittest/storage/blocksstable/slog/test_storage_log_reader_writer.cpp
浏览文件 @
49242ede
...
@@ -227,6 +227,137 @@ TEST_F(TestStorageLogReaderWriter, normal)
...
@@ -227,6 +227,137 @@ TEST_F(TestStorageLogReaderWriter, normal)
OB_LOG
(
INFO
,
"read log "
,
K
(
read_cursor
));
OB_LOG
(
INFO
,
"read log "
,
K
(
read_cursor
));
}
}
TEST_F
(
TestStorageLogReaderWriter
,
two_slog_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
// write part
ObLogCursor
start_cursor
;
start_cursor
.
file_id_
=
1
;
start_cursor
.
log_id_
=
1
;
start_cursor
.
offset_
=
0
;
char
write_data
[
1024
]
=
"this is slog read write 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
;
writer
.
init
(
LOG_DIR
,
LOG_FILE_SIZE
,
LOG_BUFFER_SIZE
,
CONCURRENT_TRANS_CNT
);
ret
=
writer
.
start_log
(
start_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
// write dummy log
start_cursor
.
reset
();
ret
=
writer
.
flush_log
(
LogCommand
::
OB_LOG_DUMMY_LOG
,
log_buf
,
start_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
1
,
start_cursor
.
file_id_
);
ASSERT_EQ
(
1
,
start_cursor
.
log_id_
);
// write checkpoint log
start_cursor
.
reset
();
start_cursor
.
file_id_
=
2
;
start_cursor
.
log_id_
=
3
;
start_cursor
.
offset_
=
0
;
ObStorageLogWriter
sec_writer
;
sec_writer
.
init
(
LOG_DIR
,
LOG_FILE_SIZE
,
LOG_BUFFER_SIZE
,
CONCURRENT_TRANS_CNT
);
ret
=
sec_writer
.
start_log
(
start_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
start_cursor
.
reset
();
ret
=
sec_writer
.
flush_log
(
LogCommand
::
OB_LOG_CHECKPOINT
,
log_buf
,
start_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
// read part
LogCommand
cmd
=
LogCommand
::
OB_LOG_UNKNOWN
;
start_cursor
.
reset
();
start_cursor
.
file_id_
=
1
;
start_cursor
.
log_id_
=
1
;
start_cursor
.
offset_
=
0
;
uint64_t
seq
=
0
;
int64_t
read_len
=
0
;
char
*
read_data
=
NULL
;
ObLogCursor
read_cursor
;
ObStorageLogReader
reader
;
ret
=
reader
.
init
(
LOG_DIR
,
start_cursor
.
file_id_
,
0
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
// read dummy log
ret
=
reader
.
read_log
(
cmd
,
seq
,
read_data
,
read_len
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
LogCommand
::
OB_LOG_DUMMY_LOG
,
cmd
);
ASSERT_EQ
(
1
,
seq
);
ASSERT_EQ
(
strlen
(
write_data
),
read_len
);
ASSERT_TRUE
(
0
==
strncmp
(
write_data
,
read_data
,
read_len
-
1
));
ret
=
reader
.
get_cursor
(
read_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
1
,
read_cursor
.
file_id_
);
ASSERT_EQ
(
1
,
read_cursor
.
log_id_
);
OB_LOG
(
INFO
,
"read log "
,
K
(
read_cursor
));
// read NOP log
ret
=
reader
.
read_log
(
cmd
,
seq
,
read_data
,
read_len
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
LogCommand
::
OB_LOG_NOP
,
cmd
);
ASSERT_EQ
(
2
,
seq
);
ret
=
reader
.
get_cursor
(
read_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
1
,
read_cursor
.
file_id_
);
ASSERT_EQ
(
2
,
read_cursor
.
log_id_
);
OB_LOG
(
INFO
,
"read log "
,
K
(
read_cursor
));
ASSERT_TRUE
(
0
==
read_cursor
.
offset_
%
OB_DIRECT_IO_ALIGN
);
// read checkpoint log
read_data
=
NULL
;
ret
=
reader
.
read_log
(
cmd
,
seq
,
read_data
,
read_len
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
LogCommand
::
OB_LOG_CHECKPOINT
,
cmd
);
ASSERT_EQ
(
3
,
seq
);
ASSERT_EQ
(
strlen
(
write_data
),
read_len
);
ASSERT_TRUE
(
0
==
strncmp
(
write_data
,
read_data
,
read_len
-
1
));
ret
=
reader
.
get_cursor
(
read_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
2
,
read_cursor
.
file_id_
);
ASSERT_EQ
(
3
,
read_cursor
.
log_id_
);
OB_LOG
(
INFO
,
"read log "
,
K
(
read_cursor
));
// read NOP log
read_data
=
NULL
;
ret
=
reader
.
read_log
(
cmd
,
seq
,
read_data
,
read_len
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
LogCommand
::
OB_LOG_NOP
,
cmd
);
ASSERT_EQ
(
4
,
seq
);
ret
=
reader
.
get_cursor
(
read_cursor
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ASSERT_EQ
(
2
,
read_cursor
.
file_id_
);
ASSERT_EQ
(
4
,
read_cursor
.
log_id_
);
OB_LOG
(
INFO
,
"read log "
,
K
(
read_cursor
));
ASSERT_TRUE
(
0
==
read_cursor
.
offset_
%
OB_DIRECT_IO_ALIGN
);
// read end of file
read_data
=
NULL
;
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
);
OB_LOG
(
INFO
,
"read log "
,
K
(
read_cursor
));
}
TEST_F
(
TestStorageLogReaderWriter
,
large_buf
)
TEST_F
(
TestStorageLogReaderWriter
,
large_buf
)
{
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录