nkonev / r2dbc-migrate

R2DBC database migration library
https://nkonev.name/post/136
Apache License 2.0
98 stars 9 forks source link

R2dbc-migrate fails after upgrading spring boot from 2.6.6 to 2.7.0 #17

Closed RamonVerbruggen closed 2 years ago

RamonVerbruggen commented 2 years ago

Disclaimer: I am not 100% certain this is caused by r2dbc-migrate, but I think the spring boot upgrade to 2.7.0 broke some functionality that r2dbc-migrate was using.

With spring boot 2.6.6 and r2dbc-migrate 1.8.5 I can successfully migrate H2 and MariaDB databases.

With spring boot 2.7.0 and r2dbc-migrate 1.8.5 I get the following:

2022-05-23 14:34:44,884 INFO  [main] name.nkonev.r2dbc.migrate.autoconfigure.R2dbcMigrateAutoConfiguration$R2dbcMigrateBlockingInvoker: Starting R2DBC migration
2022-05-23 14:34:44,886 INFO  [main] reactor.util.Loggers$Slf4JLogger: Configured with R2dbcMigrateProperties{enable=true, connectionMaxRetries=500, resourcesPaths=[classpath:/db/migration/*.sql], chunkSize=1000, dialect=null, validationQuery='select '42' as result', validationQueryExpectedResultValue='42', validationQueryTimeout=PT5S, validationRetryDelay=PT1S, acquireLockRetryDelay=PT1S, acquireLockMaxRetries=100, fileCharset=UTF-8, waitForDatabase=true, migrationsSchema='null', migrationsTable='migrations', migrationsLockTable='migrations_lock'}
2022-05-23 14:34:44,932 INFO  [main] reactor.util.Loggers$Slf4JLogger: Creating new test connection
2022-05-23 14:34:45,266 INFO  [reactor-tcp-epoll-2] reactor.util.Loggers$Slf4JLogger: Comparing expected value '42' with provided result '42'
2022-05-23 14:34:45,268 INFO  [reactor-tcp-epoll-2] reactor.util.Loggers$Slf4JLogger: Closing test connection
2022-05-23 14:34:45,279 INFO  [reactor-tcp-epoll-2] reactor.util.Loggers$Slf4JLogger: Successfully got result '42' of test query
2022-05-23 14:34:45,317 INFO  [reactor-tcp-epoll-2] reactor.util.Loggers$Slf4JLogger: By 'Making internal tables' 0 rows updated
2022-05-23 14:34:45,319 INFO  [reactor-tcp-epoll-2] reactor.util.Loggers$Slf4JLogger: By 'Acquiring lock' 1 rows updated
2022-05-23 14:34:45,331 ERROR [reactor-tcp-epoll-2] reactor.util.Loggers$Slf4JLogger: Got error during migration, will release lock
io.netty.util.IllegalReferenceCountException: refCnt: 0
    at io.netty.buffer.AbstractByteBuf.ensureAccessible(AbstractByteBuf.java:1454)
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1440)
    at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:730)
    at io.netty.buffer.AbstractByteBuf.readUnsignedByte(AbstractByteBuf.java:744)
    at org.mariadb.r2dbc.codec.TextRowDecoder.setPosition(TextRowDecoder.java:78)
    at org.mariadb.r2dbc.codec.TextRowDecoder.get(TextRowDecoder.java:19)
    at org.mariadb.r2dbc.MariadbReadable.get(MariadbReadable.java:33)
    at org.mariadb.r2dbc.MariadbReadable.get(MariadbReadable.java:70)
    at name.nkonev.r2dbc.migrate.core.R2dbcMigrate.lambda$getResultSafely$25(R2dbcMigrate.java:294)
    at org.mariadb.r2dbc.MariadbResult.lambda$map$1(MariadbResult.java:121)

...after which application startup fails.

Could this be related to r2dbc-migrate?

RamonVerbruggen commented 2 years ago

Forgot to mention that I get the above error when trying to migrate a MariaDB database, H2 seems to work as expected!

RamonVerbruggen commented 2 years ago

Sorry for the inconvenience, this turned out to be a problem with the mariadb r2dbc driver 1.1.1-rc which is included in spring boot 2.7.0