现象:
Version: 1.5.0-alpha.1
2022-03-01 21:02:48.321 INFO 3006711 --- [ main] run.halo.app.Application : Starting Application v1.5.0-alpha.1 using Java 11.0.13 on ls_sR9BjG5T with PID 3006711 (/home/server/halo/halo-1.5.0-alpha.1.jar started by in /home/server/halo)
2022-03-01 21:02:48.328 INFO 3006711 --- [ main] run.halo.app.Application : No active profile set, falling back to default profiles: default
2022-03-01 21:02:51.180 INFO 3006711 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-03-01 21:02:51.477 INFO 3006711 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 280 ms. Found 24 JPA repository interfaces.
2022-03-01 21:02:53.437 INFO 3006711 --- [ main] org.eclipse.jetty.util.log : Logging initialized @7529ms to org.eclipse.jetty.util.log.Slf4jLog
2022-03-01 21:02:53.826 INFO 3006711 --- [ main] o.s.b.w.e.j.JettyServletWebServerFactory : Server initialized with port: 8090
2022-03-01 21:02:53.839 INFO 3006711 --- [ main] org.eclipse.jetty.server.Server : jetty-9.4.44.v20210927; built: 2021-09-27T23:02:44.612Z; git: 8da83308eeca865e495e53ef315a249d63ba9332; jvm 11.0.13+8-LTS
2022-03-01 21:02:53.904 INFO 3006711 --- [ main] o.e.j.s.h.ContextHandler.application : Initializing Spring embedded WebApplicationContext
2022-03-01 21:02:53.905 INFO 3006711 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 5338 ms
2022-03-01 21:02:55.829 INFO 3006711 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-03-01 21:02:55.932 INFO 3006711 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.33
2022-03-01 21:02:56.010 INFO 3006711 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-03-01 21:02:56.253 INFO 3006711 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-03-01 21:02:56.886 INFO 3006711 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-03-01 21:02:56.956 INFO 3006711 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2022-03-01 21:02:59.232 INFO 3006711 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-03-01 21:02:59.256 INFO 3006711 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-03-01 21:02:59.916 INFO 3006711 --- [ main] run.halo.app.config.HaloConfiguration : Halo cache store load impl : [class run.halo.app.cache.InMemoryCacheStore]
2022-03-01 21:03:00.538 INFO 3006711 --- [ main] org.eclipse.jetty.server.session : DefaultSessionIdManager workerName=node0
2022-03-01 21:03:00.538 INFO 3006711 --- [ main] org.eclipse.jetty.server.session : No SessionScavenger set, using defaults
2022-03-01 21:03:00.541 INFO 3006711 --- [ main] org.eclipse.jetty.server.session : node0 Scavenging every 660000ms
2022-03-01 21:03:00.559 INFO 3006711 --- [ main] o.e.jetty.server.handler.ContextHandler : Started o.s.b.w.e.j.JettyEmbeddedWebAppContext@5d1bdd4a{application,/,[file:///tmp/jetty-docbase.8090.8101767950797055102/, jar:file:/home/server/halo/halo-1.5.0-alpha.1.jar!/BOOT-INF/lib/springfox-swagger-ui-3.0.0.jar!/META-INF/resources],AVAILABLE}
2022-03-01 21:03:00.559 INFO 3006711 --- [ main] org.eclipse.jetty.server.Server : Started @14654ms
2022-03-01 21:03:04.025 INFO 3006711 --- [ main] run.halo.app.handler.file.FileHandlers : Registered 9 file handler(s)
2022-03-01 21:03:07.323 INFO 3006711 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 4 endpoint(s) beneath base path '/api/admin/actuator'
2022-03-01 21:03:07.419 INFO 3006711 --- [ main] o.e.j.s.h.ContextHandler.application : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-03-01 21:03:07.420 INFO 3006711 --- [ main] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-03-01 21:03:07.422 INFO 3006711 --- [ main] o.s.web.servlet.DispatcherServlet : Completed initialization in 2 ms
2022-03-01 21:03:07.443 INFO 3006711 --- [ main] o.e.jetty.server.AbstractConnector : Started ServerConnector@3234f74e{HTTP/1.1, (http/1.1)}{0.0.0.0:8090}
2022-03-01 21:03:07.444 INFO 3006711 --- [ main] o.s.b.web.embedded.jetty.JettyWebServer : Jetty started on port(s) 8090 (http/1.1) with context path '/'
2022-03-01 21:03:07.479 INFO 3006711 --- [ main] run.halo.app.Application : Started Application in 20.452 seconds (JVM running for 21.573)
2022-03-01 21:03:07.481 INFO 3006711 --- [ main] run.halo.app.listener.StartedListener : Starting migrate database...
2022-03-01 21:03:07.589 INFO 3006711 --- [ main] o.f.c.internal.license.VersionPrinter : Flyway Community Edition 7.15.0 by Redgate
2022-03-01 21:03:07.590 INFO 3006711 --- [ main] o.f.c.i.database.base.BaseDatabaseType : Database: jdbc:h2:file:/home/.halo//db/halo (H2 1.4)
2022-03-01 21:03:07.636 INFO 3006711 --- [ main] o.f.c.i.s.JdbcTableSchemaHistory : Repair of failed migration in Schema History table "PUBLIC"."flyway_schema_history" not necessary. No failed migration detected.
2022-03-01 21:03:07.654 INFO 3006711 --- [ main] o.f.core.internal.command.DbRepair : Successfully repaired schema history table "PUBLIC"."flyway_schema_history" (execution time 00:00.033s).
2022-03-01 21:03:07.660 INFO 3006711 --- [ main] o.f.c.internal.license.VersionPrinter : Flyway Community Edition 7.15.0 by Redgate
2022-03-01 21:03:07.675 INFO 3006711 --- [ main] o.f.core.internal.command.DbValidate : Successfully validated 12 migrations (execution time 00:00.009s)
2022-03-01 21:03:07.690 INFO 3006711 --- [ main] o.f.core.internal.command.DbMigrate : Current version of schema "PUBLIC": 4
2022-03-01 21:03:07.714 INFO 3006711 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema "PUBLIC" to version "5 - migrate remove notnull for email in comments table"
2022-03-01 21:03:07.829 INFO 3006711 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema "PUBLIC" to version "6 - migrate create contents table"
2022-03-01 21:03:07.959 ERROR 3006711 --- [ main] o.f.core.internal.command.DbMigrate : Migration of schema "PUBLIC" to version "6 - migrate create contents table" failed! Please restore backups and roll back database and code!
2022-03-01 21:03:08.066 INFO 3006711 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-03-01 21:03:08.119 ERROR 3006711 --- [ main] o.s.boot.SpringApplication : Application run failed
org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException: Migration V6__migrate_create_contents_table.sql failed
------------------------------------------------------
SQL State : 23505
Error Code : 23505
Message : Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.CONTENTS(POST_ID) [1, TIMESTAMP '2021-08-18 17:15:23.596', TIMESTAMP '2021-08-18 21:24:35.215', SPACE(642 /* table: 74 id: 56903095 */), 1, SPACE(452 /* table: 74 id: 56903096 */), 1, 0]"; SQL statement:
-- Migrate post content to contents table
INSERT INTO contents(post_id, status, patch_log_id, head_patch_log_id, content, original_content, create_time,
update_time)
SELECT id,
status,
id,
id,
format_content,
original_content,
create_time,
update_time
FROM posts [23505-199]
Location : migration/V6__migrate_create_contents_table.sql (/home//server/halo/file:/home/server/halo/halo-1.5.0-alpha.1.jar!/BOOT-INF/classes!/migration/V6__migrate_create_contents_table.sql)
Line : 2
Statement : -- Migrate post content to contents table
INSERT INTO contents(post_id, status, patch_log_id, head_patch_log_id, content, original_content, create_time,
update_time)
SELECT id,
status,
id,
id,
format_content,
original_content,
create_time,
update_time
FROM posts
at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:378) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.lambda$applyMigrations$1(DbMigrate.java:271) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:66) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:270) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:243) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.lambda$migrateAll$0(DbMigrate.java:141) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.jdbc.TableLockingExecutionTemplate$1.call(TableLockingExecutionTemplate.java:38) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:66) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.jdbc.TableLockingExecutionTemplate.execute(TableLockingExecutionTemplate.java:33) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.database.base.Connection.lock(Connection.java:103) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:141) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:141) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:101) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.Flyway$1.execute(Flyway.java:219) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.Flyway$1.execute(Flyway.java:170) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.Flyway.execute(Flyway.java:586) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.Flyway.migrate(Flyway.java:170) ~[flyway-core-7.15.0.jar!/:na]
at run.halo.app.listener.StartedListener.migrate(StartedListener.java:123) ~[classes!/:1.5.0-alpha.1]
at run.halo.app.listener.StartedListener.onApplicationEvent(StartedListener.java:76) ~[classes!/:1.5.0-alpha.1]
at run.halo.app.listener.StartedListener.onApplicationEvent(StartedListener.java:47) ~[classes!/:1.5.0-alpha.1]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:105) ~[spring-boot-2.5.9.jar!/:2.5.9]
at org.springframework.boot.SpringApplicationRunListeners.lambda$started$5(SpringApplicationRunListeners.java:75) ~[spring-boot-2.5.9.jar!/:2.5.9]
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117) ~[spring-boot-2.5.9.jar!/:2.5.9]
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111) ~[spring-boot-2.5.9.jar!/:2.5.9]
at org.springframework.boot.SpringApplicationRunListeners.started(SpringApplicationRunListeners.java:75) ~[spring-boot-2.5.9.jar!/:2.5.9]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344) ~[spring-boot-2.5.9.jar!/:2.5.9]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1356) ~[spring-boot-2.5.9.jar!/:2.5.9]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1345) ~[spring-boot-2.5.9.jar!/:2.5.9]
at run.halo.app.Application.main(Application.java:21) ~[classes!/:1.5.0-alpha.1]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[halo-1.5.0-alpha.1.jar:1.5.0-alpha.1]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[halo-1.5.0-alpha.1.jar:1.5.0-alpha.1]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[halo-1.5.0-alpha.1.jar:1.5.0-alpha.1]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[halo-1.5.0-alpha.1.jar:1.5.0-alpha.1]
Caused by: org.flywaydb.core.internal.sqlscript.FlywaySqlScriptException: Migration V6__migrate_create_contents_table.sql failed
------------------------------------------------------
SQL State : 23505
Error Code : 23505
Message : Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.CONTENTS(POST_ID) [1, TIMESTAMP '2021-08-18 17:15:23.596', TIMESTAMP '2021-08-18 21:24:35.215', SPACE(642 /* table: 74 id: 56903095 */), 1, SPACE(452 /* table: 74 id: 56903096 */), 1, 0]"; SQL statement:
-- Migrate post content to contents table
INSERT INTO contents(post_id, status, patch_log_id, head_patch_log_id, content, original_content, create_time,
update_time)
SELECT id,
status,
id,
id,
format_content,
original_content,
create_time,
update_time
FROM posts [23505-199]
Location : migration/V6__migrate_create_contents_table.sql (/home/server/halo/file:/home/server/halo/halo-1.5.0-alpha.1.jar!/BOOT-INF/classes!/migration/V6__migrate_create_contents_table.sql)
Line : 2
Statement : -- Migrate post content to contents table
INSERT INTO contents(post_id, status, patch_log_id, head_patch_log_id, content, original_content, create_time,
update_time)
SELECT id,
status,
id,
id,
format_content,
original_content,
create_time,
update_time
FROM posts
at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.handleException(DefaultSqlScriptExecutor.java:277) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(DefaultSqlScriptExecutor.java:224) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.execute(DefaultSqlScriptExecutor.java:128) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.executeOnce(SqlMigrationExecutor.java:78) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.lambda$execute$0(SqlMigrationExecutor.java:67) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.database.DefaultExecutionStrategy.execute(DefaultExecutionStrategy.java:27) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:66) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:370) ~[flyway-core-7.15.0.jar!/:na]
... 42 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.CONTENTS(POST_ID) [1, TIMESTAMP '2021-08-18 17:15:23.596', TIMESTAMP '2021-08-18 21:24:35.215', SPACE(642 /* table: 74 id: 56903095 */), 1, SPACE(452 /* table: 74 id: 56903096 */), 1, 0]"; SQL statement:
-- Migrate post content to contents table
INSERT INTO contents(post_id, status, patch_log_id, head_patch_log_id, content, original_content, create_time,
update_time)
SELECT id,
status,
id,
id,
format_content,
original_content,
create_time,
update_time
FROM posts [23505-199]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:457) ~[h2-1.4.199.jar!/:na]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:427) ~[h2-1.4.199.jar!/:na]
at org.h2.message.DbException.get(DbException.java:205) ~[h2-1.4.199.jar!/:na]
at org.h2.message.DbException.get(DbException.java:181) ~[h2-1.4.199.jar!/:na]
at org.h2.mvstore.db.MVPrimaryIndex.add(MVPrimaryIndex.java:131) ~[h2-1.4.199.jar!/:na]
at org.h2.mvstore.db.MVTable.addRow(MVTable.java:546) ~[h2-1.4.199.jar!/:na]
at org.h2.command.dml.Insert.addRowImpl(Insert.java:251) ~[h2-1.4.199.jar!/:na]
at org.h2.command.dml.Insert.insertRows(Insert.java:207) ~[h2-1.4.199.jar!/:na]
at org.h2.command.dml.Insert.update(Insert.java:132) ~[h2-1.4.199.jar!/:na]
at org.h2.command.CommandContainer.update(CommandContainer.java:133) ~[h2-1.4.199.jar!/:na]
at org.h2.command.Command.executeUpdate(Command.java:267) ~[h2-1.4.199.jar!/:na]
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:233) ~[h2-1.4.199.jar!/:na]
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:205) ~[h2-1.4.199.jar!/:na]
at org.flywaydb.core.internal.jdbc.JdbcTemplate.executeStatement(JdbcTemplate.java:241) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.sqlscript.ParsedSqlStatement.execute(ParsedSqlStatement.java:111) ~[flyway-core-7.15.0.jar!/:na]
at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(DefaultSqlScriptExecutor.java:212) ~[flyway-core-7.15.0.jar!/:na]
... 48 common frames omitted
2022-03-01 21:03:08.138 INFO 3006711 --- [ main] o.e.jetty.server.AbstractConnector : Stopped ServerConnector@3234f74e{HTTP/1.1, (http/1.1)}{0.0.0.0:8090}
2022-03-01 21:03:08.138 INFO 3006711 --- [ main] org.eclipse.jetty.server.session : node0 Stopped scavenging
2022-03-01 21:03:08.140 INFO 3006711 --- [ main] o.e.j.s.h.ContextHandler.application : Destroying Spring FrameworkServlet 'dispatcherServlet'
2022-03-01 21:03:08.141 INFO 3006711 --- [ main] o.e.jetty.server.handler.ContextHandler : Stopped o.s.b.w.e.j.JettyEmbeddedWebAppContext@5d1bdd4a{application,/,[file:///tmp/jetty-docbase.8090.8101767950797055102/, jar:file:/home/server/halo/halo-1.5.0-alpha.1.jar!/BOOT-INF/lib/springfox-swagger-ui-3.0.0.jar!/META-INF/resources],STOPPED}
2022-03-01 21:03:08.169 INFO 3006711 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2022-03-01 21:03:08.172 INFO 3006711 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2022-03-01 21:03:09.204 INFO 3006711 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.