MXS-1366: Validate closed connections before pooling them

When a session is being closed in a controlled manner, i.e. a COM_QUIT is
received from the client, it is possible to deduce from this fact that the
backend connections are very likely to be idle. This can be used as an
additional qualification that must be met by all connections before they
can be candidates for connection pooling.

This assumption will not hold with batched and asynchronous queries. In
this case it is possible that the COM_QUIT is received from the client
before even the first result from the backend is read. For this to work,
the protocol module would need to track the number and state of expected
responses.
This commit is contained in:
Markus Mäkelä
2017-08-21 10:31:07 +03:00
parent b56594470b
commit 5b1f8afcd9
4 changed files with 42 additions and 0 deletions

View File

@ -145,6 +145,7 @@ typedef struct session
GWBUF *buffer; /**< Buffer containing the statement */
const struct server *target; /**< Where the statement was sent */
} stmt; /**< Current statement being executed */
bool qualifies_for_pooling; /**< Whether this session qualifies for the connection pool */
skygw_chk_t ses_chk_tail;
} MXS_SESSION;
@ -365,4 +366,18 @@ bool session_take_stmt(MXS_SESSION *session, GWBUF **buffer, const struct server
*/
void session_clear_stmt(MXS_SESSION *session);
/**
* Qualify the session for connection pooling
*
* @param session Session to qualify
*/
void session_qualify_for_pool(MXS_SESSION* session);
/**
* Check if the session qualifies for connection pooling
*
* @param session
*/
bool session_valid_for_pool(const MXS_SESSION* session);
MXS_END_DECLS