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&);