-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VirtioFS causing inconsistent MySQL and MariaDB case-sensitivity glitches #6820
Comments
The integration test for database servers using lower_case_table_names=2 relies on using a MacOS directory bind-mounted to /var/lib/mysql. If Docker Desktop for Mac is using VirtioFS (instead of gRPC FUSE), the containerized database server will exhibit buggy behavior with lower_case_table_names=2 when schema names contain any uppercase characters. This happens on all supported database flavors except for MySQL 8. So far, the only known workaround is to reconfigure Docker for Mac to use gRPC FUSE instead of VirtioFS. This commit simply adjusts the LCTN=2 test logic to fail earlier and display an informative message in this situation. We've filed a bug report with Docker concerning the VirtioFS issue; see docker/for-mac#6820
@evanelias, thanks for the test case! |
On the host, it's a normal case-insensitive APFS filesystem. With gRPC FUSE, a case-insensitive APFS filesystem directory can be bind-mounted as MySQL's data directory, and everything works perfectly even though the container is Linux and otherwise case-sensitive. This is a fairly common way to run MySQL or MariaDB on Macs for dev and local testing. MySQL auto-detects the scenario of a case-insensitive Mac data directory, and automatically enables its lower_case_table_names=2 compatibility setting. It's only with VirtioFS that this starts causing random errors. With the test case I provided, the However, executing five Thanks! |
I apparently typo'ed github.com in the link in my previous reply, please don't click the original link as it is a domain squatter. My apologies, I've edited to be the correct link now. |
This still seems to be an issue (Mac M1, Sonoma 14.4.1, Docker Desktop 4.29.0, engine 26.0.0, compose 2.26.1-desktop.1) except switching away from VirtioFS no longer helps (if Creating a database with upper case letters in the name (
Also, dropping database Importing a table with upper case letters (from a mysqldump) results in (but again, not always on the first table with upper case in its name, sometimes it manages to create 5 tables, sometimes 20):
The only workarounds are to use MySQL 8 or set |
I've just encountered the same issue. Docker Desktop: 4.34.0 (165256) Exact issue: I have a database with uppercase letters in the name. When I try to execute SQL statement The actual database is stored on my drive as Switching to |
Expected behavior
Bind-mounting a directory to /var/lib/mysql should result in a fully-functional database
Actual behavior
If VirtioFS is enabled, and the database server container uses a bind mount for its data directory, random errors will result if any database (schema) name contains at least one uppercase character.
In this situation, the db server sometimes randomly/inconsistently returns filesystem-related errors for SQL statements that should not return an error: for example,
SHOW TABLES
may return "Unknown database", or a perfectly validCREATE TABLE
may return "File not found (Errcode: 2 - No such file or directory)". In both cases, the error message references a lowercased version of the mixed-case database name.Information
The problem only happens when using VirtioFS. This might be related to #6243, but I didn't see anything in there specifically about case-sensitivity / case-insensitivity oddities, so I am not certain.
I can reproduce this with the official images for MySQL 5.5, 5.6, and 5.7 from https://hub.docker.com/_/mysql . Likewise for all modern versions of MariaDB from https://hub.docker.com/_/mariadb . It does not seem to be reproducible with MySQL 8 though, perhaps because MySQL 8 completely replaced the data dictionary implementation used in prior versions.
Creating several tables very rapidly will increase the chance of reproduction, but it's still very random and inconsistent.
It's probably somehow related to lower_case_table_names=2, which is the mode automatically enabled when /var/lib/mysql is a case-insensitive MacOS directory, but that mode normally does not cause these inconsistent/random errors. I have been using MySQL for 20 years in a wide range of environments (including Facebook's db team), and have deep experience with lower_case_table_names (see my blog post here), and have not encountered this specific glitchy behavior before.
For background: in MySQL, each database (schema) is stored in a separate directory, and using lower_case_table_names=2 is likely forcing some of the directory path lookups to all-lowercase; but for some reason, with VirtioFS, there's inconsistent behavior as to whether the downcased version of a directory name works properly.
Output of
/Applications/Docker.app/Contents/MacOS/com.docker.diagnose check
Steps to reproduce the behavior
In one terminal tab, create a new directory that will be used for the bind mount, and start a MySQL 5.7 container:
Once the server has finished initializing, run the MySQL client in another terminal tab. Create a mixed-case database name, USE the database, and then run various statements. In this case, some of the SHOW TABLES generated an error, as did one of the CREATE TABLE statements; but it's somewhat random between runs.
The text was updated successfully, but these errors were encountered: