quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

can't create mysql trigger in dev container #20654

Closed Dieken closed 2 years ago

Dieken commented 3 years ago

Describe the bug

If I put CREATE TRIGGER ... in my Flyway migration sql, quarkus dev will complain:

2021-10-10 21:22:19,770 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.sql.SQLException: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

According to https://www.testcontainers.org/modules/databases/mysql/, I set these properties but they don't work:

%dev.quarkus.datasource.devservices.properties.TC_MY_CNF=testcontainers/mysql_conf
%test.quarkus.datasource.devservices.properties.TC_MY_CNF=testcontainers/mysql_conf
$ cat src/main/resources/testcontainers/mysql_conf/extra.cnf 
[mysqld]
log_bin_trust_function_creators=ON

Expected behavior

The extra.cnf should be mounted into mysql container.

Actual behavior

The extra.cnf isn't mounted into mysql container.

How to Reproduce?

Put some CREATE TRIGGER ... in src/main/resources/db/migration/V1.0.0__init.sql, run quarkus dev to make it create mysql container automatically.

Output of uname -a or ver

Darwin XXX.local 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64

Output of java -version

OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

Client Version 2.3.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

quarkus dev

Additional information

No response

Dieken commented 2 years ago

Quarkus uses jdbc:mysql://localhost:PORT instead of jdbc:tc:mysql:VERSION://hostname/, I guess this is why TC_MY_CNF doesn't work: https://www.testcontainers.org/modules/databases/mysql/

gsmet commented 2 years ago

We cannot use that because we don't want to use the org.testcontainers.jdbc.ContainerDatabaseDriver to start the containers. I'm working on a PR that should make it work. I'll post here in a few.

gsmet commented 2 years ago

@Dieken sorry for the delay but could you check if https://github.com/quarkusio/quarkus/pull/22648 make it work for you?

There are instructions here on how to build our main, you can follow them, just use the code from my branch instead: https://github.com/quarkusio/quarkus/blob/main/CONTRIBUTING.md#building-main

Dieken commented 2 years ago

@Dieken sorry for the delay but could you check if #22648 make it work for you?

There are instructions here on how to build our main, you can follow them, just use the code from my branch instead: https://github.com/quarkusio/quarkus/blob/main/CONTRIBUTING.md#building-main

@gsmet, Verified it works for me, thank you very much!

gsmet commented 2 years ago

@Dieken thanks for taking the time to check. It's going to be part of the upcoming 2.7 release.