Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading from 0.26.2 to 0.28.1 Fails with insert or update on table "report_card" violates foreign key constraint "fk_report_card_ref_database_id" #7031

Closed
zaksoup opened this issue Feb 27, 2018 · 4 comments
Labels
Operation/ Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Type:Bug Product defects
Milestone

Comments

@zaksoup
Copy link

zaksoup commented Feb 27, 2018

Hi All, this seems similar to #6520 but is happening to me on 0.28.1

When upgrading a heroku deploy of metabase following the instructions in https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-heroku.html metabase crashes with the following error: insert or update on table "report_card" violates foreign key constraint "fk_report_card_ref_database_id"

  • Your databases: (e.x. MySQL, Postgres, MongoDB, …)
    Postgres
  • Metabase version: (e.x. 0.19.3)
    0.26.2 upgrade to 0.28.1
  • Metabase hosting environment: (e.x. Mac app, Elastic Beanstalk, Docker, Heroku, Linux/Ubuntu 12)
    Heroku
  • Metabase internal database: (e.x. H2 (default), MySQL, Postgres)
    Postgres

I managed to manually clean this up following the instructions provided in #6520 but ifgured you might want to take a look and see if there's an issue with this in 0.28.1


Full logs:

2018-02-27T20:14:18.176636+00:00 app[web.1]: 02-27 20:14:18 �[1mINFO db.migrations�[0m :: Running data migration 'populate-card-database-id'...
2018-02-27T20:14:18.246022+00:00 app[web.1]: org.postgresql.util.PSQLException: ERROR: insert or update on table "report_card" violates foreign key constraint "fk_report_card_ref_database_id"
2018-02-27T20:14:18.246046+00:00 app[web.1]:   Detail: Key (database_id)=(8) is not present in table "metabase_database".
2018-02-27T20:14:18.246319+00:00 app[web.1]: 	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477)
2018-02-27T20:14:18.246377+00:00 app[web.1]: 	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190)
2018-02-27T20:14:18.246450+00:00 app[web.1]: 	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:300)
2018-02-27T20:14:18.246495+00:00 app[web.1]: 	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428)
2018-02-27T20:14:18.246544+00:00 app[web.1]: 	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354)
2018-02-27T20:14:18.246586+00:00 app[web.1]: 	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:169)
2018-02-27T20:14:18.246617+00:00 app[web.1]: 	at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:136)
2018-02-27T20:14:18.246654+00:00 app[web.1]: 	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
2018-02-27T20:14:18.246680+00:00 app[web.1]: 	at clojure.java.jdbc$db_do_execute_prepared_statement$fn__10897.invoke(jdbc.clj:952)
2018-02-27T20:14:18.246703+00:00 app[web.1]: 	at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:741)
2018-02-27T20:14:18.246745+00:00 app[web.1]: 	at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:711)
2018-02-27T20:14:18.246774+00:00 app[web.1]: 	at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:724)
2018-02-27T20:14:18.246795+00:00 app[web.1]: 	at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:711)
2018-02-27T20:14:18.246816+00:00 app[web.1]: 	at clojure.java.jdbc$db_do_execute_prepared_statement.invokeStatic(jdbc.clj:951)
2018-02-27T20:14:18.246837+00:00 app[web.1]: 	at clojure.java.jdbc$db_do_execute_prepared_statement.invoke(jdbc.clj:945)
2018-02-27T20:14:18.246876+00:00 app[web.1]: 	at clojure.java.jdbc$db_do_prepared.invokeStatic(jdbc.clj:983)
2018-02-27T20:14:18.246944+00:00 app[web.1]: 	at clojure.java.jdbc$db_do_prepared.invoke(jdbc.clj:963)
2018-02-27T20:14:18.247019+00:00 app[web.1]: 	at clojure.java.jdbc$execute_BANG_$execute_helper__10968.invoke(jdbc.clj:1364)
2018-02-27T20:14:18.247064+00:00 app[web.1]: 	at clojure.java.jdbc$execute_BANG_.invokeStatic(jdbc.clj:1368)
2018-02-27T20:14:18.247118+00:00 app[web.1]: 	at clojure.java.jdbc$execute_BANG_.invoke(jdbc.clj:1337)
2018-02-27T20:14:18.247171+00:00 app[web.1]: 	at toucan.db$execute_BANG_.invokeStatic(db.clj:416)
2018-02-27T20:14:18.247215+00:00 app[web.1]: 	at toucan.db$execute_BANG_.doInvoke(db.clj:411)
2018-02-27T20:14:18.247260+00:00 app[web.1]: 	at clojure.lang.RestFn.invoke(RestFn.java:410)
2018-02-27T20:14:18.247309+00:00 app[web.1]: 	at toucan.db$update_BANG_.invokeStatic(db.clj:473)
2018-02-27T20:14:18.247357+00:00 app[web.1]: 	at toucan.db$update_BANG_.invoke(db.clj:462)
2018-02-27T20:14:18.247422+00:00 app[web.1]: 	at toucan.db$update_where_BANG_.invokeStatic(db.clj:501)
2018-02-27T20:14:18.247465+00:00 app[web.1]: 	at toucan.db$update_where_BANG_.doInvoke(db.clj:491)
2018-02-27T20:14:18.247516+00:00 app[web.1]: 	at clojure.lang.RestFn.invoke(RestFn.java:464)
2018-02-27T20:14:18.247563+00:00 app[web.1]: 	at metabase.db.migrations$populate_card_database_id.invokeStatic(migrations.clj:343)
2018-02-27T20:14:18.247608+00:00 app[web.1]: 	at metabase.db.migrations$populate_card_database_id.invoke(migrations.clj:339)
2018-02-27T20:14:18.247651+00:00 app[web.1]: 	at metabase.db.migrations$run_migration_if_needed_BANG_.invokeStatic(migrations.clj:50)
2018-02-27T20:14:18.247745+00:00 app[web.1]: 	at metabase.db.migrations$run_migration_if_needed_BANG_.invoke(migrations.clj:41)
2018-02-27T20:14:18.247773+00:00 app[web.1]: 	at metabase.db.migrations$run_all_BANG_.invokeStatic(migrations.clj:70)
2018-02-27T20:14:18.247823+00:00 app[web.1]: 	at metabase.db.migrations$run_all_BANG_.invoke(migrations.clj:64)
2018-02-27T20:14:18.247872+00:00 app[web.1]: 	at clojure.lang.Var.invoke(Var.java:375)
2018-02-27T20:14:18.247919+00:00 app[web.1]: 	at metabase.db$run_data_migrations_BANG_.invokeStatic(db.clj:390)
2018-02-27T20:14:18.247997+00:00 app[web.1]: 	at metabase.db$run_data_migrations_BANG_.invoke(db.clj:385)
2018-02-27T20:14:18.248029+00:00 app[web.1]: 	at metabase.db$setup_db_BANG_.invokeStatic(db.clj:401)
2018-02-27T20:14:18.248060+00:00 app[web.1]: 	at metabase.db$setup_db_BANG_.doInvoke(db.clj:392)
2018-02-27T20:14:18.248108+00:00 app[web.1]: 	at clojure.lang.RestFn.invoke(RestFn.java:421)
2018-02-27T20:14:18.248152+00:00 app[web.1]: 	at metabase.core$init_BANG_.invokeStatic(core.clj:140)
2018-02-27T20:14:18.248180+00:00 app[web.1]: 	at metabase.core$init_BANG_.invoke(core.clj:119)
2018-02-27T20:14:18.248231+00:00 app[web.1]: 	at metabase.core$start_normally.invokeStatic(core.clj:248)
2018-02-27T20:14:18.248273+00:00 app[web.1]: 	at metabase.core$start_normally.invoke(core.clj:241)
2018-02-27T20:14:18.248315+00:00 app[web.1]: 	at metabase.core$_main.invokeStatic(core.clj:269)
2018-02-27T20:14:18.248359+00:00 app[web.1]: 	at metabase.core$_main.doInvoke(core.clj:264)
2018-02-27T20:14:18.248404+00:00 app[web.1]: 	at clojure.lang.RestFn.invoke(RestFn.java:397)
2018-02-27T20:14:18.248447+00:00 app[web.1]: 	at clojure.lang.AFn.applyToHelper(AFn.java:152)
2018-02-27T20:14:18.248491+00:00 app[web.1]: 	at clojure.lang.RestFn.applyTo(RestFn.java:132)
2018-02-27T20:14:18.248551+00:00 app[web.1]: 	at metabase.core.main(Unknown Source)
2018-02-27T20:14:18.248909+00:00 app[web.1]: 02-27 20:14:18 �[1mERROR metabase.core�[0m :: Metabase Initialization FAILED:  ERROR: insert or update on table "report_card" violates foreign key constraint "fk_report_card_ref_database_id"
2018-02-27T20:14:18.248912+00:00 app[web.1]:   Detail: Key (database_id)=(8) is not present in table "metabase_database".
2018-02-27T20:14:18.262014+00:00 app[web.1]: 02-27 20:14:18 �[1mINFO metabase.core�[0m :: Metabase Shutting Down ...
2018-02-27T20:14:18.269512+00:00 app[web.1]: 02-27 20:14:18 �[1mINFO metabase.core�[0m :: Metabase Shutdown COMPLETE
2018-02-27T20:14:18.703030+00:00 heroku[web.1]: Process exited with status 1
@salsakran salsakran added Type:Bug Product defects Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Operation/ labels Mar 1, 2018
@aliasmee
Copy link

+1

@senior
Copy link
Contributor

senior commented Mar 28, 2018

Thanks for reporting this. The fix was not rolled into master (and subsequently not released as part of 0.28). I just opened a #7230 to get it applied to the soon to be release 0.28.4 version. I'll make sure it gets in master so we don't make the same mistake again.

@camsaul camsaul added this to the 0.28.4 milestone Mar 29, 2018
@camsaul
Copy link
Member

camsaul commented Mar 29, 2018

Fixed by #7230

@camsaul camsaul closed this as completed Mar 29, 2018
@salsakran
Copy link
Contributor

@zaksoup @aliasmee this is fixed in 0.28.4 which just went out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Operation/ Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Type:Bug Product defects
Projects
None yet
Development

No branches or pull requests

5 participants