From fc5f59d27eecb6f53425fbc10fe3b794f050c861 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 24 Jan 2019 13:34:15 +0200 Subject: [PATCH] Implemented dbsim high prio service log_dummy_write_set() The empty implementation of log_dummy_write_set() in dbsim high priority service implementation left unreleased commit order critical section behind whenever remote write set failed certification. Added calls to do empty commit to release the critical section. Other: Implemented ostream operator<< for wsrep::thread::id, and added printout of owning thread into transaction debug output. --- dbsim/db_high_priority_service.cpp | 17 +++++++++++++++++ dbsim/db_high_priority_service.hpp | 3 +-- include/wsrep/thread.hpp | 6 +++++- src/CMakeLists.txt | 1 + src/thread.cpp | 30 ++++++++++++++++++++++++++++++ src/transaction.cpp | 3 +-- 6 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 src/thread.cpp diff --git a/dbsim/db_high_priority_service.cpp b/dbsim/db_high_priority_service.cpp index bb7c4c5..0d2636f 100644 --- a/dbsim/db_high_priority_service.cpp +++ b/dbsim/db_high_priority_service.cpp @@ -89,6 +89,23 @@ void db::high_priority_service::after_apply() client_.client_state_.after_applying(); } +int db::high_priority_service::log_dummy_write_set( + const wsrep::ws_handle& ws_handle, + const wsrep::ws_meta& ws_meta) +{ + int ret(client_.client_state_.start_transaction(ws_handle, ws_meta)); + assert(ret == 0); + client_.client_state_.prepare_for_ordering(ws_handle, ws_meta, true); + ret = client_.client_state_.before_commit(); + assert(ret == 0); + ret = client_.client_state_.ordered_commit(); + assert(ret == ret); + ret = client_.client_state_.after_commit(); + assert(ret == 0); + client_.client_state_.after_applying(); + return ret; +} + bool db::high_priority_service::is_replaying() const { return (client_.client_state_.transaction().state() == wsrep::transaction::s_replaying); diff --git a/dbsim/db_high_priority_service.hpp b/dbsim/db_high_priority_service.hpp index 8f3f49c..5bb4a78 100644 --- a/dbsim/db_high_priority_service.hpp +++ b/dbsim/db_high_priority_service.hpp @@ -52,8 +52,7 @@ namespace db void switch_execution_context(wsrep::high_priority_service&) override { } int log_dummy_write_set(const wsrep::ws_handle&, - const wsrep::ws_meta&) override - { return 0; } + const wsrep::ws_meta&) override; bool is_replaying() const override; void debug_crash(const char*) override { } private: diff --git a/include/wsrep/thread.hpp b/include/wsrep/thread.hpp index 34d87b2..99b8cff 100644 --- a/include/wsrep/thread.hpp +++ b/include/wsrep/thread.hpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Codership Oy + * Copyright (C) 2018-2019 Codership Oy * * This file is part of wsrep-lib. * @@ -18,6 +18,7 @@ */ #include +#include namespace wsrep { @@ -34,6 +35,7 @@ namespace wsrep { return (pthread_equal(left.thread_, right.thread_)); } + friend std::ostream& operator<<(std::ostream&, const id&); pthread_t thread_; }; @@ -48,4 +50,6 @@ namespace wsrep { static inline thread::id get_id() { return thread::id(pthread_self()); } } + + std::ostream& operator<<(std::ostream&, const thread::id&); }; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f24b3a..16fe5bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,7 @@ add_library(wsrep-lib seqno.cpp view.cpp server_state.cpp + thread.cpp transaction.cpp wsrep_provider_v26.cpp) target_link_libraries(wsrep-lib wsrep_api_v26 pthread dl) diff --git a/src/thread.cpp b/src/thread.cpp new file mode 100644 index 0000000..5fec0ff --- /dev/null +++ b/src/thread.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2019 Codership Oy + * + * This file is part of wsrep-lib. + * + * Wsrep-lib is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Wsrep-lib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with wsrep-lib. If not, see . + */ + +#include "wsrep/thread.hpp" + +#include + +std::ostream& wsrep::operator<<(std::ostream& os, const wsrep::thread::id& id) +{ + std::ios_base::fmtflags orig_flags(os.flags()); + os << std::hex << id.thread_; + os.flags(orig_flags); + return os; +} diff --git a/src/transaction.cpp b/src/transaction.cpp index 81ba1e4..46e38a8 100644 --- a/src/transaction.cpp +++ b/src/transaction.cpp @@ -758,8 +758,6 @@ int wsrep::transaction::after_statement() ret = provider().commit_order_enter(ws_handle_, ws_meta_); if (ret == 0) { - // client_state_.server_state().last_committed_gtid( - // ws_meta.gtid()); provider().commit_order_leave(ws_handle_, ws_meta_); } } @@ -1550,6 +1548,7 @@ void wsrep::transaction::debug_log_state( << ", bytes: " << streaming_context_.bytes_certified() << ", sr_rb: " << streaming_context_.rolled_back() << "\n own: " << (client_state_.owning_thread_id_ == wsrep::this_thread::get_id()) + << " thread_id: " << client_state_.owning_thread_id_ << ""); }