An error occurs Redash Docker on startup

Hi,

When I started Redash docker-compose up:

PostgreSQL Database directory appears to contain a database; Skipping initialization
redash-master-postgres-1   | 
redash-master-postgres-1   | LOG:  database system was shut down at 2022-06-09 14:29:51 UTC
redash-master-postgres-1   | LOG:  MultiXact member wraparound protections are now enabled
redash-master-postgres-1   | LOG:  database system is ready to accept connections
redash-master-postgres-1   | LOG:  autovacuum launcher started
redash-master-email-1      | MailDev webapp running at http://0.0.0.0:80
redash-master-email-1      | MailDev SMTP Server running at 0.0.0.0:25
redash-master-worker-1     | Starting dev RQ worker...
redash-master-scheduler-1  | Starting dev RQ scheduler...
redash-master-server-1     | Traceback (most recent call last):
redash-master-server-1     |   File "/app/manage.py", line 6, in <module>
redash-master-server-1     |     from redash.cli import manager
redash-master-server-1     |   File "/app/redash/__init__.py", line 56, in <module>
redash-master-server-1     |     import_query_runners(settings.QUERY_RUNNERS)
redash-master-server-1     |   File "/app/redash/query_runner/__init__.py", line 438, in import_query_runners
redash-master-server-1     |     __import__(runner_import)
redash-master-server-1     |   File "/app/redash/query_runner/big_query.py", line 17, in <module>
redash-master-server-1     |     import apiclient.errors
redash-master-server-1     |   File "/usr/local/lib/python3.7/site-packages/apiclient/__init__.py", line 8, in <module>
redash-master-server-1     |     from googleapiclient import discovery
redash-master-server-1     |   File "/usr/local/lib/python3.7/site-packages/googleapiclient/discovery.py", line 56, in <module>
redash-master-server-1     |     from googleapiclient import _auth
redash-master-server-1     |   File "/usr/local/lib/python3.7/site-packages/googleapiclient/_auth.py", line 33, in <module>
redash-master-server-1     |     import oauth2client.client
redash-master-server-1     |   File "/usr/local/lib/python3.7/site-packages/oauth2client/client.py", line 45, in <module>
redash-master-server-1     |     from oauth2client import crypt
redash-master-server-1     |   File "/usr/local/lib/python3.7/site-packages/oauth2client/crypt.py", line 55, in <module>
redash-master-server-1     |     from oauth2client import _pycrypto_crypt
redash-master-server-1     |   File "/usr/local/lib/python3.7/site-packages/oauth2client/_pycrypto_crypt.py", line 17, in <module>
redash-master-server-1     |     from Crypto.PublicKey import RSA
redash-master-server-1     |   File "/usr/local/lib/python3.7/site-packages/Crypto/PublicKey/RSA.py", line 585
redash-master-server-1     |     except ValueError, IndexError:
redash-master-server-1     |                      ^
redash-master-server-1     | SyntaxError: invalid syntax
redash-master-server-1 exited with code 1

Please help!!!

How did you set up Redash? This looks like a Python version mis-match. Which should not happen if you’ve followed the instructions in our documentation.

Hey, jesse.
We installed python in Dockerfile with this command:

FROM --platform=linux/amd64 python:3.7-slim-buster

Redash generally runs with docker compose. Which compose file did you use?

We used docker-compose file from your github page - redash/docker-compose.yml at master · getredash/redash · GitHub

On what target system does this run? A windows machine? macos?

No, it’s CentOS7. Follwing your guide here https://redash.io/help/open-source/dev-guide/docker we faced this pycrypto problem after docker-compose up command.

This looks like an incompatibility between a pinned query runner dependency and your centos installation. Do you know which target databases you hope to query? Such as postgres, mysql etc? If so, I would specify these directly using the enabled_query_runners environment variable. This will prevent Redash trying to load dependencies for query runners you don’t intend to use.

Otherwise you can search here on the forum for centos user posts. There are some eccentricities to centos that have been covered in the past.

We use postgres. Do you mean switch redash to on-prem postgres instead of docker container?

No no no no no. No not at all.

I’ll try to explain:

As Redash starts, it looks at a setting to know which query runners to enable. Then it loops through the enabled runners and loads their Python dependencies. If a Python ImportError is raised while dependencies are loaded, that query runner is skipped and a log message is emitted. But the process won’t crash, it just skips that query runner and moves along.

However, if a different exception is raised than ImportError this may signal bigger issues with the environment, so non-ImportError exceptions are not explicitly caught and will cause the startup to fail.

Your log messages indicate that startup fails during execution of the line:

import_query_runners(settings.QUERY_RUNNERS)

And specifically it fails to load dependencies for big_query. The specific dependency that fails is pycrypto. Because of this there are a few ways to debug / correct:

[Preferred Option] Figure out why pycrypto won’t load.

I’m guessing this is a CentOS specific issue (context).Once you fix pycrypto for centos then try starting Redash again. This is the preferred option since pycrypto is very widely used across Redash. I believe it is required for the postgres query runner as well, although I’m not sure. I’m away from my system presently so it’s not something I can check.

[Workaround 1] Explicitly stop Redash from trying to load dependencies for big query (BQ) using environment variables.

The one you’d use to disable big query alone is

export REDASH_DISABLED_QUERY_RUNNERS="query_runner.big_query"

[Workaround 2] Tell Redash to only load dependencies for data sources you know you’ll use

If you’re only going to connect with postgres then you can use

export REDASH_ENABLED_QUERY_RUNNERS="query_runner.pg"

Note that neither workaround will fix this problem if the postgres query runner or one of its dependencies relies on pycrypto. Given there are references in google and stack overflow to special setup instructions with pycrypto on centos, I’d advise fixing the root of the issue.

Got it. Give me some time to check it out.

I’ve restarted everything from the scratch and error dessapeared as it always happens… Right now can’t reach redash master web pache after port changing from 5000 to 8088.

Here is new error after docker-compose up command:

redash-master-postgres-1   | ERROR:  relation "query_results" does not exist at character 13
redash-master-postgres-1   | STATEMENT:  DELETE FROM query_results WHERE query_results.id IN (SELECT query_results.id
redash-master-postgres-1   |    FROM query_results LEFT OUTER JOIN queries ON query_results.id = queries.latest_query_data_id
redash-master-postgres-1   |    WHERE queries.id IS NULL AND query_results.retrieved_at < '2022-06-09T14:53:40.363540'::timestamp
redash-master-postgres-1   |     LIMIT 100)
redash-master-worker-1     | [2022-06-16 14:53:40,399][PID:54][ERROR][rq.worker] sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "query_results" does not exist
redash-master-worker-1     | LINE 1: DELETE FROM query_results WHERE query_results.id IN (SELECT ...
redash-master-worker-1     |                     ^
redash-master-worker-1     |
redash-master-worker-1     | [SQL: DELETE FROM query_results WHERE query_results.id IN (SELECT query_results.id
redash-master-worker-1     | FROM query_results LEFT OUTER JOIN queries ON query_results.id = queries.latest_query_data_id
redash-master-worker-1     | WHERE queries.id IS NULL AND query_results.retrieved_at < %(retrieved_at_1)s
redash-master-worker-1     |  LIMIT %(param_1)s)]
redash-master-worker-1     | [parameters: {'retrieved_at_1': datetime.datetime(2022, 6, 9, 14, 53, 40, 363540), 'param_1': 100}]
redash-master-worker-1     | (Background on this error at: http://sqlalche.me/e/f405)
redash-master-worker-1     | Traceback (most recent call last):
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context
redash-master-worker-1     |     cursor, statement, parameters, context
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute
redash-master-worker-1     |     cursor.execute(statement, parameters)
redash-master-worker-1     | psycopg2.errors.UndefinedTable: relation "query_results" does not exist
redash-master-worker-1     | LINE 1: DELETE FROM query_results WHERE query_results.id IN (SELECT ...
redash-master-worker-1     |                     ^
redash-master-worker-1     |
redash-master-worker-1     |
redash-master-worker-1     | The above exception was the direct cause of the following exception:
redash-master-worker-1     |
redash-master-worker-1     | Traceback (most recent call last):
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/rq/worker.py", line 934, in perform_job
redash-master-worker-1     |     rv = job.perform()
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 686, in perform
redash-master-worker-1     |     self._result = self._execute()
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 692, in _execute
redash-master-worker-1     |     return self.func(*self.args, **self.kwargs)
redash-master-worker-1     |   File "/app/redash/tasks/queries/maintenance.py", line 142, in cleanup_query_results
redash-master-worker-1     |     ).delete(synchronize_session=False)
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3727, in delete
redash-master-worker-1     |     delete_op.exec_()
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1693, in exec_
redash-master-worker-1     |     self._do_exec()
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1921, in _do_exec
redash-master-worker-1     |     self._execute_stmt(delete_stmt)
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1698, in _execute_stmt
redash-master-worker-1     |     self.result = self.query._execute_crud(stmt, self.mapper)
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3375, in _execute_crud
redash-master-worker-1     |     return conn.execute(stmt, self._params)
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute
redash-master-worker-1     |     return meth(self, multiparams, params)
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
redash-master-worker-1     |     return connection._execute_clauseelement(self, multiparams, params)
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
redash-master-worker-1     |     distilled_params,
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context
redash-master-worker-1     |     e, statement, parameters, cursor, context
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception
redash-master-worker-1     |     util.raise_from_cause(sqlalchemy_exception, exc_info)
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause
redash-master-worker-1     |     reraise(type(exception), exception, tb=exc_tb, cause=cause)
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise
redash-master-worker-1     |     raise value.with_traceback(tb)
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context
redash-master-worker-1     |     cursor, statement, parameters, context
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute
redash-master-worker-1     |     cursor.execute(statement, parameters)
redash-master-worker-1     | sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "query_results" does not exist
redash-master-worker-1     | LINE 1: DELETE FROM query_results WHERE query_results.id IN (SELECT ...

Looks like you didn’t set up your metadata database.

docker-compose run --rm server create_db

It’s strange cause I had to run this command twice to pass this error.
So for now I have following output after docker-compose up command.

[+] Running 6/6
 ⠿ Container redash-master-email-1      Created                                                                                                                                                           0.0s
 ⠿ Container redash-master-redis-1      Running                                                                                                                                                           0.0s
 ⠿ Container redash-master-postgres-1   Running                                                                                                                                                           0.0s
 ⠿ Container redash-master-server-1     Created                                                                                                                                                           0.0s
 ⠿ Container redash-master-worker-1     Created                                                                                                                                                           0.0s
 ⠿ Container redash-master-scheduler-1  Created                                                                                                                                                           0.0s
Attaching to redash-master-email-1, redash-master-postgres-1, redash-master-redis-1, redash-master-scheduler-1, redash-master-server-1, redash-master-worker-1
redash-master-email-1      | MailDev webapp running at http://0.0.0.0:80
redash-master-email-1      | MailDev SMTP Server running at 0.0.0.0:25
redash-master-scheduler-1  | Starting dev RQ scheduler...
redash-master-worker-1     | Starting dev RQ worker...
redash-master-server-1     |  * Environment: production
redash-master-server-1     |    WARNING: This is a development server. Do not use it in a production deployment.
redash-master-server-1     |    Use a production WSGI server instead.
redash-master-server-1     |  * Debug mode: on
redash-master-server-1     | [2022-06-16 19:34:55,341][PID:1][INFO][werkzeug]  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
redash-master-server-1     | [2022-06-16 19:34:55,382][PID:1][INFO][werkzeug]  * Restarting with inotify reloader
redash-master-worker-1     | [2022-06-16 19:34:56,163][PID:8][INFO][rq.worker] Worker rq:worker:7c49c19d7f9d450686848352ce2f7bbe: started, version 1.5.0
redash-master-worker-1     | [2022-06-16 19:34:56,164][PID:8][INFO][rq.worker] *** Listening on periodic, emails, default, scheduled_queries, queries, schemas...
redash-master-worker-1     | [2022-06-16 19:34:56,164][PID:8][INFO][rq.worker] Cleaning registries for queue: periodic
redash-master-worker-1     | [2022-06-16 19:34:56,165][PID:8][INFO][rq.worker] Cleaning registries for queue: emails
redash-master-worker-1     | [2022-06-16 19:34:56,166][PID:8][INFO][rq.worker] Cleaning registries for queue: default
redash-master-worker-1     | [2022-06-16 19:34:56,167][PID:8][INFO][rq.worker] Cleaning registries for queue: scheduled_queries
redash-master-worker-1     | [2022-06-16 19:34:56,168][PID:8][INFO][rq.worker] Cleaning registries for queue: queries
redash-master-worker-1     | [2022-06-16 19:34:56,169][PID:8][INFO][rq.worker] Cleaning registries for queue: schemas
redash-master-scheduler-1  | [2022-06-16 19:34:56,196][PID:8][INFO][redash.tasks.schedule] Scheduling 305c0cae0a196ae96915fd2b6f81001c435aad65 (refresh_queries) with interval 30.
redash-master-scheduler-1  | [2022-06-16 19:34:56,197][PID:8][INFO][redash.tasks.schedule] Scheduling 59a84668e68687338646f735965213c58e814b32 (remove_ghost_locks) with interval 60.
redash-master-scheduler-1  | [2022-06-16 19:34:56,198][PID:8][INFO][redash.tasks.schedule] Scheduling 75540cdf868e7873f5eec072177423b13b98dece (empty_schedules) with interval 3600.
redash-master-scheduler-1  | [2022-06-16 19:34:56,199][PID:8][INFO][redash.tasks.schedule] Scheduling 52bcd40c254552539398db3cdb15055d4a9a536a (refresh_schemas) with interval 1800.
redash-master-scheduler-1  | [2022-06-16 19:34:56,200][PID:8][INFO][redash.tasks.schedule] Scheduling 18281a865ed3d1a60f366aeb8596fe2283aa421f (sync_user_details) with interval 60.
redash-master-scheduler-1  | [2022-06-16 19:34:56,200][PID:8][INFO][redash.tasks.schedule] Scheduling 797f4f959c6c96c738efd445b17db75742db80a9 (send_aggregated_errors) with interval 3600.
redash-master-scheduler-1  | [2022-06-16 19:34:56,201][PID:8][INFO][redash.tasks.schedule] Scheduling 526f2c7f55dfe92457914cd7df02cfffe4dec877 (version_check) with interval 86400.
redash-master-scheduler-1  | [2022-06-16 19:34:56,202][PID:8][INFO][redash.tasks.schedule] Scheduling e27209059575fcc17c527c47d0957cb21756e551 (cleanup_query_results) with interval 300.
redash-master-scheduler-1  | [2022-06-16 19:34:56,203][PID:8][INFO][rq_scheduler.scheduler] Registering birth
redash-master-worker-1     | [2022-06-16 19:34:56,207][PID:8][INFO][rq.worker] periodic: 18281a865ed3d1a60f366aeb8596fe2283aa421f
redash-master-worker-1     | [2022-06-16 19:34:56,227][PID:47][INFO][rq.worker] periodic: Job OK (18281a865ed3d1a60f366aeb8596fe2283aa421f)
redash-master-worker-1     | [2022-06-16 19:34:56,228][PID:47][INFO][rq.worker] Result is kept for 600 seconds
redash-master-worker-1     | [2022-06-16 19:34:56,237][PID:8][INFO][rq.worker] periodic: 305c0cae0a196ae96915fd2b6f81001c435aad65
redash-master-worker-1     | [2022-06-16 19:34:56,247][PID:48][INFO][rq.job.redash.tasks.queries.maintenance] job.func_name=redash.tasks.queries.maintenance.refresh_queries job.id=305c0cae0a196ae96915fd2b6f81001c435aad65 Refreshing queries...
redash-master-worker-1     | [2022-06-16 19:34:56,283][PID:48][INFO][rq.job.redash.tasks.queries.maintenance] job.func_name=redash.tasks.queries.maintenance.refresh_queries job.id=305c0cae0a196ae96915fd2b6f81001c435aad65 Done refreshing queries: {'outdated_queries_count': 0, 'last_refresh_at': 1655408096.2826107, 'query_ids': '[]'}
redash-master-worker-1     | [2022-06-16 19:34:56,286][PID:48][INFO][rq.worker] periodic: Job OK (305c0cae0a196ae96915fd2b6f81001c435aad65)
redash-master-worker-1     | [2022-06-16 19:34:56,286][PID:48][INFO][rq.worker] Result is kept for 600 seconds
redash-master-postgres-1   | LOG:  unexpected EOF on client connection with an open transaction
redash-master-worker-1     | [2022-06-16 19:34:56,300][PID:8][INFO][rq.worker] periodic: 526f2c7f55dfe92457914cd7df02cfffe4dec877
redash-master-worker-1     | [2022-06-16 19:34:56,314][PID:49][INFO][root] Performing version check.
redash-master-worker-1     | [2022-06-16 19:34:56,314][PID:49][INFO][root] Current version: 11.0.0-dev
redash-master-worker-1     | [2022-06-16 19:34:56,347][PID:49][ERROR][rq.worker] AttributeError: 'NoneType' object has no attribute 'get_setting'
redash-master-worker-1     | Traceback (most recent call last):
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/rq/worker.py", line 934, in perform_job
redash-master-worker-1     |     rv = job.perform()
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 686, in perform
redash-master-worker-1     |     self._result = self._execute()
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 692, in _execute
redash-master-worker-1     |     return self.func(*self.args, **self.kwargs)
redash-master-worker-1     |   File "/app/redash/tasks/general.py", line 35, in version_check
redash-master-worker-1     |     run_version_check()
redash-master-worker-1     |   File "/app/redash/version_check.py", line 75, in run_version_check
redash-master-worker-1     |     if Organization.query.first().get_setting("beacon_consent"):
redash-master-worker-1     | AttributeError: 'NoneType' object has no attribute 'get_setting'
redash-master-worker-1     | Traceback (most recent call last):
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/rq/worker.py", line 934, in perform_job
redash-master-worker-1     |     rv = job.perform()
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 686, in perform
redash-master-worker-1     |     self._result = self._execute()
redash-master-worker-1     |   File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 692, in _execute
redash-master-worker-1     |     return self.func(*self.args, **self.kwargs)
redash-master-worker-1     |   File "/app/redash/tasks/general.py", line 35, in version_check
redash-master-worker-1     |     run_version_check()
redash-master-worker-1     |   File "/app/redash/version_check.py", line 75, in run_version_check
redash-master-worker-1     |     if Organization.query.first().get_setting("beacon_consent"):
redash-master-worker-1     | AttributeError: 'NoneType' object has no attribute 'get_setting'
redash-master-postgres-1   | LOG:  unexpected EOF on client connection with an open transaction

Boy you are just plagued with odd issues I’ve never seen before. It looks like you were not shown an onboarding screen to create an organisation. Does anything load in your browser?

What exact steps have you followed so far? It’s not enough to point to the doc page because collectively these instructions are followed dozens-hundreds of times per month and don’t produce these issues. I believe there must be an environment issue on your box, potentially related to Centos but it’s hard to say.

Okay, I got your pretty straight answer. I’ll try to make it on my own.

Can you confirm whether anything has loaded in your browser yet?

Finally I switched ports and can reach redash web setup page. It failes with other errors related to yarn as I can guess.

FileNotFoundError: [Errno 2] No such file or directory: '/app/redash/settings/../../client/dist/index.html'

Looks like it had been solving by you a years go. Give me some time to check evertying out.

That error means you didn’t build the front-end assets. To do this you need to run yarn build. Then try again and it should load.