quarkusio / quarkus

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

Reactive datasource parse MariaDB version error #36559

Closed red010182 closed 10 months ago

red010182 commented 10 months ago

Describe the bug

@ApplicationScoped
@Path("/hello")
class GreetingResource(@ReactiveDataSource("cool") val db: MySQLPool) {
    @GET
    suspend fun hello(): List<Int> {
        return db.query("SELECT 1").execute().awaitSuspending().map { it.getInteger("1") }
    }
}

Accessing mariadb datasource with MySQLPool shows warning: parse database version error. (However, it has no problem when connecting to mysql datasource)

Expected behavior

access datasource without error or warning.

Actual behavior

2023-10-18 22:54:39,310 WARN  [io.ver.mys.imp.MySQLDatabaseMetadata] (vert.x-eventloop-thread-2) Incorrect parsing server version tokens: java.lang.NumberFormatException: For input string: ""
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
        at java.base/java.lang.Integer.parseInt(Integer.java:675)
        at java.base/java.lang.Integer.parseInt(Integer.java:781)
        at io.vertx.mysqlclient.impl.MySQLDatabaseMetadata.parse(MySQLDatabaseMetadata.java:57)
        at io.vertx.mysqlclient.impl.codec.InitialHandshakeCommandCodec.handleInitialHandshake(InitialHandshakeCommandCodec.java:74)
        at io.vertx.mysqlclient.impl.codec.InitialHandshakeCommandCodec.decodePayload(InitialHandshakeCommandCodec.java:59)
        at io.vertx.mysqlclient.impl.codec.MySQLDecoder.decodePackets(MySQLDecoder.java:72)
        at io.vertx.mysqlclient.impl.codec.MySQLDecoder.channelRead(MySQLDecoder.java:48)
        at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1589)

How to Reproduce?

github repo

Output of uname -a or ver

No response

Output of java -version

java version "19.0.1" 2022-10-18 Java(TM) SE Runtime Environment (build 19.0.1+10-21) Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.2.6.Final

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

Maven home: C:\Users\ptrue\.m2\wrapper\dists\apache-maven-3.9.3-bin\326f10f4\apache-maven-3.9.3 Java version: 19.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-19 Default locale: en_US, platform encoding: UTF-8 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

quarkus.http.port=9000
quarkus.datasource.cool.db-kind=mariadb
quarkus.datasource.cool.reactive.url=mariadb://localhost:3308/test
quarkus.datasource.cool.username=root
quarkus.datasource.cool.password=root

Docker compose file for mariadb (v11):

version: '3.1'

services:

  mysql:
    image: mysql:8.1
    restart: always
    ports:
      - 3306:3306
    volumes:
      - ./mysql_db_data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root 

  mariadb:
    image: mariadb:11
    restart: always
    ports:
      - 3308:3306
    volumes:
      - ./maria_db_data:/var/lib/mysql
    environment:
      MARIADB_ROOT_PASSWORD: root
  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
appiepollo14 commented 10 months ago

@red010182 in my opinion, this has nothing to do with quarkus and this must error reported at vertx. In their code, there is the database version being parsed. https://github.com/eclipse-vertx/vertx-sql-client/blob/68eb6520dd0a126aebaf518321ade7f8b01d8e95/vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/MySQLDatabaseMetadata.java#L64C7-L64C57 when running your dockerfile, the version in the database is: 11.1.2-MariaDB-1:11.1.2+maria~ubu2204 , this part of the version: 2-MariaDB-1:11 is put into an Integer.parseInt function. Will give a warning offcourse. IMHO, vertx needs to solve this.

appiepollo14 commented 10 months ago

Is solved in vertx mysql connector 4.4.6, will provide PR

gsmet commented 10 months ago

@appiepollo14 main is already using 4.4.6

appiepollo14 commented 10 months ago

@gsmet you were just a few seconds earlier than my to find this out!

appiepollo14 commented 10 months ago

@red010182 does upgrading to Quarkus solve the issue? Can this issue be closed?

quarkus-bot[bot] commented 10 months ago

/cc @tsegismont (reactive-sql-clients), @vietj (reactive-sql-clients)

tsegismont commented 10 months ago

This has been fixed upstream in Vert.x 4.4.5 https://github.com/eclipse-vertx/vertx-sql-client/pull/1345

@red010182 as a workaround, you can try to change the vertx-mysql-client version in your project to 4.4.5 But I would recommend to upgrade to Quarkus 3.2.8-Final instead, which ships Vert.x 4.4.6.

@cescoffier I believe this issue can be closed.