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

Error running SQL Lab #12824

Closed
liuxp311 opened this issue Jan 29, 2021 · 13 comments
Closed

Error running SQL Lab #12824

liuxp311 opened this issue Jan 29, 2021 · 13 comments
Labels
#bug Bug report

Comments

@liuxp311
Copy link

Error running SQL Lab

Expected results

Error message:

Database Error
Instance <Query at 0x1b00c574070> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/13/bhk3)

Actual results

Unable to query

Screenshots

Database Error
Instance <Query at 0x1b00c574070> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/13/bhk3)

How to reproduce the bug

  1. open sql lab
  2. run
  3. Scroll down to '....'
  4. See error :
    Database Error
    Instance <Query at 0x1b00c574070> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/13/bhk3)

Environment

(please complete the following information):

  • superset version: superset version 1.0.0
  • python version: python --version3.8.6
  • node.js version: node -v12 1.8

Checklist

Additional context

@liuxp311 liuxp311 added the #bug Bug report label Jan 29, 2021
@liuxp311
Copy link
Author

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\13264\desktop\test\python\superset\venv\lib\site-packages\superset\views\base.py", line 180, in wraps
return f(self, *args, **kwargs)
File "c:\users\13264\desktop\test\python\superset\venv\lib\site-packages\superset\utils\log.py", line 164, in wrapper
value = f(*args, **kwargs)
File "c:\users\13264\desktop\test\python\superset\venv\lib\site-packages\superset\views\core.py", line 2418, in sql_json
return self.sql_json_exec(request.json, log_params)
File "c:\users\13264\desktop\test\python\superset\venv\lib\site-packages\superset\views\core.py", line 2564, in sql_json_exec
return self._sql_json_sync(
File "c:\users\13264\desktop\test\python\superset\venv\lib\site-packages\superset\views\core.py", line 2403, in sql_json_sync
logger.exception("Query %i failed unexpectedly", query.id)
File "c:\users\13264\desktop\test\python\superset\venv\lib\site-packages\sqlalchemy\orm\attributes.py", line 294, in get
return self.impl.get(instance_state(instance), dict
)
File "c:\users\13264\desktop\test\python\superset\venv\lib\site-packages\sqlalchemy\orm\attributes.py", line 725, in get
value = state._load_expired(state, passive)
File "c:\users\13264\desktop\test\python\superset\venv\lib\site-packages\sqlalchemy\orm\state.py", line 652, in _load_expired
self.manager.deferred_scalar_loader(self, toload)
File "c:\users\13264\desktop\test\python\superset\venv\lib\site-packages\sqlalchemy\orm\loading.py", line 942, in load_scalar_attributes
raise orm_exc.DetachedInstanceError(
sqlalchemy.orm.exc.DetachedInstanceError: Instance <Query at 0x22638334df0> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/13/bhk3)
INFO:werkzeug:127.0.0.1 - - [31/Jan/2021 10:48:14] "POST /superset/sql_json/ HTTP/1.1" 500 -
INFO:werkzeug:127.0.0.1 - - [31/Jan/2021 10:48:14] "GET /superset/queries/1612060970962.423 HTTP/1.1" 200 -

@eugeniamz
Copy link

which database do you use?

@liuxp311
Copy link
Author

1)mysql or sqlite,the same question,2)Environment:Virtual environment python -m venv venv

@liuxp311
Copy link
Author

which database do you use?

1)mysql or sqlite,the same question,2)Environment:Virtual environment python -m venv venv

@beautah
Copy link

beautah commented Jan 31, 2021

I'm seeing the same issue using an oracle db connection, my python version is 3.8.4, using conda for env, but same set up otherwise.

@jokus-pokus
Copy link

Same issue here using a SQL Server and Apache Superset on Windows.
Everything works fine but i cant query in SQL Lab.
What can i do there to bound my query to a Session?

Thanks in advance!

@liuxp311
Copy link
Author

liuxp311 commented Feb 7, 2021

@eugeniamz :can help to solve this question?

@liuxp311
Copy link
Author

liuxp311 commented Feb 7, 2021

@ryw :can help to solve this question?

@mohimirza
Copy link

mohimirza commented Feb 9, 2021

@liuxp311 @beautah @jokus-pokus

The problem seems to be caused by SIGALRM. Here is a workaround which has worked for me.
In Lib\site-packages\superset\utils\core.py replace:

  def __enter__(self):
      try:
          signal.signal(signal.SIGALRM, self.handle_timeout)
          signal.alarm(self.seconds)
      except ValueError as e:
          logger.warning("timeout can't be used in the current context")
          logger.exception(e)

  def __exit__(self, type, value, traceback):
      try:
          signal.alarm(0)
      except ValueError as e:
          logger.warning("timeout can't be used in the current context")
          logger.exception(e)

with

    def __enter__(self):
        try:
            #signal.signal(signal.SIGALRM, self.handle_timeout)
            #signal.alarm(self.seconds)
            pass
        except ValueError as e:
            logger.warning("timeout can't be used in the current context")
            logger.exception(e)

    def __exit__(self, type, value, traceback):
        try:
            #signal.alarm(0)
            pass
        except ValueError as e:
            logger.warning("timeout can't be used in the current context")
            logger.exception(e)

@beautah
Copy link

beautah commented Feb 9, 2021

Nice! Thanks for that @mohimirza , but I've decided to go ahead and get this set up on my linux server and keep it within the realm of supported devices, might just have to use this trick to have a working local development version though, it certainly works!

@liuxp311
Copy link
Author

ok

@liuxp311 liuxp311 reopened this Feb 19, 2021
@liuxp311
Copy link
Author

ok

@liuxp311
Copy link
Author

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report
Projects
None yet
Development

No branches or pull requests

5 participants