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

Monitor database problem with reconnection issues without changes being comitted #15

Open
paulmueller opened this issue Aug 18, 2023 · 1 comment

Comments

@paulmueller
Copy link
Member

paulmueller commented Aug 18, 2023

ckan/ckan#5953

See if this patch helped:
ckan/ckan#5953

Error message was:

Traceback (most recent call last):
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1243, in _execute_context
    self.dialect.do_execute(
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 550, in do_execute
    cursor.execute(statement, parameters)
psycopg2.errors.AdminShutdown: terminating connection due to administrator command
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/app.py", line 1947, in full_dispatch_request
    rv = self.preprocess_request()
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/app.py", line 2241, in preprocess_request
    rv = func()
  File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware/flask_app.py", line 372, in ckan_before_request
    app_globals.app_globals._check_uptodate()
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/app_globals.py", line 199, in _check_uptodate
    value = model.get_system_info('ckan.config_update')
  File "/usr/lib/ckan/default/src/ckan/ckan/model/system_info.py", line 47, in get_system_info
    obj = meta.Session.query(SystemInfo).filter_by(key=key).first()
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3222, in first
    ret = list(self[0:1])
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3012, in __getitem__
    return list(res)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3324, in __iter__
    return self._execute_and_instances(context)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3349, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 988, in execute
    return meth(self, multiparams, params)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1101, in _execute_clauseelement
    ret = self._execute_context(
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1247, in _execute_context
    self._handle_dbapi_exception(
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 399, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1243, in _execute_context
    self.dialect.do_execute(
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 550, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (psycopg2.errors.AdminShutdown) terminating connection due to administrator command
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.

[SQL: SELECT system_info.id AS system_info_id, system_info.key AS system_info_key, system_info.value AS system_info_value, system_info.state AS system_info_state 
FROM system_info 
WHERE system_info.key = %(key_1)s 
 LIMIT %(param_1)s]
[parameters: {'key_1': 'ckan.config_update', 'param_1': 1}]
(Background on this error at: http://sqlalche.me/e/e3q8)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    return handler(e)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware/flask_app.py", line 548, in error_handler
    return base.render(u'error_document_template.html', extra_vars), 500
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 151, in render
    return flask_render_template(template_name, **extra_vars)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/templating.py", line 137, in render_template
    return _render(
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
    rv = template.render(context)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/ckan/default/src/ckan/ckan/templates/error_document_template.html", line 1, in <module>
    {% extends "page.html" %}
  File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 1, in <module>
    {% extends "base.html" %}
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/ckanext/dcor_schemas/templates/base.html", line 1, in <module>
    {% ckan_extends %}
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/ckanext/dcor_theme/templates/base.html", line 1, in <module>
    {% ckan_extends %}
  File "/usr/lib/ckan/default/src/ckan/ckan/templates/base.html", line 68, in <module>
    {%- block styles %}
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/ckanext/dcor_schemas/templates/base.html", line 8, in <module>
    {% if not c.userobj.sysadmin %}
  File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/environment.py", line 430, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'werkzeug.local.LocalProxy object' has no attribute 'userobj'

@paulmueller
Copy link
Member Author

Editing the needrestart config file and setting $nrconf{restart} = 'a'; could resolve this issue which seems to be related to updates of the database libraries.

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

1 participant