From 3fdce2d984af1692524cfe122ba51edf88962216 Mon Sep 17 00:00:00 2001 From: Gavin Morris Date: Thu, 26 Oct 2023 17:35:05 -0400 Subject: [PATCH 1/9] Mariadb max_packet_allowed - Draft --- mariadb/rootfs/etc/confd/conf.d/mariadb-server.toml | 7 +++++++ .../templates/mariadb-server.tmpl} | 3 ++- mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 mariadb/rootfs/etc/confd/conf.d/mariadb-server.toml rename mariadb/rootfs/etc/{my.cnf.d/mariadb-server.cnf => confd/templates/mariadb-server.tmpl} (89%) create mode 100755 mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh diff --git a/mariadb/rootfs/etc/confd/conf.d/mariadb-server.toml b/mariadb/rootfs/etc/confd/conf.d/mariadb-server.toml new file mode 100644 index 00000000..961baec4 --- /dev/null +++ b/mariadb/rootfs/etc/confd/conf.d/mariadb-server.toml @@ -0,0 +1,7 @@ +[template] +src = "mariadb-server.tmpl" +dest = "/etc/my.cnf.d/mariadb-server.cnf" +uid = 100 +gid = 1000 +mode = "0664" +keys = [ "/" ] diff --git a/mariadb/rootfs/etc/my.cnf.d/mariadb-server.cnf b/mariadb/rootfs/etc/confd/templates/mariadb-server.tmpl similarity index 89% rename from mariadb/rootfs/etc/my.cnf.d/mariadb-server.cnf rename to mariadb/rootfs/etc/confd/templates/mariadb-server.tmpl index 77569381..83e99335 100644 --- a/mariadb/rootfs/etc/my.cnf.d/mariadb-server.cnf +++ b/mariadb/rootfs/etc/confd/templates/mariadb-server.tmpl @@ -8,7 +8,8 @@ # this is only for the mysqld standalone daemon [mysqld] # skip-networking - +# Allow for max_allowed_packet to be set in the project .env +max_allowed_packet ={{ getenv "DB_MAX_ALLOWED_PACKET" }} # Galera-related settings [galera] # Mandatory settings diff --git a/mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh b/mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh new file mode 100755 index 00000000..961b8a95 --- /dev/null +++ b/mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh @@ -0,0 +1,8 @@ +#!/command/with-contenv bash +# shellcheck shell=bash +set -e + +# Use what has been provided by the user or default to the derived values. +cat < Date: Fri, 27 Oct 2023 11:40:50 -0400 Subject: [PATCH 2/9] Draft 2 - max_packet_now has default env but still NOT dynamic. Confd env values ignored --- mariadb/Dockerfile | 2 ++ .../etc/s6-overlay/s6-rc.d/set-max-packet/dependencies.d/ready | 0 mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/type | 1 + mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/up | 1 + mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/dependencies.d/ready create mode 100644 mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/type create mode 100755 mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/up diff --git a/mariadb/Dockerfile b/mariadb/Dockerfile index 7b670c2b..8fa9a79d 100644 --- a/mariadb/Dockerfile +++ b/mariadb/Dockerfile @@ -23,5 +23,7 @@ RUN --mount=type=cache,id=mariadb-apk-${TARGETARCH},sharing=locked,target=/var/c # base image. Set to 10 minutes just incase it ran on very old or overallocated # hardware. ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=600000 +# Default value of 256 MB in bytes +ENV DB_MAX_ALLOWED_PACKET=268435456 COPY --link rootfs / diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/dependencies.d/ready b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/dependencies.d/ready new file mode 100644 index 00000000..e69de29b diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/type b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/type @@ -0,0 +1 @@ +oneshot diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/up b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/up new file mode 100755 index 00000000..11e54fa8 --- /dev/null +++ b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/up @@ -0,0 +1 @@ +/etc/s6-overlay/scripts/set-max-packet.sh diff --git a/mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh b/mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh index 961b8a95..86c30b49 100755 --- a/mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh +++ b/mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh @@ -2,7 +2,7 @@ # shellcheck shell=bash set -e -# Use what has been provided by the user or default to the derived values. +# Use what has been provided by the user or default value of 256M cat < Date: Mon, 30 Oct 2023 13:18:48 -0400 Subject: [PATCH 3/9] Variable rename and README update per Comment 1 --- mariadb/Dockerfile | 4 ++-- mariadb/README.md | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mariadb/Dockerfile b/mariadb/Dockerfile index 8fa9a79d..6b534651 100644 --- a/mariadb/Dockerfile +++ b/mariadb/Dockerfile @@ -23,7 +23,7 @@ RUN --mount=type=cache,id=mariadb-apk-${TARGETARCH},sharing=locked,target=/var/c # base image. Set to 10 minutes just incase it ran on very old or overallocated # hardware. ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=600000 -# Default value of 256 MB in bytes -ENV DB_MAX_ALLOWED_PACKET=268435456 +# Default Mariadb value of 16 MB (bytes) +ENV MYSQL_MAX_ALLOWED_PACKET=16777216 COPY --link rootfs / diff --git a/mariadb/README.md b/mariadb/README.md index 1937280e..a659a605 100644 --- a/mariadb/README.md +++ b/mariadb/README.md @@ -41,6 +41,7 @@ default database connection configuration. | :------------------- | :------ | :------------------------------------------------------------------------------------ | | MYSQL_ROOT_PASSWORD | | The database root user password. Defaults to `DB_ROOT_PASSWORD` | | MYSQL_ROOT_USER | | The database root user (used to create the site database). Defaults to `DB_ROOT_USER` | +| MYSQL_MAX_ALLOWED_PACKET | 16777216 | Max packet length to send to or receive from the server, [documentation](https://mariadb.com/docs/server/ref/mdb/system-variables/max_allowed_packet/) | ## Logs From 84177c6e5f896e80b4e7cb5052e0143ccb0e3ad9 Mon Sep 17 00:00:00 2001 From: Gavin Morris Date: Mon, 30 Oct 2023 16:18:41 -0400 Subject: [PATCH 4/9] Renamed confd cnf files with correct uid settings --- .../conf.d/{mariadb-server.toml => mariadb-server.cnf.toml} | 6 +++--- .../{mariadb-server.tmpl => mariadb-server.cnf.tmpl} | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename mariadb/rootfs/etc/confd/conf.d/{mariadb-server.toml => mariadb-server.cnf.toml} (73%) rename mariadb/rootfs/etc/confd/templates/{mariadb-server.tmpl => mariadb-server.cnf.tmpl} (94%) diff --git a/mariadb/rootfs/etc/confd/conf.d/mariadb-server.toml b/mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml similarity index 73% rename from mariadb/rootfs/etc/confd/conf.d/mariadb-server.toml rename to mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml index 961baec4..1b6af546 100644 --- a/mariadb/rootfs/etc/confd/conf.d/mariadb-server.toml +++ b/mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml @@ -1,7 +1,7 @@ [template] src = "mariadb-server.tmpl" dest = "/etc/my.cnf.d/mariadb-server.cnf" -uid = 100 -gid = 1000 -mode = "0664" +uid = 0 +gid = 0 +mode = 0664 keys = [ "/" ] diff --git a/mariadb/rootfs/etc/confd/templates/mariadb-server.tmpl b/mariadb/rootfs/etc/confd/templates/mariadb-server.cnf.tmpl similarity index 94% rename from mariadb/rootfs/etc/confd/templates/mariadb-server.tmpl rename to mariadb/rootfs/etc/confd/templates/mariadb-server.cnf.tmpl index 83e99335..b775943d 100644 --- a/mariadb/rootfs/etc/confd/templates/mariadb-server.tmpl +++ b/mariadb/rootfs/etc/confd/templates/mariadb-server.cnf.tmpl @@ -9,7 +9,7 @@ [mysqld] # skip-networking # Allow for max_allowed_packet to be set in the project .env -max_allowed_packet ={{ getenv "DB_MAX_ALLOWED_PACKET" }} +max_allowed_packet ={{ getenv "MYSQL_MAX_ALLOWED_PACKET" }} # Galera-related settings [galera] # Mandatory settings From e651ccbb99d669443712a280f2d8573b861b2ce5 Mon Sep 17 00:00:00 2001 From: Gavin Morris Date: Mon, 30 Oct 2023 16:20:14 -0400 Subject: [PATCH 5/9] Remove errant comment --- mariadb/rootfs/etc/confd/templates/mariadb-server.cnf.tmpl | 1 - 1 file changed, 1 deletion(-) diff --git a/mariadb/rootfs/etc/confd/templates/mariadb-server.cnf.tmpl b/mariadb/rootfs/etc/confd/templates/mariadb-server.cnf.tmpl index b775943d..75b10f93 100644 --- a/mariadb/rootfs/etc/confd/templates/mariadb-server.cnf.tmpl +++ b/mariadb/rootfs/etc/confd/templates/mariadb-server.cnf.tmpl @@ -8,7 +8,6 @@ # this is only for the mysqld standalone daemon [mysqld] # skip-networking -# Allow for max_allowed_packet to be set in the project .env max_allowed_packet ={{ getenv "MYSQL_MAX_ALLOWED_PACKET" }} # Galera-related settings [galera] From c0d927ffcf5f544f252929f4058b768ebd151a2d Mon Sep 17 00:00:00 2001 From: Gavin Morris Date: Mon, 30 Oct 2023 16:22:40 -0400 Subject: [PATCH 6/9] Remove three unneeded files --- mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/type | 1 - mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/up | 1 - mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh | 8 -------- 3 files changed, 10 deletions(-) delete mode 100644 mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/type delete mode 100755 mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/up delete mode 100755 mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/type b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/type deleted file mode 100644 index bdd22a18..00000000 --- a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/type +++ /dev/null @@ -1 +0,0 @@ -oneshot diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/up b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/up deleted file mode 100755 index 11e54fa8..00000000 --- a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/up +++ /dev/null @@ -1 +0,0 @@ -/etc/s6-overlay/scripts/set-max-packet.sh diff --git a/mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh b/mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh deleted file mode 100755 index 86c30b49..00000000 --- a/mariadb/rootfs/etc/s6-overlay/scripts/set-max-packet.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/command/with-contenv bash -# shellcheck shell=bash -set -e - -# Use what has been provided by the user or default value of 256M -cat < Date: Mon, 30 Oct 2023 16:31:58 -0400 Subject: [PATCH 7/9] Remove extra set-max-packet directories and files --- .../etc/s6-overlay/s6-rc.d/set-max-packet/dependencies.d/ready | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/dependencies.d/ready diff --git a/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/dependencies.d/ready b/mariadb/rootfs/etc/s6-overlay/s6-rc.d/set-max-packet/dependencies.d/ready deleted file mode 100644 index e69de29b..00000000 From 983ffc2eb67f5f3166b83e2510012198574e65fa Mon Sep 17 00:00:00 2001 From: Gavin Morris Date: Mon, 30 Oct 2023 16:41:56 -0400 Subject: [PATCH 8/9] Missing toml value fixed --- mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml b/mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml index 1b6af546..a13b5ffe 100644 --- a/mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml +++ b/mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml @@ -1,5 +1,5 @@ [template] -src = "mariadb-server.tmpl" +src = "mariadb-server.cnf.tmpl" dest = "/etc/my.cnf.d/mariadb-server.cnf" uid = 0 gid = 0 From 22f6437f23b381d9c0f0250c5bf602275a47f2ba Mon Sep 17 00:00:00 2001 From: Gavin Morris Date: Mon, 30 Oct 2023 16:49:03 -0400 Subject: [PATCH 9/9] Quotes for perm values removed by mistake --- mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml b/mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml index a13b5ffe..cd0d3a6a 100644 --- a/mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml +++ b/mariadb/rootfs/etc/confd/conf.d/mariadb-server.cnf.toml @@ -3,5 +3,5 @@ src = "mariadb-server.cnf.tmpl" dest = "/etc/my.cnf.d/mariadb-server.cnf" uid = 0 gid = 0 -mode = 0664 +mode = "0664" keys = [ "/" ]