MXS-812: Fix active operation counters

When a client executes commands which do not return results (for example
inserting BLOB data via the C API), readwritesplit expects a result for
each sent packet. This is a somewhat of a false assumption but it clears
itself out when the session is closed normally. If the session is closed
due to an error, the counter is not decremented.

Each sesssion should only increase the number of active operation on a
server by one operation. By checking that the session is not already
executing an operation before incrementing the active operation count the
runtime operation count will be correct.
This commit is contained in:
Markus Makela 2016-09-08 15:56:48 +03:00
parent 4a95439a8d
commit 7a144079b9

View File

@ -942,7 +942,7 @@ static void closeSession(ROUTER *instance, void *router_session)
}
#endif
/** Clean operation counter in bref and in SERVER */
while (BREF_IS_WAITING_RESULT(bref))
if (BREF_IS_WAITING_RESULT(bref))
{
bref_clear_state(bref, BREF_WAITING_RESULT);
}
@ -955,6 +955,10 @@ static void closeSession(ROUTER *instance, void *router_session)
/** decrease server current connection counters */
atomic_add(&bref->bref_backend->backend_conn_count, -1);
}
else
{
ss_dassert(!BREF_IS_WAITING_RESULT(bref));
}
}
/** Unlock */
rses_end_locked_router_action(router_cli_ses);
@ -2796,11 +2800,8 @@ static void bref_clear_state(backend_ref_t *bref, bref_state_t state)
MXS_ERROR("[%s] Error: NULL parameter.", __FUNCTION__);
return;
}
if (state != BREF_WAITING_RESULT)
{
bref->bref_state &= ~state;
}
else
if ((state & BREF_WAITING_RESULT) && (bref->bref_state & BREF_WAITING_RESULT))
{
int prev1;
int prev2;
@ -2825,6 +2826,8 @@ static void bref_clear_state(backend_ref_t *bref, bref_state_t state)
}
}
}
bref->bref_state &= ~state;
}
static void bref_set_state(backend_ref_t *bref, bref_state_t state)
@ -2834,11 +2837,8 @@ static void bref_set_state(backend_ref_t *bref, bref_state_t state)
MXS_ERROR("[%s] Error: NULL parameter.", __FUNCTION__);
return;
}
if (state != BREF_WAITING_RESULT)
{
bref->bref_state |= state;
}
else
if ((state & BREF_WAITING_RESULT) && (bref->bref_state & BREF_WAITING_RESULT) == 0)
{
int prev1;
int prev2;
@ -2864,6 +2864,8 @@ static void bref_set_state(backend_ref_t *bref, bref_state_t state)
bref->bref_backend->backend_server->port);
}
}
bref->bref_state |= state;
}
/**