craftcms / nitro

Speedy local dev environment for @craftcms.
https://getnitro.sh
MIT License
178 stars 24 forks source link

MySQL 5.6 and 8.0 often won't run simultaneously #446

Closed proimage closed 2 years ago

proimage commented 2 years ago

Description

I've got Nitro set up with a number of different database versions, to match the versions in use on the production sites. I initially set it up with MySQL 5.6 and 8.0. I later added 5.7, but the problem I'm encountering was happening before adding 5.7, and indeed, 5.7 so far seems unaffected.

Initially (after first start), both the 5.6 and 8.0 database containers seem to run fine. But after a "while" (first use? not sure), they'll only run exclusively of each other. If I start one, the other one... stops. Starting the stopped one makes the other DB stop.

I'm not sure where to look to find an error log that would show what the problem is here.

Steps to reproduce

  1. Run MySQL 5.6 and 8.0 simultaneously
  2. Somehow have the problem happen?

Additional info

Windows Subsystem for Linux was last updated on Tue, 2021-10-12 WSL automatic updates are on. Windows updates are paused.

Kernel version: 5.10.60.1 Wed, 2022-01-19 14:49:46

- Nitro version:

Nitro CLI: 2.0.8 Nitro gRPC: 2.0.8 Docker API: 1.41 (1.12 min) Docker CLI: 1.41

- Docker version:

Client: Docker Engine - Community Cloud integration: v1.0.22 Version: 20.10.11 API version: 1.41 Go version: go1.16.9 Git commit: dea9396 Built: Thu Nov 18 00:37:33 2021 OS/Arch: linux/amd64 Context: default Experimental: true

Server: Docker Engine - Community Engine: Version: 20.10.11 API version: 1.41 (minimum version 1.12) Go version: go1.16.9 Git commit: 847da18 Built: Thu Nov 18 00:35:39 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.12 GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d runc: Version: 1.0.2 GitCommit: v1.0.2-0-g52b36a2 docker-init: Version: 0.19.0 GitCommit: de40ad0

proimage commented 2 years ago

Update: I removed the MySQL 5.6 container. The one site that I thought needed it is, I'm told by the sysadmin, in fact on MySQL 8.0, despite Craft reporting 5.6.47.0: image Not sure what's going on there, but in any case, I'm now trying to import the DB into the 8.0 container, but the container exits the moment I run nitro db import /path/to/file.sql.

What do I do?

jasonmccallister commented 2 years ago

@proimage what system resources are setup for your Docker Desktop (RAM and CPU). Often the MySQL containers will stop when the resources are low. If you can provide the output of the container (using docker logs <container-name>) that would also be helpful to debug the issue.

proimage commented 2 years ago

Docker Desktop's Settings -> Resources: image

Contents of my .wslconfig file:

[wsl2]
memory=5GB
swap=0

The docker logs command resulted in 514Kb of logs. Should I just post it here, or does it contain sensitive information and should be emailed?

angrybrad commented 2 years ago

@proimage from: https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig

memory defaults to:

50% of total memory on Windows or 8GB, whichever is less

I'd consider 8GB a bare minimum for WSL/Docker.

and swap:

25% of memory size on Windows rounded up to the nearest GB

Setting this to 0 effectively disables swap, so everything will be done in memory (which is limited to 5GB in your setup).

Try removing those settings from your wslconfig and go with the defaults. If that doesn't help and you've got memory and disk space to spare, try allocating more than the defaults.

proimage commented 2 years ago

Try removing those settings from your wslconfig and go with the defaults. If that doesn't help and you've got memory and disk space to spare, try allocating more than the defaults.

That seems to have done the trick! Thank youuu!! 😄