SQL Lab queries fails intermittently when running in Async mode.
Make sure these boxes are checked before submitting your issue - thank you!
- [X] I have checked the superset logs for python stacktraces and included it here as text if any
- [X] I have reproduced the issue with at least the latest release
- [X] I have checked the issue tracker for the same issue and I haven't found one similar
I'm trying to run query in async mode using celery and redis. Using Postgress DB which is running in Webserver. Few query runs fast and give results.But query goes into pending state for long time and then i get the below error in worker. The issue is intermittent. :
[2017-11-30 08:36:31,897: ERROR/ForkPoolWorker-3] Query with id `179` could not be retrieved
[2017-11-30 08:36:31,897: ERROR/ForkPoolWorker-3] Sleeping for a sec before retrying...
[2017-11-30 08:36:32,901: ERROR/ForkPoolWorker-3] Query with id `179` could not be retrieved
[2017-11-30 08:36:32,901: ERROR/ForkPoolWorker-3] Sleeping for a sec before retrying...
[2017-11-30 08:36:33,904: ERROR/ForkPoolWorker-3] Query with id `179` could not be retrieved
[2017-11-30 08:36:33,904: ERROR/ForkPoolWorker-3] Sleeping for a sec before retrying...
[2017-11-30 08:36:34,907: ERROR/ForkPoolWorker-3] Query with id `179` could not be retrieved
[2017-11-30 08:36:34,908: ERROR/ForkPoolWorker-3] Sleeping for a sec before retrying...
[2017-11-30 08:36:35,911: ERROR/ForkPoolWorker-3] Query with id `179` could not be retrieved
[2017-11-30 08:36:35,912: ERROR/ForkPoolWorker-3] Sleeping for a sec before retrying...
[2017-11-30 08:36:36,915: ERROR/ForkPoolWorker-3] Task superset.sql_lab.get_sql_results[b51234ae-fed3-4d5e-af80-d12d20123ef6] raised unexpected: SqlLabException('Failed at getting query',)
Traceback (most recent call last):
File "/home/ec2-user/superset/lib/python2.7/dist-packages/celery/app/trace.py", line 374, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/ec2-user/superset/lib/python2.7/dist-packages/celery/app/trace.py", line 629, in __protected_call__
return self.run(*args, **kwargs)
File "/home/ec2-user/superset/local/lib/python2.7/site-packages/superset/sql_lab.py", line 96, in get_sql_results
query = get_query(query_id, sesh)
File "/home/ec2-user/superset/local/lib/python2.7/site-packages/superset/sql_lab.py", line 68, in get_query
raise SqlLabException("Failed at getting query")
SqlLabException: Failed at getting query
config_file in web server
class CeleryConfig(object):
BROKER_URL = 'redis://xyz.cache.amazonaws.comcache.amazonaws.com:6379/0'
CELERY_IMPORTS = ('superset.sql_lab', )
CELERY_RESULT_BACKEND = 'redis://xyz.cache.amazonaws.com.cache.amazonaws.com:6379/0'
CELERY_ANNOTATIONS = {'tasks.add': {'rate_limit': '10/s'}}
CELERY_CONFIG = CeleryConfig
from werkzeug.contrib.cache import RedisCache
RESULTS_BACKEND = RedisCache(
host='xyz.cache.amazonaws.com', port=6379, key_prefix='superset_results')
SQLALCHEMY_DATABASE_URI = 'postgresql://user:password@localhost/myapp'
config file in worker server
class CeleryConfig(object):
BROKER_URL = 'redis://xyz.cache.amazonaws.comcache.amazonaws.com:6379/0'
CELERY_IMPORTS = ('superset.sql_lab', )
CELERY_RESULT_BACKEND = 'redis://xyz.cache.amazonaws.com.cache.amazonaws.com:6379/0'
CELERY_ANNOTATIONS = {'tasks.add': {'rate_limit': '10/s'}}
CELERY_CONFIG = CeleryConfig
from werkzeug.contrib.cache import RedisCache
RESULTS_BACKEND = RedisCache(
host='xyz.cache.amazonaws.com', port=6379, key_prefix='superset_results')
SQLALCHEMY_DATABASE_URI = 'postgresql://user:password@<webserver_ip>:5432/myapp'
Superset version
0.20.1
Expected results
Queries should not fail
Actual results
Queries goes into "pending" status for long time and then fails. Intermittent issue
Steps to reproduce
Maybe a zombie web worker pointing to another database? Does query with id 179 exist on the db? If not then it seems to point to a faulty web worker, if it is there then it seems to point to a faulty worker.
I checked the database, query id 179 exist. In the worker, i suspected it is connecting to local postgres DB, so i stopped the postgress DB in worker, to check whether it connects to the main central DB running in web server. I get the below error now
[2017-12-01 02:25:18,848: ERROR/ForkPoolWorker-2] local variable 'conn' referenced before assignment
Traceback (most recent call last):
File "/home/ec2-user/superset/local/lib/python2.7/site-packages/superset/sql_lab.py", line 91, in get_sql_results
ctask, query_id, return_results, store_results)
File "/home/ec2-user/superset/local/lib/python2.7/site-packages/superset/sql_lab.py", line 193, in execute_sql
conn.close()
UnboundLocalError: local variable 'conn' referenced before assignment
[2017-12-01 02:25:42,967: ERROR/ForkPoolWorker-3] (psycopg2.OperationalError) could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
Traceback (most recent call last):
File "/home/ec2-user/superset/local/lib/python2.7/site-packages/superset/sql_lab.py", line 175, in execute_sql
conn = engine.raw_connection()
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2177, in raw_connection
self.pool.unique_connection, _connection)
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2151, in _wrap_pool_connect
e, dialect, self)
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1465, in _handle_dbapi_exception_noconnection
exc_info
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2147, in _wrap_pool_connect
return fn()
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 328, in unique_connection
return _ConnectionFairy._checkout(self)
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 766, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 516, in checkout
rec = pool._do_get()
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 1229, in _do_get
return self._create_connection()
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 333, in _create_connection
return _ConnectionRecord(self)
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 461, in __init__
self.__connect(first_connect_check=True)
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 651, in __connect
connection = pool._invoke_creator(self)
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 105, in connect
return dialect.connect(*cargs, **cparams)
File "/home/ec2-user/superset/local/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 393, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/home/ec2-user/superset/lib/python2.7/dist-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
I have cross checked the config file in worker, it has the line
SQLALCHEMY_DATABASE_URI = 'postgresql://user:password@<webserver_ip>:5432/myapp'
And also connection between the two servers works fine.
same problem here...
@guillaumewibaux @jkakh do you have postgres and celery on the same machine?
Works but with erros:
2018-12-21 13:44:13,480:ERROR:flask_appbuilder.security.sqla.manager:DB Creation and initialization failed: (psycopg2.OperationalError) could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
(Background on this error at: http://sqlalche.me/e/e3q8)
Setting up admin user admin.
Loaded your LOCAL configuration at [/app/superset_config.py]
Recognized Database Authentications.
Admin User admin created.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Sorry for disturbing a closed issue, I have the same problem as well... It occurs when I use the 'CTAS' function in superset sql lab. Does anybody has the solution..?
my celery worker throws this error:
[2019-08-02 09:47:00,417: ERROR/ForkPoolWorker-1] Query with id `202` could not be retrieved
[2019-08-02 09:47:00,419: ERROR/ForkPoolWorker-1] Sleeping for a sec before retrying...
[2019-08-02 09:47:01,424: ERROR/ForkPoolWorker-1] Query with id `202` could not be retrieved
[2019-08-02 09:47:01,424: ERROR/ForkPoolWorker-1] Sleeping for a sec before retrying...
[2019-08-02 09:47:02,429: ERROR/ForkPoolWorker-1] Query with id `202` could not be retrieved
[2019-08-02 09:47:02,429: ERROR/ForkPoolWorker-1] Sleeping for a sec before retrying...
[2019-08-02 09:47:03,433: ERROR/ForkPoolWorker-1] Query with id `202` could not be retrieved
[2019-08-02 09:47:03,434: ERROR/ForkPoolWorker-1] Sleeping for a sec before retrying...
[2019-08-02 09:47:04,440: ERROR/ForkPoolWorker-1] Query with id `202` could not be retrieved
[2019-08-02 09:47:04,440: ERROR/ForkPoolWorker-1] Sleeping for a sec before retrying...
[2019-08-02 09:47:05,442: ERROR/ForkPoolWorker-1] Failed at getting query
Traceback (most recent call last):
File "/root/incubator-superset/superset/sql_lab.py", line 136, in get_sql_results
session=session, start_time=start_time)
File "/root/incubator-superset/superset/sql_lab.py", line 224, in execute_sql_statements
query = get_query(query_id, session)
File "/root/incubator-superset/superset/sql_lab.py", line 96, in get_query
raise SqlLabException('Failed at getting query')
superset.sql_lab.SqlLabException: Failed at getting query
[2019-08-02 09:47:05,455: ERROR/ForkPoolWorker-1] Query with id `202` could not be retrieved
[2019-08-02 09:47:05,456: ERROR/ForkPoolWorker-1] Sleeping for a sec before retrying...
[2019-08-02 09:47:06,461: ERROR/ForkPoolWorker-1] Query with id `202` could not be retrieved
[2019-08-02 09:47:06,462: ERROR/ForkPoolWorker-1] Sleeping for a sec before retrying...
[2019-08-02 09:47:07,467: ERROR/ForkPoolWorker-1] Query with id `202` could not be retrieved
[2019-08-02 09:47:07,467: ERROR/ForkPoolWorker-1] Sleeping for a sec before retrying...
[2019-08-02 09:47:08,472: ERROR/ForkPoolWorker-1] Query with id `202` could not be retrieved
[2019-08-02 09:47:08,473: ERROR/ForkPoolWorker-1] Sleeping for a sec before retrying...
[2019-08-02 09:47:09,477: ERROR/ForkPoolWorker-1] Query with id `202` could not be retrieved
[2019-08-02 09:47:09,478: ERROR/ForkPoolWorker-1] Sleeping for a sec before retrying...
[2019-08-02 09:47:10,482: ERROR/ForkPoolWorker-1] Failed at getting query
Traceback (most recent call last):
File "/root/incubator-superset/superset/sql_lab.py", line 136, in get_sql_results
session=session, start_time=start_time)
File "/root/incubator-superset/superset/sql_lab.py", line 224, in execute_sql_statements
query = get_query(query_id, session)
File "/root/incubator-superset/superset/sql_lab.py", line 96, in get_query
raise SqlLabException('Failed at getting query')
superset.sql_lab.SqlLabException: Failed at getting query
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/incubator-superset/superset/sql_lab.py", line 114, in session_scope
yield session
File "/root/incubator-superset/superset/sql_lab.py", line 140, in get_sql_results
query = get_query(query_id, session)
File "/root/incubator-superset/superset/sql_lab.py", line 96, in get_query
raise SqlLabException('Failed at getting query')
superset.sql_lab.SqlLabException: Failed at getting query
[2019-08-02 09:47:10,504: ERROR/ForkPoolWorker-1] Task superset.sql_lab.get_sql_results[cb5c14c2-0c78-4ee2-8e00-b8c68f559f0e] raised unexpected: SqlLabException('Failed at getting query',)
Traceback (most recent call last):
File "/root/incubator-superset/superset/sql_lab.py", line 136, in get_sql_results
session=session, start_time=start_time)
File "/root/incubator-superset/superset/sql_lab.py", line 224, in execute_sql_statements
query = get_query(query_id, session)
File "/root/incubator-superset/superset/sql_lab.py", line 96, in get_query
raise SqlLabException('Failed at getting query')
superset.sql_lab.SqlLabException: Failed at getting query
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/celery/app/trace.py", line 385, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/celery/app/trace.py", line 648, in __protected_call__
return self.run(*args, **kwargs)
File "/root/incubator-superset/superset/sql_lab.py", line 140, in get_sql_results
query = get_query(query_id, session)
File "/root/incubator-superset/superset/sql_lab.py", line 96, in get_query
raise SqlLabException('Failed at getting query')
superset.sql_lab.SqlLabException: Failed at getting query
I quite new with superset, anyhelp is appreciated...