Skip to content

docker-compose 使用最新的 image 启动服务,服务初始化 SQL 报错了 #177

Open
@myxOpsKevin

Description

@myxOpsKevin

前提条件

  • 我已经创建 openjob 库

docker-compose 信息:

version: '3'

services:
  openjob:
    container_name: openjob
    image: openjob/openjob-server:latest
    restart: always
    environment:
      - AKKA_REMOTE_HOSTNAME=172.31.18.48
      #- OJ_DS_DRIVER_CLASS=com.mysql.cj.jdbc.Driver
      - OJ_DS_URL=jdbc:mysql://172.31.18.48:3306/openjob?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
      - OJ_DS_USERNAME=root
      - OJ_DS_PASSWORD=123456
      - OJ_LOG_STORAGE_MYSQL_URL=jdbc:mysql://172.31.18.48:3306/openjob?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
      - OJ_LOG_STORAGE_MYSQL_USER=root
      - OJ_LOG_STORAGE_MYSQL_PASSWORD=123456
    ports: 
      - "8080:8080"
      - "25520:25520" 
    privileged: true

报错信息

024-05-06 20:23:58,561 ERROR [main] o.f.core.internal.command.DbMigrate [Slf4jLog.java : 52] Migration of schema `openjob` to version "1 - v1.0.7 release" failed! Please restore backups and roll back database and code!
2024-05-06 20:23:58,588 WARN [main] o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext [AbstractApplicationContext.java : 591] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException: Migration V1__v1.0.7_release.sql failed
---------------------------------------
SQL State  : 42000
Error Code : 1064
Message    : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CLOB                  NOT NULL COMMENT 'Delay params',
    delay_extra      TEXT' at line 9
Location   : db/migration/h2/V1__v1.0.7_release.sql (/home/openjob/file:/home/openjob/target/openjob-server.jar!/BOOT-INF/classes!/db/migration/h2/V1__v1.0.7_release.sql)
Line       : 171
Statement  : CREATE TABLE `delay_instance`
(
    id               BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT 'PK',
    app_id           BIGINT                NOT NULL COMMENT 'Application',
    namespace_id     BIGINT                NOT NULL COMMENT 'Namespace',
    task_id          VARCHAR(64) DEFAULT '' NOT NULL COMMENT 'Task id',
    topic            VARCHAR(128) DEFAULT '' NOT NULL COMMENT 'Topic',
    delay_id         BIGINT                NOT NULL COMMENT 'Delay id',
    delay_params     CLOB                  NOT NULL COMMENT 'Delay params',
    delay_extra      TEXT                  NOT NULL COMMENT 'Delay extra',
    status           TINYINT               NOT NULL COMMENT 'Delay task status',
    fail_status      TINYINT DEFAULT 0     NOT NULL COMMENT 'Delay fail status',
    execute_time     BIGINT                NOT NULL COMMENT 'Execute time',
    complete_time    BIGINT DEFAULT 0      NOT NULL COMMENT 'Complete time',
    worker_address   VARCHAR(32) DEFAULT '' NOT NULL COMMENT 'Worker address',
    deleted          TINYINT DEFAULT 2     NOT NULL COMMENT 'Delete status. 1=yes 2=no',
    delete_time      BIGINT DEFAULT 0      NOT NULL COMMENT 'Delete time',
    create_time      BIGINT                NOT NULL COMMENT 'Create time',
    update_time      BIGINT                NOT NULL COMMENT 'Update time',
    create_time_date INT DEFAULT 0         NOT NULL COMMENT 'Time date`20230527`',
    create_time_hour INT DEFAULT 0         NOT NULL COMMENT 'Time hour`2023052701`'
)

2024-05-06 20:23:58,643 ERROR [main] o.s.boot.SpringApplication [SpringApplication.java : 843] Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException: Migration V1__v1.0.7_release.sql failed
---------------------------------------
SQL State  : 42000
Error Code : 1064
Message    : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CLOB                  NOT NULL COMMENT 'Delay params',
    delay_extra      TEXT' at line 9
Location   : db/migration/h2/V1__v1.0.7_release.sql (/home/openjob/file:/home/openjob/target/openjob-server.jar!/BOOT-INF/classes!/db/migration/h2/V1__v1.0.7_release.sql)
Line       : 171
Statement  : CREATE TABLE `delay_instance`
(
    id               BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT 'PK',
    app_id           BIGINT                NOT NULL COMMENT 'Application',
    namespace_id     BIGINT                NOT NULL COMMENT 'Namespace',
    task_id          VARCHAR(64) DEFAULT '' NOT NULL COMMENT 'Task id',
    topic            VARCHAR(128) DEFAULT '' NOT NULL COMMENT 'Topic',
    delay_id         BIGINT                NOT NULL COMMENT 'Delay id',
    delay_params     CLOB                  NOT NULL COMMENT 'Delay params',
    delay_extra      TEXT                  NOT NULL COMMENT 'Delay extra',
    status           TINYINT               NOT NULL COMMENT 'Delay task status',
    fail_status      TINYINT DEFAULT 0     NOT NULL COMMENT 'Delay fail status',
    execute_time     BIGINT                NOT NULL COMMENT 'Execute time',
    complete_time    BIGINT DEFAULT 0      NOT NULL COMMENT 'Complete time',
    worker_address   VARCHAR(32) DEFAULT '' NOT NULL COMMENT 'Worker address',
    deleted          TINYINT DEFAULT 2     NOT NULL COMMENT 'Delete status. 1=yes 2=no',
    delete_time      BIGINT DEFAULT 0      NOT NULL COMMENT 'Delete time',
    create_time      BIGINT                NOT NULL COMMENT 'Create time',
    update_time      BIGINT                NOT NULL COMMENT 'Update time',
    create_time_date INT DEFAULT 0         NOT NULL COMMENT 'Time date`20230527`',
    create_time_hour INT DEFAULT 0         NOT NULL COMMENT 'Time hour`2023052701`'
)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
        at io.openjob.server.ServerApplication.main(ServerApplication.java:19)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException: Migration V1__v1.0.7_release.sql failed
---------------------------------------
SQL State  : 42000
Error Code : 1064
Message    : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CLOB                  NOT NULL COMMENT 'Delay params',
    delay_extra      TEXT' at line 9
Location   : db/migration/h2/V1__v1.0.7_release.sql (/home/openjob/file:/home/openjob/target/openjob-server.jar!/BOOT-INF/classes!/db/migration/h2/V1__v1.0.7_release.sql)
Line       : 171
Statement  : CREATE TABLE `delay_instance`
(
    id               BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT 'PK',
    app_id           BIGINT                NOT NULL COMMENT 'Application',
    namespace_id     BIGINT                NOT NULL COMMENT 'Namespace',
    task_id          VARCHAR(64) DEFAULT '' NOT NULL COMMENT 'Task id',
    topic            VARCHAR(128) DEFAULT '' NOT NULL COMMENT 'Topic',
    delay_id         BIGINT                NOT NULL COMMENT 'Delay id',
    delay_params     CLOB                  NOT NULL COMMENT 'Delay params',
    delay_extra      TEXT                  NOT NULL COMMENT 'Delay extra',
    status           TINYINT               NOT NULL COMMENT 'Delay task status',
    fail_status      TINYINT DEFAULT 0     NOT NULL COMMENT 'Delay fail status',
    execute_time     BIGINT                NOT NULL COMMENT 'Execute time',
    complete_time    BIGINT DEFAULT 0      NOT NULL COMMENT 'Complete time',
    worker_address   VARCHAR(32) DEFAULT '' NOT NULL COMMENT 'Worker address',
    deleted          TINYINT DEFAULT 2     NOT NULL COMMENT 'Delete status. 1=yes 2=no',
    delete_time      BIGINT DEFAULT 0      NOT NULL COMMENT 'Delete time',
    create_time      BIGINT                NOT NULL COMMENT 'Create time',
    update_time      BIGINT                NOT NULL COMMENT 'Update time',
    create_time_date INT DEFAULT 0         NOT NULL COMMENT 'Time date`20230527`',
    create_time_hour INT DEFAULT 0         NOT NULL COMMENT 'Time hour`2023052701`'
)

        at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:378)
        at org.flywaydb.core.internal.command.DbMigrate.lambda$applyMigrations$1(DbMigrate.java:271)
        at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:66)
        at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:270)
        at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:243)
        at org.flywaydb.core.internal.command.DbMigrate.lambda$migrateAll$0(DbMigrate.java:141)
        at org.flywaydb.core.internal.database.mysql.MySQLNamedLockTemplate.execute(MySQLNamedLockTemplate.java:60)
        at org.flywaydb.core.internal.database.mysql.MySQLConnection.lock(MySQLConnection.java:154)
        at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:141)
        at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:141)
        at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:101)
        at org.flywaydb.core.Flyway$1.execute(Flyway.java:219)
        at org.flywaydb.core.Flyway$1.execute(Flyway.java:170)
        at org.flywaydb.core.Flyway.execute(Flyway.java:586)
        at org.flywaydb.core.Flyway.migrate(Flyway.java:170)
        at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
        ... 26 common frames omitted
Caused by: org.flywaydb.core.internal.sqlscript.FlywaySqlScriptException: Migration V1__v1.0.7_release.sql failed
---------------------------------------
SQL State  : 42000
Error Code : 1064
Message    : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CLOB                  NOT NULL COMMENT 'Delay params',
    delay_extra      TEXT' at line 9
Location   : db/migration/h2/V1__v1.0.7_release.sql (/home/openjob/file:/home/openjob/target/openjob-server.jar!/BOOT-INF/classes!/db/migration/h2/V1__v1.0.7_release.sql)
Line       : 171
Statement  : CREATE TABLE `delay_instance`
(
    id               BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT 'PK',
    app_id           BIGINT                NOT NULL COMMENT 'Application',
    namespace_id     BIGINT                NOT NULL COMMENT 'Namespace',
    task_id          VARCHAR(64) DEFAULT '' NOT NULL COMMENT 'Task id',
    topic            VARCHAR(128) DEFAULT '' NOT NULL COMMENT 'Topic',
    delay_id         BIGINT                NOT NULL COMMENT 'Delay id',
    delay_params     CLOB                  NOT NULL COMMENT 'Delay params',
    delay_extra      TEXT                  NOT NULL COMMENT 'Delay extra',
    status           TINYINT               NOT NULL COMMENT 'Delay task status',
    fail_status      TINYINT DEFAULT 0     NOT NULL COMMENT 'Delay fail status',
    execute_time     BIGINT                NOT NULL COMMENT 'Execute time',
    complete_time    BIGINT DEFAULT 0      NOT NULL COMMENT 'Complete time',
    worker_address   VARCHAR(32) DEFAULT '' NOT NULL COMMENT 'Worker address',
    deleted          TINYINT DEFAULT 2     NOT NULL COMMENT 'Delete status. 1=yes 2=no',
    delete_time      BIGINT DEFAULT 0      NOT NULL COMMENT 'Delete time',
    create_time      BIGINT                NOT NULL COMMENT 'Create time',
    update_time      BIGINT                NOT NULL COMMENT 'Update time',
    create_time_date INT DEFAULT 0         NOT NULL COMMENT 'Time date`20230527`',
    create_time_hour INT DEFAULT 0         NOT NULL COMMENT 'Time hour`2023052701`'
)

        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.handleException(DefaultSqlScriptExecutor.java:277)
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(DefaultSqlScriptExecutor.java:224)
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.execute(DefaultSqlScriptExecutor.java:128)
        at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.executeOnce(SqlMigrationExecutor.java:78)
        at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.lambda$execute$0(SqlMigrationExecutor.java:67)
        at org.flywaydb.core.internal.database.DefaultExecutionStrategy.execute(DefaultExecutionStrategy.java:27)
        at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:66)
        at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:370)
        ... 43 common frames omitted
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CLOB                  NOT NULL COMMENT 'Delay params',
    delay_extra      TEXT' at line 9
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
        at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:768)
        at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:653)
        at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94)
        at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
        at org.flywaydb.core.internal.jdbc.JdbcTemplate.executeStatement(JdbcTemplate.java:241)
        at org.flywaydb.core.internal.sqlscript.ParsedSqlStatement.execute(ParsedSqlStatement.java:111)
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(DefaultSqlScriptExecutor.java:212)
        ... 49 common frames omitted

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions