alerta/alerta

Postgres 15 (upgrade): Group By error causes alerta not to start if you have no heartsbeats configured

darkobas opened this issue · 3 comments

  • Database: postgres 15
web_1        | 2022-10-23 21:51:49,696 alerta.app[45]: [ERROR] non-integer constant in ORDER BY
web_1        | LINE 4:           ORDER BY (false)
web_1        |                             ^
web_1        |  request_id=ab8f0ee1-fc6b-482f-a4ba-7f43457d20f4 ip=172.18.0.1
web_1        | Traceback (most recent call last):
web_1        |   File "/venv/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
web_1        |     rv = self.dispatch_request()
web_1        |   File "/venv/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
web_1        |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
web_1        |   File "/venv/lib/python3.8/site-packages/flask_cors/decorator.py", line 128, in wrapped_function
web_1        |     resp = make_response(f(*args, **kwargs))
web_1        |   File "/venv/lib/python3.8/site-packages/alerta/auth/decorators.py", line 90, in wrapped
web_1        |     return f(*args, **kwargs)
web_1        |   File "/venv/lib/python3.8/site-packages/alerta/utils/response.py", line 18, in decorated
web_1        |     return func(*args, **kwargs)
web_1        |   File "/venv/lib/python3.8/site-packages/alerta/views/users.py", line 136, in list_users
web_1        |     users = User.find_all(query, page=paging.page, page_size=paging.page_size)
web_1        |   File "/venv/lib/python3.8/site-packages/alerta/models/user.py", line 164, in find_all
web_1        |     return [User.from_db(user) for user in db.get_users(query, page, page_size)]
web_1        |   File "/venv/lib/python3.8/site-packages/alerta/database/backends/postgres/base.py", line 1070, in get_users
web_1        |     return self._fetchall(select, query.vars, limit=page_size, offset=(page - 1) * page_size)
web_1        |   File "/venv/lib/python3.8/site-packages/alerta/database/backends/postgres/base.py", line 1595, in _fetchall
web_1        |     cursor.execute(query, vars)
web_1        |   File "/venv/lib/python3.8/site-packages/psycopg2/extras.py", line 312, in execute
web_1        |     return super().execute(query, vars)
web_1        | psycopg2.errors.SyntaxError: non-integer constant in ORDER BY
web_1        | LINE 4:           ORDER BY (false)
web_1        |                             ^

Got the same issue with other queries, it's because the order by (false) (default for query object) is not supported by postgreSQL 15
You can find the line there : utils
Most of the web ui pannels are not working because of that : Can't see customers (full list or inside filters), users, API keys,...

image

Looks like there's a breaking change in Postgres 15. This needs to be fixed but in the meantime assume Alerta only supports up to Postgres 14. The next release will have support.

This is now fixed so that Alerta supports Postgres 15.