orangeCatDeveloper opened a new pull request, #4326:
URL: https://github.com/apache/hertzbeat/pull/4326
Fixes #4325
On a fresh MySQL/PostgreSQL database the manager bricks itself: it fails
once on V181, then refuses to start forever until someone hand-deletes a row
from `flyway_schema_history`.
Root cause: Flyway is deliberately delayed until after
`entityManagerFactory`, so Hibernate `ddl-auto` creates `hzb_sop_schedule`
first. V181's bare `CREATE TABLE` then collides, Flyway records the failure,
and every later boot dies in validation:
```
FlywayValidateException: Validate failed: Migrations have failed validation
Detected failed migration to version 181 (update column)
```
The fix has two halves. The scripts become idempotent (`CREATE TABLE IF NOT
EXISTS` / `CREATE INDEX IF NOT EXISTS` in both mysql and postgresql variants),
so racing Hibernate no longer fails the migration. And for instances already
bricked, `FlywayConfiguration` catches this one validation failure ("failed
migration"), runs `flyway.repair()` and retries once — other validation errors
(e.g. checksum mismatch) still propagate, since those need a human decision.
`FlywayConfigurationTest` pins both behaviors with mocks (repair + retry
ordering; checksum errors rethrown without repair).
Verified against real MySQL 8 and PostgreSQL 15 (Hibernate-created table
first, then Flyway with production baseline settings):
```
before: 1st boot V181 CREATE TABLE collides -> failure recorded
2nd boot FlywayValidateException: Detected failed migration to
version 181 (bricked forever)
after: fresh install with pre-existing table -> migrate succeeds
already-bricked history -> repair + retry succeeds,
instance starts
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]