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

MariaDB: clean fails when event scheduler is disabled #2410

Closed
Dazzel opened this issue Jun 7, 2019 · 5 comments

Comments

@Dazzel
Copy link

commented Jun 7, 2019

Which version and edition of Flyway are you using?

5.2.4 and 6.0.0-beta2

If this is not the latest version, can you reproduce the issue with the latest one as well?

Nope, see versions above

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

CLI and Java API

Which database are you using (type & version)?

Mariadb 10.3

Which operating system are you using?

macOS 10.14.5

What did you do?

Simply ran an empty migration, then this error pops up. Database URL is jdbc:mariadb://localhost:3306/SCHEMA_NAME. With jdbc:mysql the same error occurs.

While running 'validate' or 'info' no error occurs.

What did you expect to see?

No error, just an information how many (in this case 0) migration where run.

What did you see instead?

The stacktrace from the Java API:

Exception in thread "main" org.flywaydb.core.internal.exception.FlywaySqlException: 
Unable to check whether schema `SCHEMA_NAME` is empty
----------------------------------------------------------
SQL State  : HY000
Error Code : 1577
Message    : (conn=29) Cannot proceed, because event scheduler is disabled

	at org.flywaydb.core.internal.database.base.Schema.empty(Schema.java:100)
	at org.flywaydb.core.Flyway$1.execute(Flyway.java:158)
	at org.flywaydb.core.Flyway$1.execute(Flyway.java:142)
	at org.flywaydb.core.Flyway.execute(Flyway.java:504)
	at org.flywaydb.core.Flyway.migrate(Flyway.java:142)
	at MyMigrateTest.main(MyMigrateTest.java:8)
Caused by: java.sql.SQLException: (conn=29) Cannot proceed, because event scheduler is disabled
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:261)
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:171)
	at org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:238)
	at org.mariadb.jdbc.ClientSidePreparedStatement.executeInternal(ClientSidePreparedStatement.java:230)
	at org.mariadb.jdbc.ClientSidePreparedStatement.execute(ClientSidePreparedStatement.java:157)
	at org.mariadb.jdbc.ClientSidePreparedStatement.executeQuery(ClientSidePreparedStatement.java:172)
	at org.flywaydb.core.internal.jdbc.JdbcTemplate.queryForInt(JdbcTemplate.java:148)
	at org.flywaydb.core.internal.database.mysql.MySQLSchema.doEmpty(MySQLSchema.java:49)
	at org.flywaydb.core.internal.database.base.Schema.empty(Schema.java:98)
	... 5 more
Caused by: java.sql.SQLException: Cannot proceed, because event scheduler is disabled
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:261)
	at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.readNextValue(SelectResultSet.java:440)
	at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.fetchAllResults(SelectResultSet.java:348)
	at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.<init>(SelectResultSet.java:205)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readResultSet(AbstractQueryProtocol.java:1721)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1466)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1415)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:288)
	at org.mariadb.jdbc.ClientSidePreparedStatement.executeInternal(ClientSidePreparedStatement.java:221)
	... 10 more

The issue is the fourth select statement which queries the information_schema.events table. But when the event scheduler is disabled, MariaDB fails with given error message.
The query: SELECT 1 as found FROM information_schema.events WHERE event_schema=? LIMIT 1

@axelfontaine axelfontaine changed the title MySQLSchema doEmpty() call fails on disabled event scheduler MariaDB: clean fails when event scheduler is disabled Jun 8, 2019

axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue Jun 8, 2019

@axelfontaine axelfontaine added this to the Flyway 6.0.0 milestone Jun 8, 2019

@axelfontaine

This comment has been minimized.

Copy link
Member

commented Jun 8, 2019

Thank you very much for the detailed report and investigation. Fascinating! It appears this undocumented difference in behavior between MariaDB and MySQL was introduced in MariaDB 10.0. Only MariaDB 10.0 and newer have this issue. It is not present in any version of MySQL, nor in MariaDB 5.5. Fixed.

@Dazzel

This comment has been minimized.

Copy link
Author

commented Jun 10, 2019

Thank you for your fast reply and fix!

But I am not sure if the fix works on every installation. The query SELECT @@event_scheduler returns the value OFF and not DISABLED on my installation.

@axelfontaine

This comment has been minimized.

Copy link
Member

commented Jun 10, 2019

@Dazzel I couldn't reproduce the error with OFF. Only DISABLED prevents the table from being queried.

@Dazzel

This comment has been minimized.

Copy link
Author

commented Jun 10, 2019

@axelfontaine Okay. This is strange. I get the same error when the database reports OFF.

Maybe an configuration difference? Installed mariadb vie Homebrew.

axelfontaine pushed a commit that referenced this issue Jun 10, 2019
@axelfontaine

This comment has been minimized.

Copy link
Member

commented Jun 10, 2019

OK, generalized the check to be on the safe side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.