Fix false debug assertion and clarify error message

The debug assertion wasn't well placed as it is perfectly possible that a
master connnection exists but it is not in use. This can be further
checked by asserting that the master is indeed closed and not in use.

Moved the original debug assertion into a separate branch that should
catch any errors in the routing logic.
This commit is contained in:
Markus Mäkelä 2018-02-07 11:24:52 +02:00
parent 8558ace801
commit 6dbec397dc
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -1044,11 +1044,17 @@ static void log_master_routing_failure(RWSplitSession *rses, bool found,
sprintf(errmsg, "Session is in read-only mode because it was created "
"when no master was available");
}
else if (old_master && !old_master->in_use())
{
sprintf(errmsg, "Was supposed to route to master but the master connection is %s",
old_master->is_closed() ? "closed" : "not in a suitable state");
ss_dassert(old_master->is_closed());
}
else
{
ss_dassert(false); // A session should always have a master reference
sprintf(errmsg, "Was supposed to route to master but couldn't "
"find master in a suitable state");
"find original master connection");
ss_dassert(!true);
}
}