mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 07:30:54 +00:00
New subcode for IOError to detect the ESTALE errno
Summary: I'd like to propose a patch to expose a new IOError type with subcode kStaleFile to allow to detect when ESTALE error is returned. This allows the rocksdb consumers to handle this error separately from other IOErrors. I've also added a missing string representation for the kDeadlock subcode, I believe calling ToString() on Status object with that subcode would result in an out of band access in the msgs array, Please let me know if you have any questions or would like me to make any changes to this pull request. Closes https://github.com/facebook/rocksdb/pull/1748 Differential Revision: D4387675 Pulled By: IslamAbdelRahman fbshipit-source-id: 67feb13
This commit is contained in:
parent
7ab0051835
commit
a618a16f44
|
@ -70,6 +70,7 @@ class Status {
|
|||
kLockLimit = 3,
|
||||
kNoSpace = 4,
|
||||
kDeadlock = 5,
|
||||
kStaleFile = 6,
|
||||
kMaxSubCode
|
||||
};
|
||||
|
||||
|
|
|
@ -26,9 +26,14 @@
|
|||
namespace rocksdb {
|
||||
|
||||
static Status IOError(const std::string& context, int err_number) {
|
||||
return (err_number == ENOSPC) ?
|
||||
Status::NoSpace(context, strerror(err_number)) :
|
||||
Status::IOError(context, strerror(err_number));
|
||||
switch (err_number) {
|
||||
case ENOSPC:
|
||||
return Status::NoSpace(context, strerror(err_number));
|
||||
case ESTALE:
|
||||
return Status::IOError(Status::kStaleFile);
|
||||
default:
|
||||
return Status::IOError(context, strerror(err_number));
|
||||
}
|
||||
}
|
||||
|
||||
class PosixHelper {
|
||||
|
|
|
@ -12,7 +12,9 @@ const char* Status::msgs[] = {
|
|||
"Timeout Acquiring Mutex", // kMutexTimeout
|
||||
"Timeout waiting to lock key", // kLockTimeout
|
||||
"Failed to acquire lock due to max_num_locks limit", // kLockLimit
|
||||
"No space left on device" // kNoSpace
|
||||
"No space left on device", // kNoSpace
|
||||
"Deadlock", // kDeadlock
|
||||
"Stale file handle" // kStaleFile
|
||||
};
|
||||
|
||||
} // namespace rocksdb
|
||||
|
|
Loading…
Reference in a new issue