diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 772ab55586..70101edd40 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -2527,7 +2527,11 @@ int MySQL_Session::handler() { myconn->async_state_machine=ASYNC_IDLE; myds->DSS=STATE_MARIADB_GENERIC; if (transaction_persistent==true) { - transaction_persistent_hostgroup=current_hostgroup; + if (transaction_persistent_hostgroup==-1) { // change only if not set already, do not allow to change it again + if (myds->myconn->IsActiveTransaction()==true) { // only active transaction is important here. Ignore other criterias + transaction_persistent_hostgroup=current_hostgroup; + } + } } } } else {