把mysql替换成TIDB,运行报错

chival365 2021-12-27 1144

SQL State : 42000 Error Code : 1235 Message : function get_lock has only noop implementation in tidb now, use tidb_enable_noop_functions to enable these functions

    at org.flywaydb.core.internal.database.mysql.MySQLNamedLockTemplate.execute(MySQLNamedLockTemplate.java:62)
    at org.flywaydb.core.internal.database.mysql.MySQLConnection.lock(MySQLConnection.java:147)
    at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:155)
    at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:161)
    at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:139)
    at org.flywaydb.core.Flyway$1.execute(Flyway.java:1395)
    at org.flywaydb.core.Flyway$1.execute(Flyway.java:1356)
    at org.flywaydb.core.Flyway.execute(Flyway.java:1711)
    at org.flywaydb.core.Flyway.migrate(Flyway.java:1356)
    at win.liyufan.im.DBUtil.init(DBUtil.java:113)
    at io.moquette.server.Server.startServer(Server.java:227)
    at io.moquette.server.Server.startServer(Server.java:219)
    at io.moquette.server.Server.startServer(Server.java:203)
    at io.moquette.server.Server.start(Server.java:113)
    at cn.wildfirechat.server.Server.main(Server.java:15)

Caused by: java.sql.SQLSyntaxErrorException: function get_lock has only noop implementation in tidb now, use tidb_enable_noop_functions to enable these functions at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1003) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:431) at org.flywaydb.core.internal.jdbc.JdbcTemplate.queryForInt(JdbcTemplate.java:139) at org.flywaydb.core.internal.database.mysql.MySQLNamedLockTemplate.tryLock(MySQLNamedLockTemplate.java:91) at org.flywaydb.core.internal.database.mysql.MySQLNamedLockTemplate.lock(MySQLNamedLockTemplate.java:81) at org.flywaydb.core.internal.database.mysql.MySQLNamedLockTemplate.execute(MySQLNamedLockTemplate.java:59) ... 14 more

最新回复 (6)
  • HeavyRain 2021-12-27
    引用 2
    可能是我们使用的flyway版本不支持tidb,请试一下把flyway的版本升级一下试试。从 https://repo1.maven.org/maven2/org/flywaydb/flyway-core/8.2.3/flyway-core-8.2.3.jar  这里下载8.2.3的jar包,然后替换lib里的flyway-core-xxx.jar

    请把使用结果反映给我们,谢谢
  • chival365 2021-12-27
    引用 3
    换成了flayway 8.2.3,报另外的错:

    Exception in thread "main" org.flywaydb.core.api.FlywayException: Unsupported Database: MySQL 5.7
            at org.flywaydb.core.internal.database.DatabaseTypeRegister.getDatabaseTypeForConnection(DatabaseTypeRegister.java:106)
            at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:75)
            at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:143)
            at org.flywaydb.core.Flyway.info(Flyway.java:191)
            at win.liyufan.im.DBUtil.init(DBUtil.java:110)
            at io.moquette.server.Server.startServer(Server.java:227)
            at io.moquette.server.Server.startServer(Server.java:219)
            at io.moquette.server.Server.startServer(Server.java:203)
            at io.moquette.server.Server.start(Server.java:113)
            at cn.wildfirechat.server.Server.main(Server.java:15)
    Heap
     garbage-first heap   total 129024K, used 59213K [0x0000000083400000, 0x00000000835003f0, 0x0000000100000000)
      region size 1024K, 59 young (60416K), 1 survivors (1024K)
     Metaspace       used 15019K, capacity 15240K, committed 15616K, reserved 1062912K
      class space    used 1611K, capacity 1690K, committed 1792K, reserved 1048576K
  • HeavyRain 2021-12-27
    引用 4
    我们查了一下flyway最新版本不支持mysql5.7了。。。还是得退回去,看第一额日志是要开启一个状态,试试下面命令:
    set global tidb_enable_noop_functions=1; 

    如果还是不行,建议咨询一下tidb官方
  • chival365 2021-12-27
    引用 5
    现在可以了。
  • chival365 2021-12-28
    引用 6
    野火的数据库有用到临时表吗,CREATE TEMPORARY TABLE 
  • HeavyRain 2021-12-28
    引用 7
    野火没有用到临时表,可以把问题发出来看看
返回