Skip to content
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

Initialisation script errors aren't logged #1026

Open
DRCG-Matrix opened this issue Feb 4, 2024 · 3 comments
Open

Initialisation script errors aren't logged #1026

DRCG-Matrix opened this issue Feb 4, 2024 · 3 comments

Comments

@DRCG-Matrix
Copy link

I'm not sure if this is intended behaviour but I was running into a problem of not having all my scripts run and wasn't certain why until I tried to execute the sql in the last script it logs that it's initialising and found a bug someone had introduced. Is it not possible for the container to at least show there was an error with the script or better yet log the actual error to track down the error more easily?

@DRCG-Matrix
Copy link
Author

DRCG-Matrix commented Feb 4, 2024

I had no idea and would not have found there was a bug unless I had started digging into scripts and manually attempting to run the statements myself. I then proceeded to do this step by step until all script errors had been corrected using mysql workbench

@tianon
Copy link
Member

tianon commented Feb 5, 2024

I'm not sure I understand what you mean -- I've just tried to reproduce, and was unable to (my invalid SQL immediately prints an error and stops the initialization, as expected):

$ docker run -it --rm --pull=always --env MYSQL_ROOT_PASSWORD=foobar mysql bash -c 'echo "SOME VERY INVALID SQL" > /docker-entrypoint-initdb.d/init.sql && exec docker-entrypoint.sh mysqld'
latest: Pulling from library/mysql
Digest: sha256:d7c20c5ba268c558f4fac62977f8c7125bde0630ff8946b08dde44135ef40df3
Status: Image is up to date for mysql:latest
2024-02-05 18:48:01+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.3.0-1.el8 started.
2024-02-05 18:48:01+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2024-02-05 18:48:01+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.3.0-1.el8 started.
2024-02-05 18:48:02+00:00 [Note] [Entrypoint]: Initializing database files
2024-02-05T18:48:02.135625Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2024-02-05T18:48:02.137301Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.3.0) initializing of server in progress as process 81
2024-02-05T18:48:02.146895Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-02-05T18:48:02.624036Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-02-05T18:48:03.881625Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2024-02-05T18:48:07.629010Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
2024-02-05 18:48:07+00:00 [Note] [Entrypoint]: Database files initialized
2024-02-05 18:48:07+00:00 [Note] [Entrypoint]: Starting temporary server
mysqld will log errors to /var/lib/mysql/96c433dc25b0.err
mysqld is running as pid 127
2024-02-05 18:48:08+00:00 [Note] [Entrypoint]: Temporary server started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.

2024-02-05 18:48:09+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SOME VERY INVALID SQL' at line 1
$ 

Maybe your container has an aggressive restart policy and you're running into effectively docker-library/postgres#159?

@LaurentGoderre
Copy link
Member

@DRCG-Matrix when testing the initialization, do you remove all the volumes? If i don't clear the volumes and I make the initialization fail, it shows the error the first time then hangs the second time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants