s = data_dir_ptr->Close(IOOptions(), nullptr);
if (!s.ok()) {
// TODO(zichen): add `Status Close()` and `CloseDirectories()
- ROCKS_LOG_WARN(ioptions_.logger, "Ignoring error %s",
- s.ToString().c_str());
s.PermitUncheckedError();
}
}
DirFsyncOptions(options_file_name));
}
if (s.ok()) {
- s = dir_obj->Close(IOOptions(), nullptr);
+ Status temp_s = dir_obj->Close(IOOptions(), nullptr);
+ // The default Close() could return "NotSupproted" and we bypass it
+ // if it is not impelmented. Detailed explanations can be found in
+ // db/db_impl/db_impl.h
+ if (!temp_s.ok()) {
+ if (temp_s.IsNotSupported()) {
+ temp_s.PermitUncheckedError();
+ } else {
+ s = temp_s;
+ }
+ }
}
}
if (s.ok()) {
IOStatus Close(const IOOptions& options, IODebugContext* dbg) {
// close all directories for all database paths
IOStatus s = IOStatus::OK();
+ IOStatus temp_s = IOStatus::OK();
+
+ // The default implementation for Close() in Directory/FSDirectory class
+ // "NotSupported" status, the upper level interface should be able to
+ // handle this error so that Close() does not fail after upgrading when
+ // run on FileSystems that have not implemented `Directory::Close()` or
+ // `FSDirectory::Close()` yet
+
if (db_dir_) {
- s = db_dir_->Close(options, dbg);
+ temp_s = db_dir_->Close(options, dbg);
+ if (!temp_s.ok()) {
+ if (temp_s.IsNotSupported()) {
+ temp_s.PermitUncheckedError();
+ } else {
+ s = temp_s;
+ }
+ }
}
if (!s.ok()) {
if (wal_dir_) {
s = wal_dir_->Close(options, dbg);
+ if (!temp_s.ok()) {
+ if (temp_s.IsNotSupported()) {
+ temp_s.PermitUncheckedError();
+ } else {
+ s = temp_s;
+ }
+ }
}
if (!s.ok()) {
if (data_dirs_.size() > 0 && s.ok()) {
for (auto& data_dir_ptr : data_dirs_) {
if (data_dir_ptr) {
- s = data_dir_ptr->Close(options, dbg);
- if (!s.ok()) {
- return s;
+ temp_s = data_dir_ptr->Close(options, dbg);
+ if (!temp_s.ok()) {
+ if (temp_s.IsNotSupported()) {
+ temp_s.PermitUncheckedError();
+ } else {
+ return temp_s;
+ }
}
}
}
}
+ // Mark temp_s as checked when temp_s is still the initial status
+ // (IOStatus::OK(), not checked yet)
+ temp_s.PermitUncheckedError();
return s;
}
s = dir_obj->FsyncWithDirOptions(IOOptions(), nullptr,
DirFsyncOptions(identify_file_name));
}
+
+ // The default Close() could return "NotSupported" and we bypass it
+ // if it is not impelmented. Detailed explanations can be found in
+ // db/db_impl/db_impl.h
if (s.ok()) {
- s = dir_obj->Close(IOOptions(), nullptr);
+ Status temp_s = dir_obj->Close(IOOptions(), nullptr);
+ if (!temp_s.ok()) {
+ if (temp_s.IsNotSupported()) {
+ temp_s.PermitUncheckedError();
+ } else {
+ s = temp_s;
+ }
+ }
}
if (!s.ok()) {
env->DeleteFile(tmp).PermitUncheckedError();