Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
6731eb76
T
Terarkdb
项目概览
indiff7643
/
Terarkdb
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Terarkdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6731eb76
编写于
4月 13, 2020
作者:
Z
ZhaoMing
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'stage' into v1.2.4-hotfix-0
上级
ec281248
302a6174
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
4 deletion
+59
-4
db/db_impl.cc
db/db_impl.cc
+19
-0
db/db_impl.h
db/db_impl.h
+3
-1
db/db_impl_debug.cc
db/db_impl_debug.cc
+9
-3
db/db_write_test.cc
db/db_write_test.cc
+19
-0
include/rocksdb/db.h
include/rocksdb/db.h
+9
-0
未找到文件。
db/db_impl.cc
浏览文件 @
6731eb76
...
...
@@ -1115,6 +1115,25 @@ Status DBImpl::SyncWAL() {
return
status
;
}
Status
DBImpl
::
LockWAL
()
{
log_write_mutex_
.
Lock
();
auto
cur_log_writer
=
logs_
.
back
().
writer
;
auto
status
=
cur_log_writer
->
WriteBuffer
();
if
(
!
status
.
ok
())
{
ROCKS_LOG_ERROR
(
immutable_db_options_
.
info_log
,
"WAL flush error %s"
,
status
.
ToString
().
c_str
());
// In case there is a fs error we should set it globally to prevent the
// future writes
WriteStatusCheck
(
status
);
}
return
status
;
}
Status
DBImpl
::
UnlockWAL
()
{
log_write_mutex_
.
Unlock
();
return
Status
::
OK
();
}
void
DBImpl
::
MarkLogsSynced
(
uint64_t
up_to
,
bool
synced_dir
,
const
Status
&
status
)
{
mutex_
.
AssertHeld
();
...
...
db/db_impl.h
浏览文件 @
6731eb76
...
...
@@ -231,8 +231,10 @@ class DBImpl : public DB {
const
FlushOptions
&
options
,
const
std
::
vector
<
ColumnFamilyHandle
*>&
column_families
)
override
;
virtual
Status
FlushWAL
(
bool
sync
)
override
;
bool
TEST_WALBufferIsEmpty
();
bool
TEST_WALBufferIsEmpty
(
bool
lock
=
true
);
virtual
Status
SyncWAL
()
override
;
virtual
Status
LockWAL
()
override
;
virtual
Status
UnlockWAL
()
override
;
virtual
SequenceNumber
GetLatestSequenceNumber
()
const
override
;
// REQUIRES: joined the main write queue if two_write_queues is disabled, and
...
...
db/db_impl_debug.cc
浏览文件 @
6731eb76
...
...
@@ -26,10 +26,16 @@ void DBImpl::TEST_SwitchWAL() {
SwitchWAL
(
&
write_context
);
}
bool
DBImpl
::
TEST_WALBufferIsEmpty
()
{
InstrumentedMutexLock
wl
(
&
log_write_mutex_
);
bool
DBImpl
::
TEST_WALBufferIsEmpty
(
bool
lock
)
{
if
(
lock
)
{
log_write_mutex_
.
Lock
();
}
log
::
Writer
*
cur_log_writer
=
logs_
.
back
().
writer
;
return
cur_log_writer
->
TEST_BufferIsEmpty
();
auto
res
=
cur_log_writer
->
TEST_BufferIsEmpty
();
if
(
lock
)
{
log_write_mutex_
.
Unlock
();
}
return
res
;
}
int64_t
DBImpl
::
TEST_MaxNextLevelOverlappingBytes
(
...
...
db/db_write_test.cc
浏览文件 @
6731eb76
...
...
@@ -140,6 +140,25 @@ TEST_P(DBWriteTest, IOErrorOnWALWriteTriggersReadOnlyMode) {
Close
();
}
// Test that db->LockWAL() flushes the WAL after locking.
TEST_P
(
DBWriteTest
,
LockWalInEffect
)
{
Options
options
=
GetOptions
();
Reopen
(
options
);
// try the 1st WAL created during open
ASSERT_OK
(
Put
(
"key"
+
ToString
(
0
),
"value"
));
ASSERT_TRUE
(
options
.
manual_wal_flush
!=
dbfull
()
->
TEST_WALBufferIsEmpty
());
ASSERT_OK
(
dbfull
()
->
LockWAL
());
ASSERT_TRUE
(
dbfull
()
->
TEST_WALBufferIsEmpty
(
false
));
ASSERT_OK
(
dbfull
()
->
UnlockWAL
());
// try the 2nd wal created during SwitchWAL
dbfull
()
->
TEST_SwitchWAL
();
ASSERT_OK
(
Put
(
"key"
+
ToString
(
0
),
"value"
));
ASSERT_TRUE
(
options
.
manual_wal_flush
!=
dbfull
()
->
TEST_WALBufferIsEmpty
());
ASSERT_OK
(
dbfull
()
->
LockWAL
());
ASSERT_TRUE
(
dbfull
()
->
TEST_WALBufferIsEmpty
(
false
));
ASSERT_OK
(
dbfull
()
->
UnlockWAL
());
}
INSTANTIATE_TEST_CASE_P
(
DBWriteTestInstance
,
DBWriteTest
,
testing
::
Values
(
DBTestBase
::
kDefault
,
DBTestBase
::
kConcurrentWALWrites
,
...
...
include/rocksdb/db.h
浏览文件 @
6731eb76
...
...
@@ -987,6 +987,15 @@ class DB {
virtual
Status
FlushWAL
(
bool
/*sync*/
)
{
return
Status
::
NotSupported
(
"FlushWAL not implemented"
);
}
// Lock the WAL. Also flushes the WAL after locking.
virtual
Status
LockWAL
()
{
return
Status
::
NotSupported
(
"LockWAL not implemented"
);
}
// Unlock the WAL.
virtual
Status
UnlockWAL
()
{
return
Status
::
NotSupported
(
"UnlockWAL not implemented"
);
}
// Sync the wal. Note that Write() followed by SyncWAL() is not exactly the
// same as Write() with sync=true: in the latter case the changes won't be
// visible until the sync is done.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录