Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
miniob
提交
72505bdd
M
miniob
项目概览
oceanbase
/
miniob
1 年多 前同步成功
通知
74
Star
1521
Fork
537
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
M
miniob
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
提交
72505bdd
编写于
1月 28, 2023
作者:
L
Longda Feng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compile warning
上级
314db4db
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
23 deletion
+35
-23
deps/common/log/log.cpp
deps/common/log/log.cpp
+11
-11
deps/common/os/process.cpp
deps/common/os/process.cpp
+7
-0
deps/common/seda/timer_stage.cpp
deps/common/seda/timer_stage.cpp
+8
-1
src/observer/storage/clog/clog.cpp
src/observer/storage/clog/clog.cpp
+7
-7
src/observer/storage/common/db.cpp
src/observer/storage/common/db.cpp
+1
-1
unitest/bplus_tree_test.cpp
unitest/bplus_tree_test.cpp
+1
-3
未找到文件。
deps/common/log/log.cpp
浏览文件 @
72505bdd
...
...
@@ -213,16 +213,15 @@ int Log::rotate_by_day(const int year, const int month, const int day)
return
0
;
}
#define MAX_LOG_NUM 999
int
Log
::
rename_old_logs
()
{
int
log_index
=
1
;
int
max_log_index
=
0
;
char
log_index_str
[
4
]
=
{
0
};
while
(
log_index
<
999
)
{
snprintf
(
log_index_str
,
sizeof
(
log_index_str
),
"%03d"
,
log_index
);
std
::
string
log_name
=
log_name_
+
"."
+
log_index_str
;
while
(
log_index
<
MAX_LOG_NUM
)
{
std
::
string
log_name
=
log_name_
+
"."
+
size_to_pad_str
(
log_index
,
3
);
int
result
=
access
(
log_name
.
c_str
(),
R_OK
);
if
(
result
)
{
break
;
...
...
@@ -232,15 +231,16 @@ int Log::rename_old_logs()
log_index
++
;
}
if
(
log_index
==
MAX_LOG_NUM
)
{
std
::
string
log_name_rm
=
log_name_
+
"."
+
size_to_pad_str
(
log_index
,
3
);
remove
(
log_name_rm
.
c_str
());
}
log_index
=
max_log_index
;
while
(
log_index
>
0
)
{
s
nprintf
(
log_index_str
,
sizeof
(
log_index_str
),
"%03d"
,
log_index
);
s
td
::
string
log_name_old
=
log_name_
+
"."
+
size_to_pad_str
(
log_index
,
3
);
std
::
string
log_name_old
=
log_name_
+
"."
+
log_index_str
;
snprintf
(
log_index_str
,
sizeof
(
log_index_str
),
"%03d"
,
log_index
+
1
);
std
::
string
log_name_new
=
log_name_
+
"."
+
log_index_str
;
std
::
string
log_name_new
=
log_name_
+
"."
+
size_to_pad_str
(
log_index
+
1
,
3
);
int
result
=
rename
(
log_name_old
.
c_str
(),
log_name_new
.
c_str
());
if
(
result
)
{
...
...
deps/common/os/process.cpp
浏览文件 @
72505bdd
...
...
@@ -63,7 +63,14 @@ int daemonize_service(bool close_std_streams)
{
int
nochdir
=
1
;
int
noclose
=
close_std_streams
?
0
:
1
;
#ifdef __MACH__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
int
rc
=
daemon
(
nochdir
,
noclose
);
#ifdef __MACH__
#pragma GCC diagnostic pop
#endif
// Here after the fork; the parent is dead and setsid() is called
if
(
rc
!=
0
)
{
std
::
cerr
<<
"Error: unable to daemonize: "
<<
strerror
(
errno
)
<<
"
\n
"
;
...
...
deps/common/seda/timer_stage.cpp
浏览文件 @
72505bdd
...
...
@@ -458,13 +458,20 @@ void TimerStage::check_timer()
// It is ok to hold the mutex while executing this loop.
// Triggering the events only enqueues the event on the
// caller's queue--it does not perform any real work.
#ifdef __MACH__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpotentially-evaluated-expression"
#endif
for
(
std
::
list
<
StageEvent
*>::
iterator
i
=
done_events
.
begin
();
i
!=
done_events
.
end
();
++
i
)
{
LOG_TRACE
(
"triggering timer event: sec=%ld, usec=%ld, typeid=%s
\n
"
,
now
.
tv_sec
,
now
.
tv_usec
,
typeid
(
*
*
i
).
name
());
"triggering timer event: sec=%ld, usec=%ld, typeid=%s
\n
"
,
now
.
tv_sec
,
now
.
tv_usec
,
typeid
(
*
(
*
i
)
).
name
());
(
*
i
)
->
done
();
--
num_events_
;
}
}
#ifdef __MACH__
#pragma GCC diagnostic pop
#endif
done_events
.
clear
();
// Check if the 'shutdown' signal has been received. The
...
...
src/observer/storage/clog/clog.cpp
浏览文件 @
72505bdd
...
...
@@ -119,9 +119,9 @@ RC CLogRecord::copy_record(void *dest, int start_off, int copy_len)
}
else
if
(
flag_
!=
REDO_INSERT
)
{
memcpy
(
dest
,
(
char
*
)
log_rec
+
start_off
,
copy_len
);
}
else
{
if
(
start_off
>
CLOG_INS_REC_NODATA_SIZE
)
{
if
(
start_off
>
(
int
)
CLOG_INS_REC_NODATA_SIZE
)
{
memcpy
(
dest
,
log_rec
->
ins
.
data_
+
start_off
-
CLOG_INS_REC_NODATA_SIZE
,
copy_len
);
}
else
if
(
start_off
+
copy_len
<=
CLOG_INS_REC_NODATA_SIZE
)
{
}
else
if
(
start_off
+
copy_len
<=
(
int
)
CLOG_INS_REC_NODATA_SIZE
)
{
memcpy
(
dest
,
(
char
*
)
log_rec
+
start_off
,
copy_len
);
}
else
{
memcpy
(
dest
,
(
char
*
)
log_rec
+
start_off
,
CLOG_INS_REC_NODATA_SIZE
-
start_off
);
...
...
@@ -194,7 +194,7 @@ RC CLogBuffer::append_log_record(CLogRecord *log_rec, int &start_off)
write_offset_
+=
CLOG_BLOCK_HDR_SIZE
;
return
append_log_record
(
log_rec
,
start_off
);
}
else
{
if
(
logrec_left_len
<=
(
CLOG_BLOCK_DATA_SIZE
-
log_block
->
log_block_hdr_
.
log_data_len_
))
{
// 不需要再跨block存放
if
(
logrec_left_len
<=
(
(
int32_t
)
CLOG_BLOCK_DATA_SIZE
-
log_block
->
log_block_hdr_
.
log_data_len_
))
{
// 不需要再跨block存放
if
(
log_block
->
log_block_hdr_
.
log_data_len_
==
0
)
{
// 当前为新block
if
(
start_off
==
0
)
{
log_block
->
log_block_hdr_
.
first_rec_offset_
=
CLOG_BLOCK_HDR_SIZE
;
...
...
@@ -315,7 +315,7 @@ RC CLogFile::recover(CLogMTRManager *mtr_mgr, CLogBuffer *log_buffer)
log_buffer
->
set_current_block_no
(
log_block
->
log_block_hdr_
.
log_block_no
);
int16_t
rec_offset
=
CLOG_BLOCK_HDR_SIZE
;
while
(
rec_offset
<
CLOG_BLOCK_HDR_SIZE
+
log_block
->
log_block_hdr_
.
log_data_len_
)
{
while
(
rec_offset
<
(
int16_t
)
CLOG_BLOCK_HDR_SIZE
+
log_block
->
log_block_hdr_
.
log_data_len_
)
{
block_recover
(
log_block
,
rec_offset
,
&
logrec_buf
,
log_rec
);
if
(
log_rec
!=
nullptr
)
{
CLogManager
::
gloabl_lsn_
=
log_rec
->
get_lsn
()
+
log_rec
->
get_logrec_len
();
...
...
@@ -324,7 +324,7 @@ RC CLogFile::recover(CLogMTRManager *mtr_mgr, CLogBuffer *log_buffer)
}
}
if
(
log_block
->
log_block_hdr_
.
log_data_len_
<
CLOG_BLOCK_DATA_SIZE
)
{
// 最后一个block
if
(
log_block
->
log_block_hdr_
.
log_data_len_
<
(
int16_t
)
CLOG_BLOCK_DATA_SIZE
)
{
// 最后一个block
log_buffer
->
block_copy
(
0
,
log_block
);
log_buffer
->
set_write_block_offset
(
0
);
log_buffer
->
set_write_offset
(
log_block
->
log_block_hdr_
.
log_data_len_
+
CLOG_BLOCK_HDR_SIZE
);
...
...
@@ -355,7 +355,7 @@ RC CLogFile::block_recover(CLogBlock *block, int16_t &offset, CLogRecordBuf *log
logrec_buf
->
write_offset_
+=
block
->
log_block_hdr_
.
first_rec_offset_
-
CLOG_BLOCK_HDR_SIZE
;
offset
+=
block
->
log_block_hdr_
.
first_rec_offset_
-
CLOG_BLOCK_HDR_SIZE
;
}
else
{
if
(
CLOG_BLOCK_SIZE
-
offset
<
sizeof
(
CLogRecordHeader
))
{
// 一定是跨block的第一部分
if
(
CLOG_BLOCK_SIZE
-
offset
<
(
int32_t
)
sizeof
(
CLogRecordHeader
))
{
// 一定是跨block的第一部分
// 此时无法确定log record的长度
// 开始写入logrec_buf
memcpy
(
&
logrec_buf
->
buffer_
[
logrec_buf
->
write_offset_
],
(
char
*
)
block
+
(
int
)
offset
,
CLOG_BLOCK_SIZE
-
offset
);
...
...
@@ -367,7 +367,7 @@ RC CLogFile::block_recover(CLogBlock *block, int16_t &offset, CLogRecordBuf *log
memset
(
logrec_buf
,
0
,
sizeof
(
CLogRecordBuf
));
}
else
{
CLogRecordHeader
*
logrec_hdr
=
(
CLogRecordHeader
*
)((
char
*
)
block
+
(
int
)
offset
);
if
(
logrec_hdr
->
logrec_len_
<=
CLOG_BLOCK_SIZE
-
offset
)
{
if
(
logrec_hdr
->
logrec_len_
<=
(
int32_t
)
CLOG_BLOCK_SIZE
-
offset
)
{
log_rec
=
new
CLogRecord
((
char
*
)
block
+
(
int
)
offset
);
offset
+=
logrec_hdr
->
logrec_len_
;
}
else
{
// 此时为跨block的第一部分
...
...
src/observer/storage/common/db.cpp
浏览文件 @
72505bdd
...
...
@@ -161,7 +161,7 @@ RC Db::recover()
{
RC
rc
=
RC
::
SUCCESS
;
if
((
rc
=
clog_manager_
->
recover
())
==
RC
::
SUCCESS
)
{
u
int32_t
max_trx_id
=
0
;
int32_t
max_trx_id
=
0
;
CLogMTRManager
*
mtr_manager
=
clog_manager_
->
get_mtr_manager
();
for
(
auto
it
=
mtr_manager
->
log_redo_list
.
begin
();
it
!=
mtr_manager
->
log_redo_list
.
end
();
it
++
)
{
CLogRecord
*
clog_record
=
*
it
;
...
...
unitest/bplus_tree_test.cpp
浏览文件 @
72505bdd
...
...
@@ -41,9 +41,7 @@ int k = 0;
void
init_bpm
()
{
if
(
&
BufferPoolManager
::
instance
()
==
nullptr
)
{
BufferPoolManager
::
set_instance
(
&
bpm
);
}
BufferPoolManager
::
set_instance
(
&
bpm
);
}
void
test_insert
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录