Details

    • Type: Task
    • Status: In Review
    • Priority: Critical
    • Resolution: Unresolved
    • Fix Version/s: 10.1
    • Component/s: None
    • Labels:
    • Sprint:
      10.1.7-1, 10.1.7-2, 10.1.8-1, 10.1.8-3

      Description

      Supporting socket activation would make each of the following possible for admins:

      • Cleaner restarts (the listener socket stays open persistently)
      • Network namespace isolation, disallowing any network access beyond the inherited listener port (and connections accepted from it).
      • Lazy startup for densely hosted instances. (It's also possible with socket activation to start it eagerly, as usual.)
      • Running MariaDB on privileged ports without having to start it initially as root
      • Non-racy startup for services (like a PHP site) that depend on connecting to MariaDB. Because systemd opens listener sockets early in boot, they're available even while MariaDB is starting
      • Deeper integration into coming network support in future systemd releases

      Some examples in C are here:
      http://0pointer.de/blog/projects/socket-activation.html

      I am willing to sponsor development of this feature.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              danblack Daniel Black added a comment -

              If you have two ListenStream= options, systemd will send in two separate socket file descriptors. Is that handled in the code?

              Actually 3 since the unix socket is a ListenStream too. Up to 10 are handled within the code which is just a #define with non-fatal errors if this is exceeded and written to mysql error log.

              Reminded me the current code has extra_ip_sock(extra-port) has special handling. How important is it to maintain this?

                  if (mysql_socket_getfd(sock) == mysql_socket_getfd(extra_ip_sock))
                  {
                    thd->extra_port= 1;
                    thd->scheduler= extra_thread_scheduler;
                  }
              
              Show
              danblack Daniel Black added a comment - If you have two ListenStream= options, systemd will send in two separate socket file descriptors. Is that handled in the code? Actually 3 since the unix socket is a ListenStream too. Up to 10 are handled within the code which is just a #define with non-fatal errors if this is exceeded and written to mysql error log. Reminded me the current code has extra_ip_sock(extra-port) has special handling. How important is it to maintain this? if (mysql_socket_getfd(sock) == mysql_socket_getfd(extra_ip_sock)) { thd->extra_port= 1; thd->scheduler= extra_thread_scheduler; }
              Hide
              davidstrauss David Strauss added a comment -

              Reminded me the current code has extra_ip_sock(extra-port) has special handling. How important is it to maintain this?

              I've never been a fan of the specialized handling of the IP versus the Unix socket. It would be great to have a generic pool of listeners; I see no downside.

              Show
              davidstrauss David Strauss added a comment - Reminded me the current code has extra_ip_sock(extra-port) has special handling. How important is it to maintain this? I've never been a fan of the specialized handling of the IP versus the Unix socket. It would be great to have a generic pool of listeners; I see no downside.
              Hide
              danblack Daniel Black added a comment -

              More fixes. I dare say this is getting pretty close.

              Using systemd list fds on ip_sock, extra_ip_sock and unix_socket wasn't working as there needed to be a determination of the socket type. As systemd can specify multiple sockets in any order a proper map of socket type to file descriptor was made.

              The performance schema interface was also missing which is now corrected. For the moment I've put a PS event type for systemd_unix, systemd_ipv6, systemd_ipv4 but can probably expand these to include path/host/port/numbers information if desired. Although the code for HAVE_POLL=no is there I couldn't get past MDEV-7473 which stalled on linux even with -DHAVE_SYSTEMD=no -DHAVE_POLL=no but hey, linux always has poll and systemd isn't ported to non-linux so we're safe for now.

              The socket activation part already implements MDEV-6536 IPv6 bind address now because systemd handles the opening of sockets and with a little more config parsing some of these new structures this sets the basis a more extensive listening interface.

              The main missing bit so far, a decent automated test case. Nothing non-root exists in systemd however it shouldn't be too hard to open a few sockets, set some env vars and exec another process.

              Show
              danblack Daniel Black added a comment - More fixes. I dare say this is getting pretty close. Using systemd list fds on ip_sock, extra_ip_sock and unix_socket wasn't working as there needed to be a determination of the socket type. As systemd can specify multiple sockets in any order a proper map of socket type to file descriptor was made. The performance schema interface was also missing which is now corrected. For the moment I've put a PS event type for systemd_unix, systemd_ipv6, systemd_ipv4 but can probably expand these to include path/host/port/numbers information if desired. Although the code for HAVE_POLL=no is there I couldn't get past MDEV-7473 which stalled on linux even with -DHAVE_SYSTEMD=no -DHAVE_POLL=no but hey, linux always has poll and systemd isn't ported to non-linux so we're safe for now. The socket activation part already implements MDEV-6536 IPv6 bind address now because systemd handles the opening of sockets and with a little more config parsing some of these new structures this sets the basis a more extensive listening interface. The main missing bit so far, a decent automated test case. Nothing non-root exists in systemd however it shouldn't be too hard to open a few sockets, set some env vars and exec another process.
              Hide
              danblack Daniel Black added a comment - - edited
              Show
              danblack Daniel Black added a comment - - edited https://github.com/MariaDB/server/pull/26
              Hide
              danblack Daniel Black added a comment -

              Added https://github.com/MariaDB/server/pull/83 to merge to 10.1 incorporating review comments

              Show
              danblack Daniel Black added a comment - Added https://github.com/MariaDB/server/pull/83 to merge to 10.1 incorporating review comments

                People

                • Assignee:
                  svoj Sergey Vojtovich
                  Reporter:
                  davidstrauss David Strauss
                • Votes:
                  14 Vote for this issue
                  Watchers:
                  17 Start watching this issue

                  Dates

                  • Created:
                    Updated:

                    Agile