From 3d4b8814b75c6a32927558b589e0e119cd84f7a6 Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Mon, 24 Apr 2023 21:02:12 +0800 Subject: [PATCH] refactor: fs manager --- src/replica/replica.cpp | 7 +++++-- src/replica/replica_failover.cpp | 6 +++++- src/replica/replica_learn.cpp | 8 ++++++-- src/replica/replication_app_base.cpp | 6 ++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/replica/replica.cpp b/src/replica/replica.cpp index d2f9ccefbb..e23d389ed1 100644 --- a/src/replica/replica.cpp +++ b/src/replica/replica.cpp @@ -304,11 +304,14 @@ void replica::on_client_read(dsn::message_ex *request, bool ignore_throttling) auto storage_error = _app->on_request(request); if (dsn_unlikely(storage_error != ERR_OK)) { switch (storage_error) { - // TODO(yingchun): Now only kCorruption is dealt, consider to deal with more storage - // engine errors. + // TODO(yingchun): Now only kCorruption and kIOError is dealt, consider to deal with + // more storage engine errors. case rocksdb::Status::kCorruption: handle_local_failure(ERR_RDB_CORRUPTION); break; + case rocksdb::Status::kIOError: + handle_local_failure(ERR_DISK_IO_ERROR); + break; default: LOG_ERROR_PREFIX("client read encountered an unhandled error: {}", storage_error); } diff --git a/src/replica/replica_failover.cpp b/src/replica/replica_failover.cpp index 94edaab837..c465c221d7 100644 --- a/src/replica/replica_failover.cpp +++ b/src/replica/replica_failover.cpp @@ -33,8 +33,10 @@ * xxxx-xx-xx, author, fix bug about xxx */ +#include #include +#include "common/fs_manager.h" #include "common/replication_common.h" #include "common/replication_enums.h" #include "dsn.layer2_types.h" @@ -54,7 +56,9 @@ void replica::handle_local_failure(error_code error) { LOG_INFO_PREFIX("handle local failure error {}, status = {}", error, enum_to_string(status())); - if (error == ERR_RDB_CORRUPTION) { + if (error == ERR_DISK_IO_ERROR) { + _dir_node->status = disk_status::IO_ERROR; + } else if (error == ERR_RDB_CORRUPTION) { _data_corrupted = true; } diff --git a/src/replica/replica_learn.cpp b/src/replica/replica_learn.cpp index f65f775190..75fc9c5894 100644 --- a/src/replica/replica_learn.cpp +++ b/src/replica/replica_learn.cpp @@ -1238,8 +1238,12 @@ void replica::handle_learning_error(error_code err, bool is_local_error) err, is_local_error ? "local_error" : "remote error"); - if (is_local_error && err == ERR_RDB_CORRUPTION) { - _data_corrupted = true; + if (is_local_error) { + if (err == ERR_DISK_IO_ERROR) { + _dir_node->status = disk_status::IO_ERROR; + } else if (err == ERR_RDB_CORRUPTION) { + _data_corrupted = true; + } } _stub->_counter_replicas_learning_recent_learn_fail_count->increment(); diff --git a/src/replica/replication_app_base.cpp b/src/replica/replication_app_base.cpp index 5159fd757d..db92bdf17e 100644 --- a/src/replica/replication_app_base.cpp +++ b/src/replica/replication_app_base.cpp @@ -457,10 +457,12 @@ error_code replication_app_base::apply_mutation(const mutation *mu) // an error. if (!has_ingestion_request) { switch (storage_error) { - // TODO(yingchun): Now only kCorruption is dealt, consider to deal with more storage - // engine errors. + // TODO(yingchun): Now only kCorruption and kIOError are dealt, consider to deal with + // more storage engine errors. case rocksdb::Status::kCorruption: return ERR_RDB_CORRUPTION; + case rocksdb::Status::kIOError: + return ERR_DISK_IO_ERROR; default: return ERR_LOCAL_APP_FAILURE; }