Skip to content

Commit 86536de

Browse files
authored
Bump mysql to 8.0.31 and 5.7.41, fixes ddev#4619, fixes ddev#4504 (ddev#4644)
1 parent ce8c394 commit 86536de

File tree

6 files changed

+56
-5
lines changed

6 files changed

+56
-5
lines changed

.vscode/launch.json

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@
77
"request": "launch",
88
"mode": "debug",
99
"program": "${workspaceRoot}/cmd/ddev",
10-
"cwd": "${workspaceRoot}/../d9",
10+
"cwd": "${workspaceRoot}/../d9simple",
1111
"env": {"DDEV_DEBUG": "true"},
1212
"args": ["start", "-y"],
1313
"showLog": true
1414
},
15+
{
16+
"name": "ddev snapshot",
17+
"type": "go",
18+
"request": "launch",
19+
"mode": "debug",
20+
"program": "${workspaceRoot}/cmd/ddev",
21+
"cwd": "${workspaceRoot}/../d9simple",
22+
"env": {"DDEV_DEBUG": "true"},
23+
"args": ["snapshot"],
24+
"showLog": true
25+
},
26+
1527
{
1628
"name": "debug ddev describe",
1729
"type": "go",

containers/ddev-dbserver/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ RUN ln -s -f /dev/stderr /var/log/mysqld.err
6060
RUN rm -rf /var/lib/mysql/*
6161
RUN chmod -R ugo+rw /var/lib/mysql /etc/mysql/conf.d /mysqlbase && find /mysqlbase -type d | xargs chmod ugo+rwx
6262

63+
RUN mkdir -p /var/run/mysqld && chmod 777 /var/run/mysqld
64+
6365
RUN /sbin/mkhomedir_helper www-data
6466

6567
# Remove the /etc/apt entry so that if they don't renew the key

containers/ddev-dbserver/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CURRENT_ARCH=$(shell ../get_arch.sh)
1010
# So has to explicitly declare anything it might need from there (like SHELL)
1111
SHELL = /bin/bash
1212

13-
BUILD_TARGETS=mariadb_5.5_amd64 mariadb_10.0_amd64 mariadb_10.1_both mariadb_10.2_both mariadb_10.3_both mariadb_10.4_both mariadb_10.5_both mariadb_10.6_both mariadb_10.7_both mariadb_10.8_both mysql_5.5_amd64 mysql_5.6_amd64 mysql_5.7_both mysql_8.0_both_8.0.26
13+
BUILD_TARGETS=mariadb_5.5_amd64 mariadb_10.0_amd64 mariadb_10.1_both mariadb_10.2_both mariadb_10.3_both mariadb_10.4_both mariadb_10.5_both mariadb_10.6_both mariadb_10.7_both mariadb_10.8_both mysql_5.5_amd64 mysql_5.6_amd64 mysql_5.7_both mysql_8.0_both_8.0.31
1414
TEST_TARGETS=$(shell if [ "$(CURRENT_ARCH)" = "amd64" ] ; then \
1515
echo "mariadb_5.5_test mariadb_10.0_test mariadb_10.1_test mariadb_10.2_test mariadb_10.3_test mariadb_10.4_test mariadb_10.5_test mariadb_10.6_test mariadb_10.7_test mariadb_10.8_test mysql_5.5_test mysql_5.6_test mysql_5.7_test mysql_8.0_test"; \
1616
else \
@@ -37,13 +37,13 @@ mysql_5.7: mysql_5.7_both
3737

3838
# Mysql 8.0 often must be pinned because xtrabackup is not ready for latest 8.0
3939
# So check whether xtrabackup is available for latest 8.0 before changing pin
40-
mysql_8.0: mysql_8.0_both_8.0.26
40+
mysql_8.0: mysql_8.0_both_8.0.31
4141

4242

4343
# Examples:
4444
# make <dbtype>_<dbmajor>_[both|amd64]_<pin> # pin is optional, often needed for mysql 8.0
4545
# make mariadb_10.3_both VERSION=someversion PUSH=true
46-
# make mysql_8.0_amd64_8.0.26 VERSION=someversion
46+
# make mysql_8.0_amd64_8.0.31 VERSION=someversion
4747
$(BUILD_TARGETS):
4848
@echo "building $@";
4949
export DB_TYPE=$(word 1, $(subst _, ,$@)) && \

pkg/ddevapp/app_compose_template.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ services:
1212
uid: '{{ .UID }}'
1313
gid: {{ if ne .DBType "postgres" }} {{ .GID }} {{ else }} "999" {{ end }}
1414
image: ${DDEV_DBIMAGE}-${DDEV_SITENAME}-built
15+
cap_add:
16+
- SYS_NICE
1517
stop_grace_period: 60s
1618
working_dir: "{{ .DBWorkingDir }}"
1719
volumes:

pkg/ddevapp/ddevapp.go

+35
Original file line numberDiff line numberDiff line change
@@ -2106,6 +2106,41 @@ func (app *DdevApp) Snapshot(snapshotName string) (string, error) {
21062106
return "", fmt.Errorf("unable to snapshot database, \nyour db container in project %v is not running. \nPlease start the project if you want to snapshot it. \nIf deleting project, you can delete without a snapshot using \n'ddev delete --omit-snapshot --yes', \nwhich will destroy your database", app.Name)
21072107
}
21082108

2109+
// For versions less than 8.0.32, we have to OPTIMIZE TABLES to make xtrabackup work
2110+
// See https://docs.percona.com/percona-xtrabackup/8.0/em/instant.html and
2111+
// https://www.percona.com/blog/percona-xtrabackup-8-0-29-and-instant-add-drop-columns/
2112+
if app.Database.Type == "mysql" && app.Database.Version == nodeps.MySQL80 {
2113+
stdout, stderr, err := app.Exec(&ExecOpts{
2114+
Service: "db",
2115+
Cmd: `set -eu -o pipefail; MYSQL_PWD=root mysql -e 'SET SQL_NOTES=0'; mysql -N -uroot -e 'SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE TOTAL_ROW_VERSIONS > 0;'`,
2116+
})
2117+
if err != nil {
2118+
util.Warning("could not check for tables to optimize (mysql 8.0): %v (stdout='%s', stderr='%s')", err, stdout, stderr)
2119+
} else {
2120+
stdout = strings.Trim(stdout, "\n\t ")
2121+
tables := strings.Split(stdout, "\n")
2122+
// util.Success("tables=%v len(tables)=%d stdout was '%s'", tables, len(tables), stdout)
2123+
if len(stdout) > 0 && len(tables) > 0 {
2124+
for _, t := range tables {
2125+
r := strings.Split(t, `/`)
2126+
if len(r) != 2 {
2127+
util.Warning("unable to get database/table from %s", r)
2128+
continue
2129+
}
2130+
d := r[0]
2131+
t := r[1]
2132+
stdout, stderr, err := app.Exec(&ExecOpts{
2133+
Service: "db",
2134+
Cmd: fmt.Sprintf(`set -eu -o pipefail; MYSQL_PWD=root mysql -uroot -D %s -e 'OPTIMIZE TABLES %s';`, d, t),
2135+
})
2136+
if err != nil {
2137+
util.Warning("unable to optimize table %s (mysql 8.0): %v (stdout='%s', stderr='%s')", t, err, stdout, stderr)
2138+
}
2139+
}
2140+
util.Success("Optimized mysql 8.0 tables '%s' in preparation for snapshot", strings.Join(tables, `,'`))
2141+
}
2142+
}
2143+
}
21092144
util.Success("Creating database snapshot %s", snapshotName)
21102145

21112146
c := getBackupCommand(app, path.Join(containerSnapshotDir, snapshotFile))

pkg/versionconstants/versionconstants.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var WebTag = "20230207_fix_nvm" // Note that this can be overridden by make
2323
var DBImg = "drud/ddev-dbserver"
2424

2525
// BaseDBTag is the main tag, DBTag is constructed from it
26-
var BaseDBTag = "v1.21.4"
26+
var BaseDBTag = "v1.21.5"
2727

2828
// DBAImg defines the default phpmyadmin image tag used for applications.
2929
var DBAImg = "phpmyadmin"

0 commit comments

Comments
 (0)