MXS-827: Add connection keepalive

The readwritesplit now sends COM_PING queries to backend servers that have
been idle for too long. The option is configured with the
`connection_keepalive` parameter.
This commit is contained in:
Markus Mäkelä
2017-03-24 05:22:25 +02:00
parent e3bae59e1a
commit 710012ac5d
10 changed files with 125 additions and 14 deletions

View File

@ -58,7 +58,8 @@ typedef enum
GWBUF_TYPE_SESCMD_RESPONSE = 0x08,
GWBUF_TYPE_RESPONSE_END = 0x10,
GWBUF_TYPE_SESCMD = 0x20,
GWBUF_TYPE_HTTP = 0x40
GWBUF_TYPE_HTTP = 0x40,
GWBUF_TYPE_IGNORABLE = 0x80
} gwbuf_type_t;
#define GWBUF_IS_TYPE_UNDEFINED(b) (b->gwbuf_type == 0)
@ -68,6 +69,7 @@ typedef enum
#define GWBUF_IS_TYPE_SESCMD_RESPONSE(b) (b->gwbuf_type & GWBUF_TYPE_SESCMD_RESPONSE)
#define GWBUF_IS_TYPE_RESPONSE_END(b) (b->gwbuf_type & GWBUF_TYPE_RESPONSE_END)
#define GWBUF_IS_TYPE_SESCMD(b) (b->gwbuf_type & GWBUF_TYPE_SESCMD)
#define GWBUF_IS_IGNORABLE(b) (b->gwbuf_type & GWBUF_TYPE_IGNORABLE)
/**
* A structure to encapsulate the data in a form that the data itself can be

View File

@ -76,6 +76,14 @@ mxs_pcre2_result_t modutil_mysql_wildcard_match(const char* pattern, const char*
*/
char* modutil_MySQL_bypass_whitespace(char* sql, size_t len);
/**
* @brief Write a COM_PING to a DCB and ignore the response
*
* @param dcb The backend DCB where the COM_PING is written
* @return True if command was successfully sent
*/
bool modutil_ignorable_ping(DCB *dcb);
/** Character and token searching functions */
char* strnchr_esc(char* ptr, char c, int len);
char* strnchr_esc_mysql(char* ptr, char c, int len);

View File

@ -305,7 +305,7 @@ typedef struct
uint32_t extra_capabilities; /*< MariaDB 10.2 capabilities */
unsigned long tid; /*< MySQL Thread ID, in handshake */
unsigned int charset; /*< MySQL character set at connect time */
bool ignore_reply; /*< If the reply should be discarded */
int ignore_replies; /*< How many replies should be discarded */
GWBUF* stored_query; /*< Temporarily stored queries */
#if defined(SS_DEBUG)
skygw_chk_t protocol_chk_tail;