Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
66a91e26
R
rocksdb
项目概览
kvdb
/
rocksdb
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rocksdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
66a91e26
编写于
9月 07, 2016
作者:
E
Edouard A
提交者:
Siying Dong
9月 07, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add NoSpace subcode to IOError (#1320)
Add a sub code to distinguish "out of space" errors from regular I/O errors
上级
67036c04
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
53 addition
and
23 deletion
+53
-23
db/db_io_failure_test.cc
db/db_io_failure_test.cc
+1
-0
db/db_test_util.h
db/db_test_util.h
+1
-1
include/rocksdb/status.h
include/rocksdb/status.h
+30
-12
port/win/io_win.h
port/win/io_win.h
+6
-2
util/env_hdfs.cc
util/env_hdfs.cc
+3
-1
util/io_posix.h
util/io_posix.h
+4
-1
util/status.cc
util/status.cc
+3
-2
util/status_message.cc
util/status_message.cc
+5
-4
未找到文件。
db/db_io_failure_test.cc
浏览文件 @
66a91e26
...
@@ -111,6 +111,7 @@ TEST_F(DBIOFailureTest, NoSpaceCompactRange) {
...
@@ -111,6 +111,7 @@ TEST_F(DBIOFailureTest, NoSpaceCompactRange) {
Status
s
=
dbfull
()
->
TEST_CompactRange
(
0
,
nullptr
,
nullptr
,
nullptr
,
Status
s
=
dbfull
()
->
TEST_CompactRange
(
0
,
nullptr
,
nullptr
,
nullptr
,
true
/* disallow trivial move */
);
true
/* disallow trivial move */
);
ASSERT_TRUE
(
s
.
IsIOError
());
ASSERT_TRUE
(
s
.
IsIOError
());
ASSERT_TRUE
(
s
.
IsNoSpace
());
env_
->
no_space_
.
store
(
false
,
std
::
memory_order_release
);
env_
->
no_space_
.
store
(
false
,
std
::
memory_order_release
);
}
while
(
ChangeCompactOptions
());
}
while
(
ChangeCompactOptions
());
...
...
db/db_test_util.h
浏览文件 @
66a91e26
...
@@ -221,7 +221,7 @@ class SpecialEnv : public EnvWrapper {
...
@@ -221,7 +221,7 @@ class SpecialEnv : public EnvWrapper {
// Drop writes on the floor
// Drop writes on the floor
return
Status
::
OK
();
return
Status
::
OK
();
}
else
if
(
env_
->
no_space_
.
load
(
std
::
memory_order_acquire
))
{
}
else
if
(
env_
->
no_space_
.
load
(
std
::
memory_order_acquire
))
{
return
Status
::
IOError
(
"No space left on device"
);
return
Status
::
NoSpace
(
"No space left on device"
);
}
else
{
}
else
{
env_
->
bytes_written_
+=
data
.
size
();
env_
->
bytes_written_
+=
data
.
size
();
return
base_
->
Append
(
data
);
return
base_
->
Append
(
data
);
...
...
include/rocksdb/status.h
浏览文件 @
66a91e26
...
@@ -33,14 +33,14 @@ class Status {
...
@@ -33,14 +33,14 @@ class Status {
Status
&
operator
=
(
const
Status
&
s
);
Status
&
operator
=
(
const
Status
&
s
);
Status
(
Status
&&
s
)
Status
(
Status
&&
s
)
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900))
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900))
noexcept
noexcept
#endif
#endif
;
;
Status
&
operator
=
(
Status
&&
s
)
Status
&
operator
=
(
Status
&&
s
)
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900))
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900))
noexcept
noexcept
#endif
#endif
;
;
bool
operator
==
(
const
Status
&
rhs
)
const
;
bool
operator
==
(
const
Status
&
rhs
)
const
;
bool
operator
!=
(
const
Status
&
rhs
)
const
;
bool
operator
!=
(
const
Status
&
rhs
)
const
;
...
@@ -58,7 +58,7 @@ class Status {
...
@@ -58,7 +58,7 @@ class Status {
kAborted
=
10
,
kAborted
=
10
,
kBusy
=
11
,
kBusy
=
11
,
kExpired
=
12
,
kExpired
=
12
,
kTryAgain
=
13
,
kTryAgain
=
13
};
};
Code
code
()
const
{
return
code_
;
}
Code
code
()
const
{
return
code_
;
}
...
@@ -68,6 +68,7 @@ class Status {
...
@@ -68,6 +68,7 @@ class Status {
kMutexTimeout
=
1
,
kMutexTimeout
=
1
,
kLockTimeout
=
2
,
kLockTimeout
=
2
,
kLockLimit
=
3
,
kLockLimit
=
3
,
kNoSpace
=
4
,
kMaxSubCode
kMaxSubCode
};
};
...
@@ -157,6 +158,11 @@ class Status {
...
@@ -157,6 +158,11 @@ class Status {
return
Status
(
kTryAgain
,
msg
,
msg2
);
return
Status
(
kTryAgain
,
msg
,
msg2
);
}
}
static
Status
NoSpace
()
{
return
Status
(
kIOError
,
kNoSpace
);
}
static
Status
NoSpace
(
const
Slice
&
msg
,
const
Slice
&
msg2
=
Slice
())
{
return
Status
(
kIOError
,
kNoSpace
,
msg
,
msg2
);
}
// Returns true iff the status indicates success.
// Returns true iff the status indicates success.
bool
ok
()
const
{
return
code
()
==
kOk
;
}
bool
ok
()
const
{
return
code
()
==
kOk
;
}
...
@@ -200,6 +206,15 @@ class Status {
...
@@ -200,6 +206,15 @@ class Status {
// re-attempted.
// re-attempted.
bool
IsTryAgain
()
const
{
return
code
()
==
kTryAgain
;
}
bool
IsTryAgain
()
const
{
return
code
()
==
kTryAgain
;
}
// Returns true iff the status indicates a NoSpace error
// This is caused by an I/O error returning the specific "out of space"
// error condition. Stricto sensu, an NoSpace error is an I/O error
// with a specific subcode, enabling users to take the appropriate action
// if needed
bool
IsNoSpace
()
const
{
return
(
code
()
==
kIOError
)
&&
(
subcode
()
==
kNoSpace
);
}
// Return a string representation of this status suitable for printing.
// Return a string representation of this status suitable for printing.
// Returns the string "OK" for success.
// Returns the string "OK" for success.
std
::
string
ToString
()
const
;
std
::
string
ToString
()
const
;
...
@@ -219,7 +234,10 @@ class Status {
...
@@ -219,7 +234,10 @@ class Status {
explicit
Status
(
Code
_code
,
SubCode
_subcode
=
kNone
)
explicit
Status
(
Code
_code
,
SubCode
_subcode
=
kNone
)
:
code_
(
_code
),
subcode_
(
_subcode
),
state_
(
nullptr
)
{}
:
code_
(
_code
),
subcode_
(
_subcode
),
state_
(
nullptr
)
{}
Status
(
Code
_code
,
const
Slice
&
msg
,
const
Slice
&
msg2
);
Status
(
Code
_code
,
SubCode
_subcode
,
const
Slice
&
msg
,
const
Slice
&
msg2
);
Status
(
Code
_code
,
const
Slice
&
msg
,
const
Slice
&
msg2
)
:
Status
(
_code
,
kNone
,
msg
,
msg2
)
{}
static
const
char
*
CopyState
(
const
char
*
s
);
static
const
char
*
CopyState
(
const
char
*
s
);
};
};
...
@@ -229,7 +247,7 @@ inline Status::Status(const Status& s) : code_(s.code_), subcode_(s.subcode_) {
...
@@ -229,7 +247,7 @@ inline Status::Status(const Status& s) : code_(s.code_), subcode_(s.subcode_) {
inline
Status
&
Status
::
operator
=
(
const
Status
&
s
)
{
inline
Status
&
Status
::
operator
=
(
const
Status
&
s
)
{
// The following condition catches both aliasing (when this == &s),
// The following condition catches both aliasing (when this == &s),
// and the common case where both s and *this are ok.
// and the common case where both s and *this are ok.
if
(
this
!=
&
s
)
{
if
(
this
!=
&
s
)
{
code_
=
s
.
code_
;
code_
=
s
.
code_
;
subcode_
=
s
.
subcode_
;
subcode_
=
s
.
subcode_
;
delete
[]
state_
;
delete
[]
state_
;
...
@@ -240,23 +258,23 @@ inline Status& Status::operator=(const Status& s) {
...
@@ -240,23 +258,23 @@ inline Status& Status::operator=(const Status& s) {
inline
Status
::
Status
(
Status
&&
s
)
inline
Status
::
Status
(
Status
&&
s
)
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900))
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900))
noexcept
noexcept
#endif
#endif
:
Status
()
{
:
Status
()
{
*
this
=
std
::
move
(
s
);
*
this
=
std
::
move
(
s
);
}
}
inline
Status
&
Status
::
operator
=
(
Status
&&
s
)
inline
Status
&
Status
::
operator
=
(
Status
&&
s
)
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900))
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900))
noexcept
noexcept
#endif
#endif
{
{
if
(
this
!=
&
s
)
{
if
(
this
!=
&
s
)
{
code_
=
std
::
move
(
s
.
code_
);
code_
=
std
::
move
(
s
.
code_
);
s
.
code_
=
kOk
;
s
.
code_
=
kOk
;
subcode_
=
std
::
move
(
s
.
subcode_
);
subcode_
=
std
::
move
(
s
.
subcode_
);
s
.
subcode_
=
kNone
;
s
.
subcode_
=
kNone
;
delete
[]
state_
;
delete
[]
state_
;
state_
=
nullptr
;
state_
=
nullptr
;
std
::
swap
(
state_
,
s
.
state_
);
std
::
swap
(
state_
,
s
.
state_
);
}
}
...
...
port/win/io_win.h
浏览文件 @
66a91e26
...
@@ -26,7 +26,9 @@ namespace port {
...
@@ -26,7 +26,9 @@ namespace port {
std
::
string
GetWindowsErrSz
(
DWORD
err
);
std
::
string
GetWindowsErrSz
(
DWORD
err
);
inline
Status
IOErrorFromWindowsError
(
const
std
::
string
&
context
,
DWORD
err
)
{
inline
Status
IOErrorFromWindowsError
(
const
std
::
string
&
context
,
DWORD
err
)
{
return
Status
::
IOError
(
context
,
GetWindowsErrSz
(
err
));
return
(
err
==
ERROR_HANDLE_DISK_FULL
)
?
Status
::
NoSpace
(
context
,
GetWindowsErrSz
(
err
))
:
Status
::
IOError
(
context
,
GetWindowsErrSz
(
err
));
}
}
inline
Status
IOErrorFromLastWindowsError
(
const
std
::
string
&
context
)
{
inline
Status
IOErrorFromLastWindowsError
(
const
std
::
string
&
context
)
{
...
@@ -34,7 +36,9 @@ inline Status IOErrorFromLastWindowsError(const std::string& context) {
...
@@ -34,7 +36,9 @@ inline Status IOErrorFromLastWindowsError(const std::string& context) {
}
}
inline
Status
IOError
(
const
std
::
string
&
context
,
int
err_number
)
{
inline
Status
IOError
(
const
std
::
string
&
context
,
int
err_number
)
{
return
Status
::
IOError
(
context
,
strerror
(
err_number
));
return
(
err_number
==
ENOSPC
)
?
Status
::
NoSpace
(
context
,
strerror
(
err_number
))
:
Status
::
IOError
(
context
,
strerror
(
err_number
));
}
}
// Note the below two do not set errno because they are used only here in this
// Note the below two do not set errno because they are used only here in this
...
...
util/env_hdfs.cc
浏览文件 @
66a91e26
...
@@ -36,7 +36,9 @@ namespace {
...
@@ -36,7 +36,9 @@ namespace {
// Log error message
// Log error message
static
Status
IOError
(
const
std
::
string
&
context
,
int
err_number
)
{
static
Status
IOError
(
const
std
::
string
&
context
,
int
err_number
)
{
return
Status
::
IOError
(
context
,
strerror
(
err_number
));
return
(
err_number
==
ENOSPC
)
?
Status
::
NoSpace
(
context
,
strerror
(
err_number
))
:
Status
::
IOError
(
context
,
strerror
(
err_number
));
}
}
// assume that there is one global logger for now. It is not thread-safe,
// assume that there is one global logger for now. It is not thread-safe,
...
...
util/io_posix.h
浏览文件 @
66a91e26
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#pragma once
#pragma once
#include <unistd.h>
#include <unistd.h>
#include <atomic>
#include <atomic>
#include <errno.h>
#include "rocksdb/env.h"
#include "rocksdb/env.h"
// For non linux platform, the following macros are used only as place
// For non linux platform, the following macros are used only as place
...
@@ -24,7 +25,9 @@
...
@@ -24,7 +25,9 @@
namespace
rocksdb
{
namespace
rocksdb
{
static
Status
IOError
(
const
std
::
string
&
context
,
int
err_number
)
{
static
Status
IOError
(
const
std
::
string
&
context
,
int
err_number
)
{
return
Status
::
IOError
(
context
,
strerror
(
err_number
));
return
(
err_number
==
ENOSPC
)
?
Status
::
NoSpace
(
context
,
strerror
(
err_number
))
:
Status
::
IOError
(
context
,
strerror
(
err_number
));
}
}
class
PosixHelper
{
class
PosixHelper
{
...
...
util/status.cc
浏览文件 @
66a91e26
...
@@ -21,9 +21,10 @@ const char* Status::CopyState(const char* state) {
...
@@ -21,9 +21,10 @@ const char* Status::CopyState(const char* state) {
return
result
;
return
result
;
}
}
Status
::
Status
(
Code
_code
,
const
Slice
&
msg
,
const
Slice
&
msg2
)
Status
::
Status
(
Code
_code
,
SubCode
_subcode
,
const
Slice
&
msg
,
const
Slice
&
msg2
)
:
code_
(
_code
),
subcode_
(
kNon
e
)
{
:
code_
(
_code
),
subcode_
(
_subcod
e
)
{
assert
(
code_
!=
kOk
);
assert
(
code_
!=
kOk
);
assert
(
subcode_
!=
kMaxSubCode
);
const
uint32_t
len1
=
static_cast
<
uint32_t
>
(
msg
.
size
());
const
uint32_t
len1
=
static_cast
<
uint32_t
>
(
msg
.
size
());
const
uint32_t
len2
=
static_cast
<
uint32_t
>
(
msg2
.
size
());
const
uint32_t
len2
=
static_cast
<
uint32_t
>
(
msg2
.
size
());
const
uint32_t
size
=
len1
+
(
len2
?
(
2
+
len2
)
:
0
);
const
uint32_t
size
=
len1
+
(
len2
?
(
2
+
len2
)
:
0
);
...
...
util/status_message.cc
浏览文件 @
66a91e26
...
@@ -8,10 +8,11 @@
...
@@ -8,10 +8,11 @@
namespace
rocksdb
{
namespace
rocksdb
{
const
char
*
Status
::
msgs
[]
=
{
const
char
*
Status
::
msgs
[]
=
{
""
,
// kNone
""
,
// kNone
"Timeout Acquiring Mutex"
,
// kMutexTimeout
"Timeout Acquiring Mutex"
,
// kMutexTimeout
"Timeout waiting to lock key"
,
// kLockTimeout
"Timeout waiting to lock key"
,
// kLockTimeout
"Failed to acquire lock due to max_num_locks limit"
// kLockLimit
"Failed to acquire lock due to max_num_locks limit"
,
// kLockLimit
"No space left on device"
// kNoSpace
};
};
}
// namespace rocksdb
}
// namespace rocksdb
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录