From a035c91fa629f77ba7af54bf984bc4211fbcf03c Mon Sep 17 00:00:00 2001 From: Dapeng Huang <7xerocha@gmail.com> Date: Fri, 26 Jan 2018 10:22:30 +0800 Subject: [PATCH] add doc for session_track_trx_state and refactor little --- .gitignore | 1 + .../Getting-Started/Configuration-Guide.md | 13 +++++++++++++ server/modules/protocol/MySQL/mysql_common.cc | 6 +++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d3f5d2e19..ecfc3032c 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ CMakeFiles/* */*/*/*/CMakeFiles/* Makefile /.DS_Store +.DS_Store # Netbeans Project files nbproject/ diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index 3609f404b..e12058d50 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -1063,6 +1063,19 @@ seconds. The interval is incremented until the value of `max_retry_interval` is reached at which point the listener attempts to bind to the interface every `max_retry_interval` seconds. +#### `session_track_trx_state` + +Enable or disable getting session transation state via session track mechanism. This +parameter takes a boolean value. Default False. + +Get current session transaction state from server side will be more accurate. +Minimum Server version Mariadb 10.3 or MySQL 5.7 is needed and following server +config is also needed. + ``` + session_track_state_change = ON + session_track_transaction_info = CHARACTERISTICS + ``` + ### Server Server sections are used to define the backend database servers that can be diff --git a/server/modules/protocol/MySQL/mysql_common.cc b/server/modules/protocol/MySQL/mysql_common.cc index 8ddc4b818..33a567c6c 100644 --- a/server/modules/protocol/MySQL/mysql_common.cc +++ b/server/modules/protocol/MySQL/mysql_common.cc @@ -1857,7 +1857,7 @@ void mxs_mysql_get_session_track_info(GWBUF *buff, MySQLProtocol *proto) { while (gwbuf_copy_data(buff, offset, MYSQL_HEADER_LEN + 1, header_and_command) == (MYSQL_HEADER_LEN + 1)) { - size_t packet_len = gw_mysql_get_byte3(header_and_command); + size_t packet_len = gw_mysql_get_byte3(header_and_command) + MYSQL_HEADER_LEN; uint8_t cmd = header_and_command[MYSQL_COM_OFFSET]; if (packet_len > MYSQL_OK_PACKET_MIN_LEN && @@ -1865,7 +1865,7 @@ void mxs_mysql_get_session_track_info(GWBUF *buff, MySQLProtocol *proto) (proto->num_eof_packets % 2) == 0) { buff->gwbuf_type |= GWBUF_TYPE_REPLY_OK; - mxs_mysql_parse_ok_packet(buff, offset, packet_len + MYSQL_HEADER_LEN); + mxs_mysql_parse_ok_packet(buff, offset, packet_len); } if ((proto->current_command == MXS_COM_QUERY || @@ -1875,7 +1875,7 @@ void mxs_mysql_get_session_track_info(GWBUF *buff, MySQLProtocol *proto) { proto->num_eof_packets++; } - offset += (packet_len + MYSQL_HEADER_LEN); + offset += packet_len; } } }