[Commits] c0f67cc1: Revert MDEV-17243: "FSM: no such a transition ABORTING -> REPLICATING"
revision-id: c0f67cc18569a9f9b060b33094dba261202705da (mariadb-25.3.19-18-gc0f67cc1) parent(s): 56bc9f8a19a360465f561a2f6e254cddb10a50b0 author: Jan Lindström committer: Jan Lindström timestamp: 2018-10-31 11:33:13 +0200 message: Revert MDEV-17243: "FSM: no such a transition ABORTING -> REPLICATING" --- galera/src/replicator_smm.hpp | 2 +- galera/src/wsdb.cpp | 78 ++++++------------------------------------- galera/src/wsdb.hpp | 19 ----------- 3 files changed, 11 insertions(+), 88 deletions(-) diff --git a/galera/src/replicator_smm.hpp b/galera/src/replicator_smm.hpp index d8de2e7a..9259ff59 100644 --- a/galera/src/replicator_smm.hpp +++ b/galera/src/replicator_smm.hpp @@ -349,7 +349,7 @@ namespace galera case OOOC: return true; case LOCAL_OOOC: - if (trx_.is_local()) { return true; } + return trx_.is_local(); // in case of remote trx fall through // fall through case NO_OOOC: diff --git a/galera/src/wsdb.cpp b/galera/src/wsdb.cpp index f103ce59..0aa42c5a 100644 --- a/galera/src/wsdb.cpp +++ b/galera/src/wsdb.cpp @@ -35,7 +35,6 @@ galera::Wsdb::Wsdb() : trx_pool_ (TrxHandle::LOCAL_STORAGE_SIZE(), 512, "LocalTrxHandle"), trx_map_ (), - conn_trx_map_(), trx_mutex_ (), conn_map_ (), conn_mutex_ () @@ -56,9 +55,6 @@ galera::Wsdb::~Wsdb() assert(conn_map_.size() == 0); #else for_each(trx_map_.begin(), trx_map_.end(), Unref2nd<TrxMap::value_type>()); - for_each(conn_trx_map_.begin(), - conn_trx_map_.end(), - Unref2nd<ConnTrxMap::value_type>()); #endif // !NDEBUG } @@ -68,31 +64,8 @@ galera::Wsdb::find_trx(wsrep_trx_id_t const trx_id) { gu::Lock lock(trx_mutex_); - galera::TrxHandle* trx; - /* trx-id = 0 is safe-guard condition. - trx-id is generally assigned from thd->query-id and - query-id default is 0. If background thread try to assign - wsrep_next_trx_id before setting query-id we will hit - this assertion: */ - assert(trx_id != 0); - - if (trx_id != wsrep_trx_id_t(-1)) - { - /* trx_id is valid and unique. Search for this trx_id in the - trx_id -> trx map: */ - TrxMap::iterator const i(trx_map_.find(trx_id)); - trx = (trx_map_.end() == i ? NULL : i->second); - } - else - { - /* trx_id is default, so search for repsective connection id - in connection-transaction map: */ - gu_thread_t const id = gu_thread_self(); - ConnTrxMap::iterator const i(conn_trx_map_.find(id)); - trx = (conn_trx_map_.end() == i ? NULL : i->second); - } - - return (trx); + TrxMap::iterator const i(trx_map_.find(trx_id)); + return (trx_map_.end() == i ? NULL : i->second); } @@ -105,28 +78,10 @@ galera::Wsdb::create_trx(const TrxHandle::Params& params, gu::Lock lock(trx_mutex_); - galera::TrxHandle* trx_ref; - if (trx_id != wsrep_trx_id_t(-1)) - { - /* trx_id is valid, add it to trx-map as valid trx_id, which - is unique accross connections: */ - std::pair<TrxMap::iterator, bool> i - (trx_map_.insert(std::make_pair(trx_id, trx))); - if (gu_unlikely(i.second == false)) gu_throw_fatal; - trx_ref = i.first->second; - } - else - { - /* trx_id is default so add trx object to connection map - that is maintained based on gu_thread_id (actually it is - alias for connection_id): */ - std::pair<ConnTrxMap::iterator, bool> i - (conn_trx_map_.insert(std::make_pair(gu_thread_self(), trx))); - if (gu_unlikely(i.second == false)) gu_throw_fatal; - trx_ref = i.first->second; - } - - return (trx_ref); + std::pair<TrxMap::iterator, bool> i + (trx_map_.insert(std::make_pair(trx_id, trx))); + if (gu_unlikely(i.second == false)) gu_throw_fatal; + return i.first->second; } @@ -196,24 +151,11 @@ galera::Wsdb::get_conn_query(const TrxHandle::Params& params, void galera::Wsdb::discard_trx(wsrep_trx_id_t trx_id) { gu::Lock lock(trx_mutex_); - if (trx_id != wsrep_trx_id_t(-1)) - { - TrxMap::iterator i; - if ((i = trx_map_.find(trx_id)) != trx_map_.end()) - { - i->second->unref(); - trx_map_.erase(i); - } - } - else + TrxMap::iterator i; + if ((i = trx_map_.find(trx_id)) != trx_map_.end()) { - ConnTrxMap::iterator i; - gu_thread_t id = gu_thread_self(); - if ((i = conn_trx_map_.find(id)) != conn_trx_map_.end()) - { - i->second->unref(); - conn_trx_map_.erase(i); - } + i->second->unref(); + trx_map_.erase(i); } } diff --git a/galera/src/wsdb.hpp b/galera/src/wsdb.hpp index 072ecffc..3b78f031 100644 --- a/galera/src/wsdb.hpp +++ b/galera/src/wsdb.hpp @@ -7,7 +7,6 @@ #include "trx_handle.hpp" #include "wsrep_api.h" #include "gu_unordered.hpp" -#include "gu_thread.hpp" namespace galera { @@ -56,23 +55,6 @@ namespace galera typedef gu::UnorderedMap<wsrep_trx_id_t, TrxHandle*, TrxHash> TrxMap; - /* TrxMap structure doesn't take into consideration presence of - two trx objects with same trx_id (2^64 - 1 which is default trx_id) - belonging to two different connections. - This eventually causes same trx object to get shared among two - different unrelated connections which causes state inconsistency - leading to crash (RACE CONDITION). - This problem could be solved by taking into consideration conn-id, - but that would invite interface change. To avoid this we maintain a - separate map of such trx objects based on gu_thread_id: */ - class ConnTrxHash - { - public: - size_t operator()(const gu_thread_t& key) const { return key; } - }; - - typedef gu::UnorderedMap<gu_thread_t, TrxHandle*, ConnTrxHash> ConnTrxMap; - class ConnHash { public: @@ -135,7 +117,6 @@ namespace galera TrxHandle::LocalPool trx_pool_; TrxMap trx_map_; - ConnTrxMap conn_trx_map_; gu::Mutex trx_mutex_; ConnMap conn_map_; gu::Mutex conn_mutex_;
participants (1)
-
jan