Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
925b5d00
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,发现更多精彩内容 >>
提交
925b5d00
编写于
3月 30, 2016
作者:
I
Igor Canadi
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1054 from DCEngines/magic12
Remove the Magic number 12 used in record size checks
上级
994b3bd6
63e8f1b5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
24 addition
and
18 deletion
+24
-18
db/db_impl.cc
db/db_impl.cc
+1
-1
db/repair.cc
db/repair.cc
+1
-1
db/transaction_log_impl.cc
db/transaction_log_impl.cc
+2
-2
db/wal_manager.cc
db/wal_manager.cc
+1
-1
db/write_batch.cc
db/write_batch.cc
+14
-12
db/write_batch_internal.h
db/write_batch_internal.h
+4
-0
tools/ldb_cmd.cc
tools/ldb_cmd.cc
+1
-1
未找到文件。
db/db_impl.cc
浏览文件 @
925b5d00
...
...
@@ -1186,7 +1186,7 @@ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
continue_replay_log
&&
reader
.
ReadRecord
(
&
record
,
&
scratch
,
db_options_
.
wal_recovery_mode
)
&&
status
.
ok
())
{
if
(
record
.
size
()
<
12
)
{
if
(
record
.
size
()
<
WriteBatchInternal
::
kHeader
)
{
reporter
.
Corruption
(
record
.
size
(),
Status
::
Corruption
(
"log record too small"
));
continue
;
...
...
db/repair.cc
浏览文件 @
925b5d00
...
...
@@ -265,7 +265,7 @@ class Repairer {
mem
->
Ref
();
int
counter
=
0
;
while
(
reader
.
ReadRecord
(
&
record
,
&
scratch
))
{
if
(
record
.
size
()
<
12
)
{
if
(
record
.
size
()
<
WriteBatchInternal
::
kHeader
)
{
reporter
.
Corruption
(
record
.
size
(),
Status
::
Corruption
(
"log record too small"
));
continue
;
...
...
db/transaction_log_impl.cc
浏览文件 @
925b5d00
...
...
@@ -107,7 +107,7 @@ void TransactionLogIteratorImpl::SeekToStartSequence(
return
;
}
while
(
RestrictedRead
(
&
record
,
&
scratch
))
{
if
(
record
.
size
()
<
12
)
{
if
(
record
.
size
()
<
WriteBatchInternal
::
kHeader
)
{
reporter_
.
Corruption
(
record
.
size
(),
Status
::
Corruption
(
"very small log record"
));
continue
;
...
...
@@ -167,7 +167,7 @@ void TransactionLogIteratorImpl::NextImpl(bool internal) {
currentLogReader_
->
UnmarkEOF
();
}
while
(
RestrictedRead
(
&
record
,
&
scratch
))
{
if
(
record
.
size
()
<
12
)
{
if
(
record
.
size
()
<
WriteBatchInternal
::
kHeader
)
{
reporter_
.
Corruption
(
record
.
size
(),
Status
::
Corruption
(
"very small log record"
));
continue
;
...
...
db/wal_manager.cc
浏览文件 @
925b5d00
...
...
@@ -455,7 +455,7 @@ Status WalManager::ReadFirstLine(const std::string& fname,
if
(
reader
.
ReadRecord
(
&
record
,
&
scratch
)
&&
(
status
.
ok
()
||
!
db_options_
.
paranoid_checks
))
{
if
(
record
.
size
()
<
12
)
{
if
(
record
.
size
()
<
WriteBatchInternal
::
kHeader
)
{
reporter
.
Corruption
(
record
.
size
(),
Status
::
Corruption
(
"log record too small"
));
// TODO read record's till the first no corrupt entry?
...
...
db/write_batch.cc
浏览文件 @
925b5d00
...
...
@@ -81,8 +81,6 @@ struct BatchContentClassifier : public WriteBatch::Handler {
}
// anon namespace
// WriteBatch header has an 8-byte sequence number followed by a 4-byte count.
static
const
size_t
kHeader
=
12
;
struct
SavePoint
{
size_t
size
;
// size of rep_
...
...
@@ -96,8 +94,9 @@ struct SavePoints {
WriteBatch
::
WriteBatch
(
size_t
reserved_bytes
)
:
save_points_
(
nullptr
),
content_flags_
(
0
),
rep_
()
{
rep_
.
reserve
((
reserved_bytes
>
kHeader
)
?
reserved_bytes
:
kHeader
);
rep_
.
resize
(
kHeader
);
rep_
.
reserve
((
reserved_bytes
>
WriteBatchInternal
::
kHeader
)
?
reserved_bytes
:
WriteBatchInternal
::
kHeader
);
rep_
.
resize
(
WriteBatchInternal
::
kHeader
);
}
WriteBatch
::
WriteBatch
(
const
std
::
string
&
rep
)
...
...
@@ -146,7 +145,7 @@ bool WriteBatch::Handler::Continue() {
void
WriteBatch
::
Clear
()
{
rep_
.
clear
();
rep_
.
resize
(
kHeader
);
rep_
.
resize
(
WriteBatchInternal
::
kHeader
);
content_flags_
.
store
(
0
,
std
::
memory_order_relaxed
);
...
...
@@ -249,11 +248,11 @@ Status ReadRecordFromWriteBatch(Slice* input, char* tag,
Status
WriteBatch
::
Iterate
(
Handler
*
handler
)
const
{
Slice
input
(
rep_
);
if
(
input
.
size
()
<
kHeader
)
{
if
(
input
.
size
()
<
WriteBatchInternal
::
kHeader
)
{
return
Status
::
Corruption
(
"malformed WriteBatch (too small)"
);
}
input
.
remove_prefix
(
kHeader
);
input
.
remove_prefix
(
WriteBatchInternal
::
kHeader
);
Slice
key
,
value
,
blob
;
int
found
=
0
;
Status
s
;
...
...
@@ -329,7 +328,9 @@ void WriteBatchInternal::SetSequence(WriteBatch* b, SequenceNumber seq) {
EncodeFixed64
(
&
b
->
rep_
[
0
],
seq
);
}
size_t
WriteBatchInternal
::
GetFirstOffset
(
WriteBatch
*
b
)
{
return
kHeader
;
}
size_t
WriteBatchInternal
::
GetFirstOffset
(
WriteBatch
*
b
)
{
return
WriteBatchInternal
::
kHeader
;
}
void
WriteBatchInternal
::
Put
(
WriteBatch
*
b
,
uint32_t
column_family_id
,
const
Slice
&
key
,
const
Slice
&
value
)
{
...
...
@@ -832,15 +833,16 @@ Status WriteBatchInternal::InsertInto(const WriteBatch* batch,
}
void
WriteBatchInternal
::
SetContents
(
WriteBatch
*
b
,
const
Slice
&
contents
)
{
assert
(
contents
.
size
()
>=
kHeader
);
assert
(
contents
.
size
()
>=
WriteBatchInternal
::
kHeader
);
b
->
rep_
.
assign
(
contents
.
data
(),
contents
.
size
());
b
->
content_flags_
.
store
(
ContentFlags
::
DEFERRED
,
std
::
memory_order_relaxed
);
}
void
WriteBatchInternal
::
Append
(
WriteBatch
*
dst
,
const
WriteBatch
*
src
)
{
SetCount
(
dst
,
Count
(
dst
)
+
Count
(
src
));
assert
(
src
->
rep_
.
size
()
>=
kHeader
);
dst
->
rep_
.
append
(
src
->
rep_
.
data
()
+
kHeader
,
src
->
rep_
.
size
()
-
kHeader
);
assert
(
src
->
rep_
.
size
()
>=
WriteBatchInternal
::
kHeader
);
dst
->
rep_
.
append
(
src
->
rep_
.
data
()
+
WriteBatchInternal
::
kHeader
,
src
->
rep_
.
size
()
-
WriteBatchInternal
::
kHeader
);
dst
->
content_flags_
.
store
(
dst
->
content_flags_
.
load
(
std
::
memory_order_relaxed
)
|
src
->
content_flags_
.
load
(
std
::
memory_order_relaxed
),
...
...
@@ -852,7 +854,7 @@ size_t WriteBatchInternal::AppendedByteSize(size_t leftByteSize,
if
(
leftByteSize
==
0
||
rightByteSize
==
0
)
{
return
leftByteSize
+
rightByteSize
;
}
else
{
return
leftByteSize
+
rightByteSize
-
kHeader
;
return
leftByteSize
+
rightByteSize
-
WriteBatchInternal
::
kHeader
;
}
}
...
...
db/write_batch_internal.h
浏览文件 @
925b5d00
...
...
@@ -63,6 +63,10 @@ class ColumnFamilyMemTablesDefault : public ColumnFamilyMemTables {
// WriteBatch that we don't want in the public WriteBatch interface.
class
WriteBatchInternal
{
public:
// WriteBatch header has an 8-byte sequence number followed by a 4-byte count.
static
const
size_t
kHeader
=
12
;
// WriteBatch methods with column_family_id instead of ColumnFamilyHandle*
static
void
Put
(
WriteBatch
*
batch
,
uint32_t
column_family_id
,
const
Slice
&
key
,
const
Slice
&
value
);
...
...
tools/ldb_cmd.cc
浏览文件 @
925b5d00
...
...
@@ -1576,7 +1576,7 @@ void DumpWalFile(std::string wal_file, bool print_header, bool print_values,
}
while
(
reader
.
ReadRecord
(
&
record
,
&
scratch
))
{
row
.
str
(
""
);
if
(
record
.
size
()
<
12
)
{
if
(
record
.
size
()
<
WriteBatchInternal
::
kHeader
)
{
reporter
.
Corruption
(
record
.
size
(),
Status
::
Corruption
(
"log record too small"
));
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录