From fdc125c043b3de0e88976769ea6d144594e6f2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E8=BF=8E=E6=98=A5?= Date: Fri, 5 May 2023 14:37:59 +0800 Subject: [PATCH] [SKV-636] refactor: remove useless function 'last_flushed_decree()' (#1456) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 对应社区commit: https://github.com/apache/incubator-pegasus/pull/1456/files https://github.com/apache/incubator-pegasus/issues/1383 This is a refactor patch before fixing #1383. This patch has no functionality changes, but just including refactors: 1. Moves functions `load()`, `newr()` and `clear_on_failure()` from class replica to class replica_stub, and the first two have been renamed to `load_replica()` and `new_replica()`. 2. Encapsulates a new function `move_to_err_path`. 3. Some minor refactors like fix typo. --- .../include/dsn/dist/replication/replication_app_base.h | 1 - src/rdsn/src/replica/replica.cpp | 2 -- src/rdsn/src/replica/replica.h | 1 - src/server/pegasus_server_impl.cpp | 7 +------ src/server/pegasus_server_impl.h | 2 -- 5 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/rdsn/include/dsn/dist/replication/replication_app_base.h b/src/rdsn/include/dsn/dist/replication/replication_app_base.h index c8aa2cec6c..65835b9311 100644 --- a/src/rdsn/include/dsn/dist/replication/replication_app_base.h +++ b/src/rdsn/include/dsn/dist/replication/replication_app_base.h @@ -210,7 +210,6 @@ class replication_app_base : public replica_base // Query methods. // virtual replication::decree last_durable_decree() const = 0; - virtual replication::decree last_flushed_decree() const { return last_durable_decree(); } // The return type is generated by storage engine, e.g. rocksdb::Status::Code, 0 always mean OK. virtual int on_request(message_ex *request) = 0; diff --git a/src/rdsn/src/replica/replica.cpp b/src/rdsn/src/replica/replica.cpp index b79e72a01a..3f215b2f67 100644 --- a/src/rdsn/src/replica/replica.cpp +++ b/src/rdsn/src/replica/replica.cpp @@ -418,8 +418,6 @@ mutation_ptr replica::new_mutation(decree decree) decree replica::last_durable_decree() const { return _app->last_durable_decree(); } -decree replica::last_flushed_decree() const { return _app->last_flushed_decree(); } - decree replica::last_prepared_decree() const { ballot lastBallot = 0; diff --git a/src/rdsn/src/replica/replica.h b/src/rdsn/src/replica/replica.h index 67369c4ed6..f49c8eb589 100644 --- a/src/rdsn/src/replica/replica.h +++ b/src/rdsn/src/replica/replica.h @@ -197,7 +197,6 @@ class replica : public serverlet, public ref_counter, public replica_ba decree last_committed_decree() const { return _prepare_list->last_committed_decree(); } decree last_prepared_decree() const; decree last_durable_decree() const; - decree last_flushed_decree() const; const std::string &dir() const { return _dir; } uint64_t create_time_milliseconds() const { return _create_time_ms; } const char *name() const { return replica_name(); } diff --git a/src/server/pegasus_server_impl.cpp b/src/server/pegasus_server_impl.cpp index 8c8bdd222f..98388285d6 100644 --- a/src/server/pegasus_server_impl.cpp +++ b/src/server/pegasus_server_impl.cpp @@ -2597,11 +2597,6 @@ void pegasus_server_impl::update_app_envs(const std::mapget_last_flushed_decree(); -} - void pegasus_server_impl::update_app_envs_before_open_db( const std::map &envs) { @@ -3174,7 +3169,7 @@ bool pegasus_server_impl::release_storage_after_manual_compact() gc_checkpoints(true); ddebug_replica("finish gc_checkpoints, time_used = {}ms", dsn_now_ms() - start_time); - int64_t new_last_durable = last_flushed_decree(); + int64_t new_last_durable = _meta_store->get_last_flushed_decree(); if (new_last_durable > old_last_durable) { ddebug_replica("release storage succeed, last_durable_decree changed from {} to {}", old_last_durable, diff --git a/src/server/pegasus_server_impl.h b/src/server/pegasus_server_impl.h index 09fc34b651..1b654e9a3a 100644 --- a/src/server/pegasus_server_impl.h +++ b/src/server/pegasus_server_impl.h @@ -181,8 +181,6 @@ class pegasus_server_impl : public pegasus_read_service int64_t last_durable_decree() const override { return _last_durable_decree.load(); } - int64_t last_flushed_decree() const override; - void update_app_envs(const std::map &envs) override; void query_app_envs(/*out*/ std::map &envs) override;