superset icon indicating copy to clipboard operation
superset copied to clipboard

Run Async in SQL Lab is not working (socket error)

Open gwthm-in opened this issue 10 years ago • 12 comments

Make sure these boxes are checked before submitting your issue - thank you!

  • [Yes] I have checked the superset logs for python stacktraces and included it here as text if any
  • [Yes] I have reproduced the issue with at least the latest released version of superset
  • [Yes] I have checked the issue tracker for the same issue and I haven't found one similar

Superset version - 0.14.1

Expected results

Should run the query in Async mode and show result.

Actual results

Exception -

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2000, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1991, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1567, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/dist-packages/flask_appbuilder/security/decorators.py", line 52, in wraps
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/superset/models.py", line 2279, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/superset/views.py", line 2373, in sql_json
    store_results=not query.select_as_cta)
  File "/usr/local/lib/python2.7/dist-packages/celery/app/task.py", line 453, in delay
    return self.apply_async(args, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/app/task.py", line 565, in apply_async
    **dict(self._get_exec_options(), **options)
  File "/usr/local/lib/python2.7/dist-packages/celery/app/base.py", line 354, in send_task
    reply_to=reply_to or self.oid, **options
  File "/usr/local/lib/python2.7/dist-packages/celery/app/amqp.py", line 310, in publish_task
    **kwargs
  File "/usr/local/lib/python2.7/dist-packages/kombu/messaging.py", line 172, in publish
    routing_key, mandatory, immediate, exchange, declare)
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 470, in _ensured
    interval_max)
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 382, in ensure_connection
    interval_start, interval_step, interval_max, callback)
  File "/usr/local/lib/python2.7/dist-packages/kombu/utils/__init__.py", line 246, in retry_over_time
    return fun(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 250, in connect
    return self.connection
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 756, in connection
    self._connection = self._establish_connection()
  File "/usr/local/lib/python2.7/dist-packages/kombu/connection.py", line 711, in _establish_connection
    conn = self.transport.establish_connection()
  File "/usr/local/lib/python2.7/dist-packages/kombu/transport/pyamqp.py", line 116, in establish_connection
    conn = self.Connection(**opts)
  File "/usr/local/lib/python2.7/dist-packages/amqp/connection.py", line 165, in __init__
    self.transport = self.Transport(host, connect_timeout, ssl)
  File "/usr/local/lib/python2.7/dist-packages/amqp/connection.py", line 186, in Transport
    return create_transport(host, connect_timeout, ssl)
  File "/usr/local/lib/python2.7/dist-packages/amqp/transport.py", line 299, in create_transport
    return TCPTransport(host, connect_timeout)
  File "/usr/local/lib/python2.7/dist-packages/amqp/transport.py", line 95, in __init__
    raise socket.error(last_err)
error: [Errno 111] Connection refused

Steps to reproduce

Type any proper query in sql lab and click on Run Async

gwthm-in avatar Dec 02 '16 12:12 gwthm-in

Looks like your broker isn't up or configured properly

mistercrunch avatar Dec 02 '16 14:12 mistercrunch

Hi @mistercrunch,

I configured broker which eliminated the above mentioned error.

But even though async is not giving any results. It's keep rendering. I guess, the problem is the following line.

config.py file

results_backend = None

Could you please share some info how to set this results_backend ?

This is my CeleryConfig.

class CeleryConfig(object): BROKER_URL = 'redis://localhost:6379/' CELERY_IMPORTS = ('superset.sql_lab', ) CELERY_RESULT_BACKEND = 'redis://localhost:6379/' CELERY_ANNOTATIONS = {'tasks.add': {'rate_limit': '10/s'}} CELERY_CONFIG = CeleryConfig

gwthm-in avatar Dec 02 '16 15:12 gwthm-in

@mistercrunch

Do I need to start celery workers? I'm getting the following error when starting them using

celery worker -A superset

Traceback (most recent call last): File "/usr/local/bin/celery", line 11, in sys.exit(main()) File "/usr/local/lib/python2.7/dist-packages/celery/main.py", line 14, in main _main() File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 326, in main cmd.execute_from_commandline(argv) File "/usr/local/lib/python2.7/dist-packages/celery/bin/celery.py", line 488, in execute_from_commandline super(CeleryCommand, self).execute_from_commandline(argv))) File "/usr/local/lib/python2.7/dist-packages/celery/bin/base.py", line 276, in execute_from_commandline argv = self.setup_app_from_commandline(argv) File "/usr/local/lib/python2.7/dist-packages/celery/bin/base.py", line 486, in setup_app_from_commandline self._handle_user_preload_options(argv) File "/usr/local/lib/python2.7/dist-packages/celery/bin/base.py", line 491, in _handle_user_preload_options user_preload = tuple(self.app.user_options['preload'] or ()) AttributeError: 'Flask' object has no attribute 'user_options'

gwthm-in avatar Dec 03 '16 10:12 gwthm-in

Finally I'm able to start it up and running. But getting error when storing because reuslts_backend is none in config file.

@mistercrunch

Can you please help how to setup results_backend?

And if I want to help you by documenting all this. Where can I document it?

gwthm-in avatar Dec 03 '16 10:12 gwthm-in

@Gowtham95india please feel free to submit a PR with updated documentation! https://github.com/airbnb/superset/tree/master/docs

ascott avatar Dec 05 '16 18:12 ascott

@Gowtham95india I've run into this same exact issue, can you share details about how this was resolved? Documentation in a comment is better than none at all.

acmiyaguchi avatar Mar 03 '17 21:03 acmiyaguchi

Here's where it would go in the docs: https://github.com/airbnb/superset/blob/master/docs/installation.rst

mistercrunch avatar Mar 03 '17 22:03 mistercrunch

Note that you should run superset worker

mistercrunch avatar Mar 03 '17 22:03 mistercrunch

I just found about superset worker after my read through the config file. I managed to get it running with redis, but haven't figured out how to do so with sqlite (due to sqla not being a supported transport?). I'll probably add in a small section for setting up celery now that I've been through it,

acmiyaguchi avatar Mar 03 '17 22:03 acmiyaguchi

sqla is experimental, I think it should work on small workloads like Superset would typically generate, but I'd use a proper threaded DB, not sqllite for celery on sqla.

Either see how much mileage you can get on that or setup Redis which is pretty easy and has been zero-maintenance in our case.

mistercrunch avatar Mar 03 '17 23:03 mistercrunch

@acmiyaguchi can you pl. share the documentation for celery setup. I want to use s3 as the results backend. Currently, I have sqla as the broker and local filesystem as the results backend. The problem is, on sql editor screen, after clicking "Run Query Asynchronously", I am unable to run the next query until the previous one completes. What am I missing here?

santhavathi avatar Apr 26 '17 11:04 santhavathi

@santhavathi,

I suspect your celery workers. Your getting results, but you are getting only one is executed, guessing you have only one celery worker running?

fsck-mount avatar Apr 26 '17 11:04 fsck-mount