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

Test database population fails for Postgres version 11 #721

Open
fedarko opened this issue Nov 8, 2018 · 2 comments
Open

Test database population fails for Postgres version 11 #721

fedarko opened this issue Nov 8, 2018 · 2 comments

Comments

@fedarko
Copy link
Contributor

fedarko commented Nov 8, 2018

I get an error from pg_restore that schema "public" already exists. In turn, this causes populate_test_db() (in amgut/lib/data_access/env_management.py) to raise an error.

I encountered this error just when using Postgres version 11. Moving down to Postgres version 10.5 (by adjusting my system's PATH and opening a new terminal instance) fixes the error.

Per this Stack Overflow post and Daniel Vérité's answer to it, this sort of problem has been documented as impacting different versions of Postgres (although oddly enough the problematic version here -- 11 -- is later than 9.2, the apparent problematic version from that post). In particular, it looks like the version of the Postgres binaries in use (pg_restore, etc.) is what impacts the error -- I tried versions 11, 10.5, 9.6, and 9.5 of the binaries all with the version 11 Postgres server, and the error only came up when I had my PATH set to use the version 11 binaries.

Here's a transcript of the output/errors I get (the pertinent part starts after Populating the test database) --

/Users/mfedarko/Software/american-gut-web/amgut/lib/config_manager.py:34: UserWarning: Extra main section option(s) found: 'base_log_dir'
  warnings.warn("Extra %s found: %r" % (set_type, extra))
/anaconda3/envs/amgut/lib/python2.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
  """)
Creating database
Populating the test database
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 8; 2615 2200 SCHEMA public postgres
pg_restore: [archiver (db)] could not execute query: ERROR:  schema "public" already exists
    Command was: CREATE SCHEMA public;



WARNING: errors ignored on restore: 1
Traceback (most recent call last):
  File "scripts/ag", line 110, in <module>
    cli()
  File "/anaconda3/envs/amgut/lib/python2.7/site-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/anaconda3/envs/amgut/lib/python2.7/site-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/anaconda3/envs/amgut/lib/python2.7/site-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/anaconda3/envs/amgut/lib/python2.7/site-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/anaconda3/envs/amgut/lib/python2.7/site-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "scripts/ag", line 65, in make
    populate_test_db()
  File "/Users/mfedarko/Software/american-gut-web/amgut/lib/data_access/env_management.py", line 147, in populate_test_db
    (AMGUT_CONFIG.database, retcode))
RuntimeError: Could not populate test database ag_test: retcode 1

As shown at the top I got a few warnings about my system's installation of psycopg2. However, I'm pretty sure this isn't the cause of the error, since I was able to avoid the problem with non-v11 versions of Postgres.

For reference, this is on a Mac, version 10.13.6.

@wasade
Copy link
Member

wasade commented Nov 8, 2018 via email

@fedarko
Copy link
Contributor Author

fedarko commented Nov 8, 2018

Sure, that'd work! I'm not sure how trivial it'd be to solve this, so just making note of it is a good idea. I'll make a PR.

fedarko added a commit to fedarko/american-gut-web that referenced this issue Nov 8, 2018
wording might be a bit awkward -- wasn't sure how best to phrase that
it's just the version 11 binaries that seem to be the problem here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants