MXS-1921: Explain why session was closed

When a client connection is closed by MaxScale before the client initiates
a controlled closing of the connection, an error message is sent. This
error message now also explains why the connection was closed to make
problem resolution easier.
This commit is contained in:
Markus Mäkelä
2018-06-14 13:48:07 +03:00
parent 315738f279
commit 3d1c2b421a
6 changed files with 67 additions and 1 deletions

View File

@ -135,6 +135,17 @@ typedef struct mxs_upstream
int32_t (*error)(void *instance, void *session, void *);
} MXS_UPSTREAM;
/* Specific reasons why a session was closed */
typedef enum
{
SESSION_CLOSE_NONE = 0, // No special reason
SESSION_CLOSE_TIMEOUT, // Connection timed out
SESSION_CLOSE_HANDLEERROR_FAILED, // Router returned an error from handleError
SESSION_CLOSE_ROUTING_FAILED, // Router closed DCB
SESSION_CLOSE_KILLED, // Killed by another connection
SESSION_CLOSE_TOO_MANY_CONNECTIONS, // Too many connections
} session_close_t;
/**
* The session status block
*
@ -169,6 +180,7 @@ typedef struct session
} stmt; /**< Current statement being executed */
bool qualifies_for_pooling; /**< Whether this session qualifies for the connection pool */
SessionStmtQueue* last_statements; /*< The N last statements by the client */
session_close_t close_reason; /**< Reason why the session was closed */
skygw_chk_t ses_chk_tail;
} MXS_SESSION;
@ -534,4 +546,15 @@ void session_set_dump_statements(session_dump_statements_t value);
*/
session_dump_statements_t session_get_dump_statements();
/**
* Get the reason why a session was closed
*
* @param session Session to inspect
*
* @return String representation of the reason why the session was closed. If
* the session was closed normally, an empty string is returned.
*/
const char* session_get_close_reason(const MXS_SESSION* session);
MXS_END_DECLS