From 13e9403ebabfe31f401776670247a32e74e8f955 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Tue, 19 Sep 2023 14:03:41 +0300 Subject: [PATCH] Allow storage service implementation to run in client context If the storage service implementation can operate in client session context, avoid resetting/restoring globals when changing to storage service scope in transaction.cpp. --- include/wsrep/storage_service.hpp | 11 +++++++++++ src/transaction.cpp | 11 ++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/wsrep/storage_service.hpp b/include/wsrep/storage_service.hpp index e68548b..3c689b6 100644 --- a/include/wsrep/storage_service.hpp +++ b/include/wsrep/storage_service.hpp @@ -92,6 +92,17 @@ namespace wsrep virtual void store_globals() = 0; virtual void reset_globals() = 0; + + /** + * Return true if the implementation requires storing + * and restoring global state. Return true by default + * since this is the original behavior. Stateless + * implementations may override. + */ + virtual bool requires_globals() const { + return true; + } + }; } diff --git a/src/transaction.cpp b/src/transaction.cpp index 505234c..f1fd86d 100644 --- a/src/transaction.cpp +++ b/src/transaction.cpp @@ -63,8 +63,10 @@ namespace { throw wsrep::runtime_error("Null client_state provided"); } - client_service_.reset_globals(); - storage_service_->store_globals(); + if (storage_service_->requires_globals()) { + client_service_.reset_globals(); + storage_service_->store_globals(); + } } wsrep::storage_service& storage_service() @@ -74,8 +76,11 @@ namespace ~scoped_storage_service() { + bool restore_globals = storage_service_->requires_globals(); deleter_(storage_service_); - client_service_.store_globals(); + if (restore_globals) { + client_service_.store_globals(); + } } private: scoped_storage_service(const scoped_storage_service&);