Cannot start up auth service when migrating to 3.4 RC
Description
Get an error when migrating to latest 3.4 code on perftest with MW dataset.
Caused by: org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException:
Migration 20180613120215847__remove_referencedatauserid_from_user.sql failed
----------------------------------------------------------------------------
SQL State : 23503
Error Code : 0
Message : ERROR: update or delete on table "auth_users" violates foreign key constraint "fk_la2ts67g4oh2sreayswhox1i6" on table "password_reset_tokens"
Detail: Key (id)=(da5e15f0-e3a6-4104-9db0-02d3806e6ae1) is still referenced from table "password_reset_tokens".
Location : db/migration/20180613120215847__remove_referencedatauserid_from_user.sql (/file:/service.jar!/BOOT-INF/classes!/db/migration/20180613120215847__remove_referencedatauserid_from_user.sql)
Line : 1
Statement : UPDATE auth_users SET id = referencedatauserid
at org.flywaydb.core.internal.dbsupport.SqlScript.execute(SqlScript.java:117)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:71)
at org.flywaydb.core.internal.command.DbMigrate.doMigrate(DbMigrate.java:352)
at org.flywaydb.core.internal.command.DbMigrate.access$1100(DbMigrate.java:47)
at org.flywaydb.core.internal.command.DbMigrate$4.doInTransaction(DbMigrate.java:308)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72)
at org.flywaydb.core.internal.command.DbMigrate.applyMigration(DbMigrate.java:305)
at org.flywaydb.core.internal.command.DbMigrate.access$1000(DbMigrate.java:47)
at org.flywaydb.core.internal.command.DbMigrate$2.doInTransaction(DbMigrate.java:230)
at org.flywaydb.core.internal.command.DbMigrate$2.doInTransaction(DbMigrate.java:173)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72)
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:173)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:959)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:917)
at org.flywaydb.core.Flyway.execute(Flyway.java:1373)
at org.flywaydb.core.Flyway.migrate(Flyway.java:917)
at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579)
... 26 common frames omitted
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "auth_users" violates foreign key constraint "fk_la2ts67g4oh2sreayswhox1i6" on table "password_reset_tokens"
Detail: Key (id)=(da5e15f0-e3a6-4104-9db0-02d3806e6ae1) is still referenced from table "password_reset_tokens".
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2412)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2125)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:297)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:301)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:287)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:264)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:260)
at org.flywaydb.core.internal.dbsupport.JdbcTemplate.executeStatement(JdbcTemplate.java:238)
at org.flywaydb.core.internal.dbsupport.SqlScript.execute(SqlScript.java:114)
... 44 common frames omitted
Looks like foreign key issue in migration script, when there is data in password_reset_tokens.
Environment
None
Activity
Łukasz Lewczyński
July 12, 2018 at 7:06 AM
@Chongsun Ahn I will fix this as fast as I can
CC: @Nikodem Graczewski@Sebastian Brudziński@Sam Im
Sam Im
July 11, 2018 at 6:10 PM
FYI @Sebastian Brudziński
Chongsun Ahn
July 11, 2018 at 5:53 PM
@Łukasz Lewczyński I believe you created this migration script. Can you take a look at this issue, or assign to someone if you don't have time?
Done
Pinned fields
Click on the next to a field label to start pinning.
Get an error when migrating to latest 3.4 code on perftest with MW dataset.
Caused by: org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException: Migration 20180613120215847__remove_referencedatauserid_from_user.sql failed ---------------------------------------------------------------------------- SQL State : 23503 Error Code : 0 Message : ERROR: update or delete on table "auth_users" violates foreign key constraint "fk_la2ts67g4oh2sreayswhox1i6" on table "password_reset_tokens" Detail: Key (id)=(da5e15f0-e3a6-4104-9db0-02d3806e6ae1) is still referenced from table "password_reset_tokens". Location : db/migration/20180613120215847__remove_referencedatauserid_from_user.sql (/file:/service.jar!/BOOT-INF/classes!/db/migration/20180613120215847__remove_referencedatauserid_from_user.sql) Line : 1 Statement : UPDATE auth_users SET id = referencedatauserid at org.flywaydb.core.internal.dbsupport.SqlScript.execute(SqlScript.java:117) at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:71) at org.flywaydb.core.internal.command.DbMigrate.doMigrate(DbMigrate.java:352) at org.flywaydb.core.internal.command.DbMigrate.access$1100(DbMigrate.java:47) at org.flywaydb.core.internal.command.DbMigrate$4.doInTransaction(DbMigrate.java:308) at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72) at org.flywaydb.core.internal.command.DbMigrate.applyMigration(DbMigrate.java:305) at org.flywaydb.core.internal.command.DbMigrate.access$1000(DbMigrate.java:47) at org.flywaydb.core.internal.command.DbMigrate$2.doInTransaction(DbMigrate.java:230) at org.flywaydb.core.internal.command.DbMigrate$2.doInTransaction(DbMigrate.java:173) at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72) at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:173) at org.flywaydb.core.Flyway$1.execute(Flyway.java:959) at org.flywaydb.core.Flyway$1.execute(Flyway.java:917) at org.flywaydb.core.Flyway.execute(Flyway.java:1373) at org.flywaydb.core.Flyway.migrate(Flyway.java:917) at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) ... 26 common frames omitted Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "auth_users" violates foreign key constraint "fk_la2ts67g4oh2sreayswhox1i6" on table "password_reset_tokens" Detail: Key (id)=(da5e15f0-e3a6-4104-9db0-02d3806e6ae1) is still referenced from table "password_reset_tokens". at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2412) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2125) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:297) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:301) at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:287) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:264) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:260) at org.flywaydb.core.internal.dbsupport.JdbcTemplate.executeStatement(JdbcTemplate.java:238) at org.flywaydb.core.internal.dbsupport.SqlScript.execute(SqlScript.java:114) ... 44 common frames omitted
Looks like foreign key issue in migration script, when there is data in password_reset_tokens.