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

Database initialization fails on Inventory sandbox #961

Closed
adborden opened this issue Sep 20, 2019 · 4 comments
Closed

Database initialization fails on Inventory sandbox #961

adborden opened this issue Sep 20, 2019 · 4 comments
Labels
bug Software defect or bug component/inventory Inventory playbooks/roles O&M Operations and maintenance tasks for the Data.gov platform

Comments

@adborden
Copy link
Contributor

Somehow db initialization depends on the database already being initialized.

$ sudo ckan db init
Traceback (most recent call last):
  File "/usr/bin/ckan", line 45, in <module>
    load_entry_point('PasteScript', 'console_scripts', 'paster')()
  File "/usr/lib/ckan/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
    invoke(command, command_name, options, args[1:])
  File "/usr/lib/ckan/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
    exit_code = runner.run(args)
  File "/usr/lib/ckan/lib/python2.7/site-packages/paste/script/command.py", line 236, in run
    result = self.command()
  File "/usr/lib/ckan-new/src/ckan/ckan/lib/cli.py", line 205, in command
    self._load_config(cmd!='upgrade')
  File "/usr/lib/ckan-new/src/ckan/ckan/lib/cli.py", line 147, in _load_config
    load_environment(conf.global_conf, conf.local_conf)
  File "/usr/lib/ckan-new/src/ckan/ckan/config/environment.py", line 232, in load_environment
    p.load_all(config)
  File "/usr/lib/ckan-new/src/ckan/ckan/plugins/core.py", line 124, in load_all
    unload_all()
  File "/usr/lib/ckan-new/src/ckan/ckan/plugins/core.py", line 181, in unload_all
    unload(*reversed(_PLUGINS))
  File "/usr/lib/ckan-new/src/ckan/ckan/plugins/core.py", line 209, in unload
    plugins_update()
  File "/usr/lib/ckan-new/src/ckan/ckan/plugins/core.py", line 116, in plugins_update
    environment.update_config()
  File "/usr/lib/ckan-new/src/ckan/ckan/config/environment.py", line 416, in update_config
    logic.get_action('get_site_user')({'ignore_auth': True}, None)
  File "/usr/lib/ckan-new/src/ckan/ckan/logic/__init__.py", line 416, in wrapped
    result = _action(context, data_dict, **kw)
  File "/usr/lib/ckan-new/src/ckan/ckan/logic/action/get.py", line 2450, in get_site_user
    user = model.User.get(site_id)
  File "/usr/lib/ckan-new/src/ckan/ckan/model/user.py", line 64, in get
    return query.first()
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2334, in first
    ret = list(self[0:1])
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2201, in __getitem__
    return list(res)
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2405, in __iter__
    return self._execute_and_instances(context)
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2420, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 727, in execute
    return meth(self, multiparams, params)
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 322, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 824, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 954, in _execute_context
    context)
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1116, in _handle_dbapi_exception
    exc_info
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 189, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb)
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 947, in _execute_context
    context)
  File "/usr/lib/ckan/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 435, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.DBAPIError: (UndefinedTable) relation "user" does not exist
LINE 2: FROM "user"
             ^
 'SELECT "user".password AS user_password, "user".id AS user_id, "user".name AS user_name, "user".openid AS user_openid, "user".fullname AS user_fullname, "user".email AS user_email, "user".apikey AS user_apikey, "user".created AS user_created, "user".reset_key AS user_reset_key, "user".about AS user_about, "user".activity_streams_email_notifications AS user_activity_streams_email_notifications, "user".sysadmin AS user_sysadmin, "user".state AS user_state \nFROM "user" \nWHERE "user".name = %(name_1)s OR "user".openid = %(openid_1)s OR "user".id = %(id_1)s ORDER BY "user".name \n LIMIT %(param_1)s' {'param_1': 1, 'id_1': 'central.ckan', 'name_1': 'central.ckan', 'openid_1': 'central.ckan'}

How to reproduce

  1. In a new Inventory environment, ckan db init

Expected behavior

Database is initialized.

Actual behavior

Error.

@adborden adborden added bug Software defect or bug component/inventory Inventory playbooks/roles labels Oct 7, 2019
@martinburchell
Copy link

I've seen this error when installing CKAN 2.7 as per https://docs.ckan.org/en/2.7/maintaining/installing/install-from-source.html

I upgrade psycopg2 to work around psycopg/psycopg2#489 but upgraded to 2.8.x which gives the error you reported.

Fixed by downgrading pyscopg2 to 2.7.7

@adborden adborden changed the title Database initialization fails on Inventory Database initialization fails on Inventory sandbox Feb 11, 2020
adborden added a commit to GSA/inventory-app that referenced this issue Feb 11, 2020
@adborden
Copy link
Contributor Author

Thanks @martinburchell! I've confirmed this work around is working on https://github.com/GSA/inventory-app/tree/bionic

@mogul mogul added the O&M Operations and maintenance tasks for the Data.gov platform label Apr 23, 2020
@adborden
Copy link
Contributor Author

adborden commented Dec 3, 2020

This might be fixed in CKAN 2.8

@jbrown-xentity
Copy link
Contributor

Were able to clear and re-initialize the CKAN DB for inventory on sandbox, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Software defect or bug component/inventory Inventory playbooks/roles O&M Operations and maintenance tasks for the Data.gov platform
Projects
None yet
Development

No branches or pull requests

4 participants