From 997fe6b90bba462eea81315afbfca376289954c2 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Sat, 24 Sep 2016 10:14:59 +0300 Subject: [PATCH] Add a fail-safe for active operation counters If a backend is not in use but it is waiting for a result, the state should anyways be cleared to keep the operation counters correct. --- server/modules/routing/readwritesplit/readwritesplit.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index ac5a8781d..0d026b800 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -958,6 +958,15 @@ static void closeSession(ROUTER *instance, void *router_session) else { ss_dassert(!BREF_IS_WAITING_RESULT(bref)); + + /** This should never be true unless a backend reference is taken + * out of use before clearing the BREF_WAITING_RESULT state */ + if (BREF_IS_WAITING_RESULT(bref)) + { + MXS_WARNING("A closed backend was expecting a result, this should not be possible. " + "Decrementing active operation counter for this backend."); + bref_clear_state(bref, BREF_WAITING_RESULT); + } } } /** Unlock */