Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-32567

Remove thr_alarm from server codebase

Details

    Description

      The thr_alarm.h, alarm() and SIGALRM has not been used for a very long time,at least since a decade . Its existence just obscures the source code (even net_real_read/net_read_write, and signal handler still have some code for "if alarm in use")

      Attachments

        Activity

          danblack, please review.

          wlad Vladislav Vaintroub added a comment - danblack , please review.
          danblack Daniel Black added a comment -

          Done. So sorry for delay.

          danblack Daniel Black added a comment - Done. So sorry for delay.

          I am looking at the code in 10.6 and 10.11 and thr_alarm is still actively used.

          As far as I can see thr_alarm allows us to know more exactly why connections are going down, in which case we should add it back.

          monty Michael Widenius added a comment - I am looking at the code in 10.6 and 10.11 and thr_alarm is still actively used. As far as I can see thr_alarm allows us to know more exactly why connections are going down, in which case we should add it back.
          wlad Vladislav Vaintroub added a comment - - edited

          No, not so much actively used .

          #define NO_ALARM 1

          is in my_config.h everywhere since ever (on Solaris "ever" is since 679b8dc18b20 , elsewhere much longer)
          The socket timeouts are handled in vio since 5.5 , or maybe even 5.1

          So , thr_alarm had been actively unused since an eternity, and made net_serv.cc unreadable. if you need socket errors, vio errors are there. If there was a timeout in a poll in vio_io_wait (this is the function that handles timeout, not built on thr_alarms), this needs to be recognized on the upper level, and maybe recorded somewhere.

          vio_io_wait does not always handle all network timeouts. For wait_timeout expiration and for threadpool there is a handle_wait_timeout() function , that sets ER_NET_READ_INTERRUPTED, and net.error=2.

          wlad Vladislav Vaintroub added a comment - - edited No, not so much actively used . #define NO_ALARM 1 is in my_config.h everywhere since ever (on Solaris "ever" is since 679b8dc18b20 , elsewhere much longer) The socket timeouts are handled in vio since 5.5 , or maybe even 5.1 So , thr_alarm had been actively unused since an eternity, and made net_serv.cc unreadable. if you need socket errors, vio errors are there. If there was a timeout in a poll in vio_io_wait (this is the function that handles timeout, not built on thr_alarms), this needs to be recognized on the upper level, and maybe recorded somewhere. vio_io_wait does not always handle all network timeouts. For wait_timeout expiration and for threadpool there is a handle_wait_timeout() function , that sets ER_NET_READ_INTERRUPTED, and net.error=2.

          I also checked in 10.5:
          cmake ../server -DBUILD_CONFIG=mysql_release
          ((/my/maria-10.5)) nm sql/mysqld | grep thr_alarm
          0000000000fda480 T end_thr_alarm
          0000000000fd9be0 T init_thr_alarm
          000000000232b8c1 B my_disable_thr_alarm
          0000000000fd9d80 T resize_thr_alarm
          0000000000fd9e60 T thr_alarm
          0000000000fda8f0 T thr_alarm_info
          000000000232b8c2 B thr_alarm_inited
          0000000000fda7b0 T thr_alarm_kill

          Which means that it is definitely still used. (Same with 10.6)

          monty Michael Widenius added a comment - I also checked in 10.5: cmake ../server -DBUILD_CONFIG=mysql_release ((/my/maria-10.5)) nm sql/mysqld | grep thr_alarm 0000000000fda480 T end_thr_alarm 0000000000fd9be0 T init_thr_alarm 000000000232b8c1 B my_disable_thr_alarm 0000000000fd9d80 T resize_thr_alarm 0000000000fd9e60 T thr_alarm 0000000000fda8f0 T thr_alarm_info 000000000232b8c2 B thr_alarm_inited 0000000000fda7b0 T thr_alarm_kill Which means that it is definitely still used. (Same with 10.6)
          wlad Vladislav Vaintroub added a comment - - edited

          Which means, that it is still definitely compiled and linked, not used.

          DONT_USE_THR_ALARM is defined when net_serv.cc includes thr_alarm.h, and that means that all those thr_alarm functions become dummy macros. There is one local variable my_bool alarmed=0 is defined, in net_real_read()/net_real_write(), and this local variable checked a couple of times inside thr_alarm_in_use() macro, and that's is it for thr_alarm inside net_serv.cc .

          This had been so on mainstream OSes since at least Dec 2009, back when timeouts in vio were handled using socket options. This had improved since, and poll/select is used for timeouts, since this bug was fixed https://bugs.mysql.com/bug.php?id=54790, and

          Thus thr_alarm served the only purpose of scaring contributors looking into net_real_read or net_read_write, since 2011-12.

          And that for MariaDB only. MySQL , when refactoring network timeout code, in vio, in https://github.com/mysql/mysql-server/commit/dc30732c549b7628b07ff8dbb8d35f0de74a24c9 removed the dummy thr_alarm calls, but we preserved them in merge.

          wlad Vladislav Vaintroub added a comment - - edited Which means, that it is still definitely compiled and linked, not used. DONT_USE_THR_ALARM is defined when net_serv.cc includes thr_alarm.h, and that means that all those thr_alarm functions become dummy macros. There is one local variable my_bool alarmed=0 is defined, in net_real_read()/net_real_write(), and this local variable checked a couple of times inside thr_alarm_in_use() macro, and that's is it for thr_alarm inside net_serv.cc . This had been so on mainstream OSes since at least Dec 2009, back when timeouts in vio were handled using socket options. This had improved since, and poll/select is used for timeouts, since this bug was fixed https://bugs.mysql.com/bug.php?id=54790 , and Thus thr_alarm served the only purpose of scaring contributors looking into net_real_read or net_read_write, since 2011-12. And that for MariaDB only. MySQL , when refactoring network timeout code, in vio, in https://github.com/mysql/mysql-server/commit/dc30732c549b7628b07ff8dbb8d35f0de74a24c9 removed the dummy thr_alarm calls, but we preserved them in merge.
          greenman Ian Gilfillan added a comment -

          Documented that this removed debug_no_thread_alarm. Reminder that user-facing changes need documentation tickets.

          greenman Ian Gilfillan added a comment - Documented that this removed debug_no_thread_alarm. Reminder that user-facing changes need documentation tickets.

          People

            wlad Vladislav Vaintroub
            wlad Vladislav Vaintroub
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.