Restore from backup - 500 Internal Error

So I performed the migration from MySQL to PostgreSQL on my server.

DB migration appears to be in progress

    $ sudo -u git -H /usr/local/bin/bundle exec rake db:migrate RAILS_ENV=production
    DEBUG:  CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0
    DEBUG:  StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0
    DEBUG:  CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0
    DEBUG:  StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0

Waiting for this to finish so the login page will appear.

Production log is currently showing the ā€œnamespaceā€ error with internal error (500)

So I was comparing some projects from mySQL and postgreSQL.

I noticed that the ā€œissues_tracker_idā€ is NULL in mySQL, but empty in postgreSQL.

Could this be the issue or just a red herring?

I think NULL is visualized as empty in postgresā€™ output.
And I could imagine that MySQL is more forgiving when restoring a DB dump in concerns to foreign keys than Postgres.

There is definitely something odd in the database that is upsetting the code but I canā€™t seem to figure it out. Iā€™m new to ruby so donā€™t really have a clue what Iā€™m looking at. When I compare the two databases (MySQL and PostgreSQL) they both look the same except for NULL vs empty values.
The code that is complaining has populated entries in DB for issue tracker. Not that we ever used that feature anyway.
Is there a way to debug the rails application on the command line with breakpoints so I can diagnose stuff.

So I reset the DB and imported the psql file. I think there is an issue with the content of the psql file. here are are few issues that appeared when I was imported into Postgres.

psql:gitlabhq_production.psql:1171: NOTICE:  sequence "abuse_reports_id_seq" does not exist, skipping
DROP SEQUENCE
CREATE SEQUENCE
 setval
--------

(1 row)

And this

ALTER TABLE
psql:gitlabhq_production.psql:1405: NOTICE:  index "index_audit_events_on_author_id" does not exist, skipping

And this

psql:gitlabhq_production.psql:1558: ERROR:  relation "index_audit_events_on_author_id" already exists
psql:gitlabhq_production.psql:1559: ERROR:  current transaction is aborted, commands ignored until end of transaction block

Line 1559

CREATE INDEX "index_audit_events_on_type" ON audit_events_old ("type");

And then at the end

ROLLBACK

ok so the issue is the transaction during import to PSQL is getting aborted. Going to try with a clean DB

CREATE INDEX "index_audit_events_on_author_id" ON audit_events_old ("author_id");
psql:gitlabhq_production.psql:1558: ERROR:  relation "index_audit_events_on_author_id" already exists
CREATE INDEX "index_audit_events_on_type" ON audit_events_old ("type");
psql:gitlabhq_production.psql:1559: ERROR:  current transaction is aborted, commands ignored until end of transaction block

ok I think I found the issue. Some of my tables are duplicated (_old)

Here is the PSQL commands

-- Indexes --
CREATE INDEX "index_audit_events_on_author_id" ON audit_events ("author_id");
CREATE INDEX "index_audit_events_on_type" ON audit_events ("type");
CREATE INDEX "index_audit_events_on_entity_id_and_entity_type" ON audit_events ("entity_id","entity_type");
CREATE INDEX "index_audit_events_on_author_id" ON audit_events_old ("author_id");

So there are duplicate index names for duplicate tables!!! Going to drop the _old tables in mysql and start again.

1 Like

That resolved the issue. Now I can get the sign-in page loaded. Thanks to all that contributed