[MDEV-19643] Invalid #ifndef WINDOWS causes error because of needless "Semisync slave socket fd" check Created: 2019-05-30  Updated: 2019-06-21  Resolved: 2019-06-21

Status: Closed
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 10.3.13, 10.3.14, 10.3.15
Fix Version/s: 10.3.17, 10.4.7

Type: Bug Priority: Major
Reporter: Kentaro Hayashi Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows



 Description   

On Windows, sometimes slave stops unexpectedlly. log shows the following error.

> 2019-05-30 3:21:55 6 [ERROR] Semisync slave socket fd is 580. select()
> cannot handle if the socket fd is greater than 64 (FD_SETSIZE).
> 2019-05-30 3:21:55 6 [Note] Stopping ack receiver thread

Searched MariaDB implementation, above log message is printed here.

https://github.com/MariaDB/server/blob/dde2ca4aa108b611b5fdfc970146b28461ef08bf/sql/semisync_master_ack_receiver.h#L214-L222

#ifndef WINDOWS
      if (socket_id > FD_SETSIZE)
      {
        sql_print_error("Semisync slave socket fd is %u. "
                        "select() cannot handle if the socket fd is "
                        "greater than %u (FD_SETSIZE).", socket_id, FD_SETSIZE);
        return 0;
      }
#endif //WINDOWS

It seems that #ifndef WINDOWS is incorrect, it should be _WIN32.
Because of incorrect #ifndef definition, needless check is executed on Windows.

It seems that master can't receive ack from slave, slave waits until master response, then it causes timeout and disconnect connection.(maybe)

In contrast to MySQL case, it uses _WIN32.

https://github.com/mysql/mysql-server/blob/8.0/plugin/semisync/semisync_master_socket_listener.h#L114-L120

#ifndef _WIN32
      if (socket_id > FD_SETSIZE) {
        LogErr(ERROR_LEVEL, ER_SEMISYNC_FAILED_TO_HANDLE_SOCKET, socket_id,
               FD_SETSIZE);
        return false;
      }
#endif // _WIN32



 Comments   
Comment by Kouhei Sutou [ 2019-05-31 ]

FYI: MySQL fixed this by https://github.com/mysql/mysql-server/commit/ec76a52483c3eec49a878e751341246be66a6802 .

Generated at Thu Feb 08 08:53:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.