From c5b47389df8fab10afd1582b8363524fb23b668f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Aug 2020 08:27:34 +0300 Subject: [PATCH] MXS-3106: Always write the final COM_QUIT This seems to help with a regression that was introduced in 2.4.11. --- include/maxscale/dcb.hh | 5 +++++ include/maxscale/protocol/mysql.hh | 1 - server/core/dcb.cc | 5 +++-- .../protocol/MySQL/mariadbbackend/mysql_backend.cc | 14 +++----------- server/modules/protocol/MySQL/mysql_common.cc | 1 - 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/maxscale/dcb.hh b/include/maxscale/dcb.hh index 8dc9659f6..dc0c6b977 100644 --- a/include/maxscale/dcb.hh +++ b/include/maxscale/dcb.hh @@ -206,6 +206,11 @@ struct DCB : public MXB_POLL_DATA bool high_water_reached = false; /** High water mark reached, to determine whether we need to * release * throttle */ + + // Enable this to prevent write errors from being logged. Helps reduce false errors when writes to + // potentially closed DCBs are done. + bool silence_write_errors = false; + struct { DCB* next = nullptr; /**< Next DCB in owning thread's list */ diff --git a/include/maxscale/protocol/mysql.hh b/include/maxscale/protocol/mysql.hh index 78c878dc2..3af98719d 100644 --- a/include/maxscale/protocol/mysql.hh +++ b/include/maxscale/protocol/mysql.hh @@ -340,7 +340,6 @@ typedef struct bool collect_result; /*< Collect the next result set as one buffer */ bool changing_user; bool track_state; /*< Track session state */ - bool send_com_quit; uint32_t num_eof_packets; /*< Encountered eof packet number, used for check * packet type */ bool large_query; /*< Whether to ignore the command byte of the next diff --git a/server/core/dcb.cc b/server/core/dcb.cc index aa03b9660..f9dc3f1b3 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -822,7 +822,7 @@ static int dcb_log_errors_SSL(DCB* dcb, int ret) unsigned long ssl_errno; ssl_errno = ERR_get_error(); - if (0 == ssl_errno) + if (0 == ssl_errno || dcb->silence_write_errors) { return 0; } @@ -1806,7 +1806,8 @@ static int gw_write(DCB* dcb, GWBUF* writeq, bool* stop_writing) if (written < 0) { *stop_writing = true; - if (saved_errno != EAGAIN && saved_errno != EWOULDBLOCK && saved_errno != EPIPE) + if (saved_errno != EAGAIN && saved_errno != EWOULDBLOCK && saved_errno != EPIPE + && !dcb->silence_write_errors) { MXS_ERROR("Write to %s %s in state %s failed: %d, %s", dcb->type(), diff --git a/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc b/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc index 40019d170..020fc2a63 100644 --- a/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc +++ b/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc @@ -1291,12 +1291,6 @@ static int gw_MySQLWrite_backend(DCB* dcb, GWBUF* queue) } else { - - if (cmd == MXS_COM_QUIT) - { - backend_protocol->send_com_quit = false; - } - if (GWBUF_IS_IGNORABLE(queue)) { /** The response to this command should be ignored */ @@ -1409,11 +1403,9 @@ static int gw_backend_close(DCB* dcb) mxb_assert(dcb->session || dcb->persistentstart); MySQLProtocol* proto = (MySQLProtocol*)dcb->protocol; - if (proto->send_com_quit && proto->protocol_auth_state == MXS_AUTH_STATE_COMPLETE) - { - // Send a COM_QUIT to the backend being closed, we haven't routed one to it yet. - dcb_write(dcb, mysql_create_com_quit(NULL, 0)); - } + // Always send a COM_QUIT to the backend being closed. This causes the connection to be closed faster. + dcb->silence_write_errors = true; + dcb_write(dcb, mysql_create_com_quit(NULL, 0)); /** Free protocol data */ mysql_protocol_done(dcb); diff --git a/server/modules/protocol/MySQL/mysql_common.cc b/server/modules/protocol/MySQL/mysql_common.cc index 547f3c869..2c5f7ccd0 100644 --- a/server/modules/protocol/MySQL/mysql_common.cc +++ b/server/modules/protocol/MySQL/mysql_common.cc @@ -64,7 +64,6 @@ MySQLProtocol* mysql_protocol_init(DCB* dcb, int fd) p->num_eof_packets = 0; p->large_query = false; p->track_state = false; - p->send_com_quit = true; /*< Assign fd with protocol */ p->fd = fd; p->owner_dcb = dcb;