Improve fast forward replication CLIENT_DEPRECATE_EOF validation

Enhance the match_ff_req_options function to better handle CLIENT_DEPRECATE_EOF
flag validation in fast forward replication scenarios. The function now performs
a more robust check by examining the actual MySQL command type when the initial
CLIENT_DEPRECATE_EOF flags don't match between frontend and backend connections.

Key improvements:
- Special handling for binlog-related commands (_MYSQL_COM_BINLOG_DUMP,
  _MYSQL_COM_BINLOG_DUMP_GTID, _MYSQL_COM_REGISTER_SLAVE) that should be
  allowed even when CLIENT_DEPRECATE_EOF flags don't match
- Proper packet parsing to extract and validate MySQL command types
- Enhanced compatibility for fast forward replication connections with
  mixed deprecate EOF configurations

This change ensures that ProxySQL can handle more complex replication
scenarios while maintaining proper protocol validation.
v3.0-5062
Rene Cannao 2 months ago
parent 5d2d26d74e
commit 5485bb02f4

@ -738,8 +738,29 @@ bool MySQL_Connection::match_ff_req_options(const MySQL_Connection *c) {
// Only required to be checked for fast_forward sessions
if (frontend->myds && frontend->myds->sess->session_fast_forward) {
return (frontend->options.client_flag & CLIENT_DEPRECATE_EOF) ==
bool ret = (frontend->options.client_flag & CLIENT_DEPRECATE_EOF) ==
(backend->mysql->server_capabilities & CLIENT_DEPRECATE_EOF);
if (ret == false) {
if (frontend->myds && frontend->myds->PSarrayIN) {
PtrSizeArray * PSarrayIN = frontend->myds->PSarrayIN;
if (PSarrayIN->len == 1) {
PtrSize_t pkt = PSarrayIN->pdata[0];
if (pkt.size >= 5) {
unsigned char c = *reinterpret_cast<unsigned char*>(static_cast<char*>(pkt.ptr) + 4);
switch ((enum_mysql_command)c) {
case _MYSQL_COM_BINLOG_DUMP:
case _MYSQL_COM_BINLOG_DUMP_GTID:
case _MYSQL_COM_REGISTER_SLAVE:
ret = true;
break;
default:
break;
};
}
}
}
}
return ret;
} else {
return true;
}

Loading…
Cancel
Save