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

I keep getting orator.exceptions.query.QueryException #57

Closed
tantita opened this issue Mar 21, 2016 · 10 comments
Closed

I keep getting orator.exceptions.query.QueryException #57

tantita opened this issue Mar 21, 2016 · 10 comments

Comments

@tantita
Copy link

tantita commented Mar 21, 2016

I have started using your awesome ORM on production and I get this error like once everyday which causes that endpoint to return a 502 until I refresh it like several times. Here is the stack-trace:

Traceback (most recent call last):
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "./theapp/controllers.py", line 28, in restaurants
    ress = Restaurant.with_('area', 'foods').get().to_dict()
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/orator/orm/builder.py", line 198, in get
    models = self.get_models(columns)
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/orator/orm/builder.py", line 439, in get_models
    results = self.apply_scopes().get_query().get(columns)
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/orator/query/builder.py", line 1049, in get
    return self.get_fresh(columns)
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/orator/query/builder.py", line 1067, in get_fresh
    return self._processor.process_select(self, self._run_select())
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/orator/query/builder.py", line 1079, in _run_select
    not self._use_write_connection
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/orator/connections/connection.py", line 34, in _run
    e, query, bindings, wrapped
  File "/var/www/grub_flask/venv/local/lib/python2.7/site-packages/orator/connections/connection.py", line 318, in _try_again_if_caused_by_lost_connection
    raise QueryException(query, bindings, e)
orator.exceptions.query.QueryException: (0, '') (SQL: SELECT * FROM `restaurants` ([]))
[pid: 13958|app: 0|req: 185/967] 41.184.34.126 () {46 vars in 989 bytes} [Mon Mar 21 18:08:02 2016] GET /api/v1/restaurants/ => generated 0 bytes in 4 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

Here is what my query looks like:

Restaurant.with_('area', 'foods').get().to_dict()
@tantita
Copy link
Author

tantita commented Mar 21, 2016

Pls note that I use orator with flask and I don't use the flask-orator package, rather I connect to it directly from my model file

@sdispater
Copy link
Owner

I will look into it

@tantita
Copy link
Author

tantita commented Mar 23, 2016

Please I need a fast solution to this.
I have to always restart the flask application process whenever I encounter this.

@sdispater
Copy link
Owner

I am unable to reproduce the error.

Which database package are you using (PyMysql, mysqclient, psycopg2)?
Also, are you using the 0.8 version of orator or the develop branch?
Finally, which Flask version are you using?

@tantita
Copy link
Author

tantita commented Mar 26, 2016

Flask (0.10.1)
Orator - develop branch
I tested with both MySQLdb and pymsql (wc are d 2 supported drivers as seen in the code -- orator/connectors/mysql_connector:3) and got the same errors

@tantita
Copy link
Author

tantita commented Mar 27, 2016

please i really need your help on this issue as I've already gone far with this application n would be difficult switching my stack at this time.

@tantita
Copy link
Author

tantita commented Mar 27, 2016

I think I have found a temporary fix,
I had to comment out the self._db.disconnect() in the flask_orator/init.py file

@sdispater
Copy link
Owner

Thanks for narrowing down the issue 👏

I just pushed a fix on the develop branch so you should be able to uncomment the line in flask-orator.

@tantita
Copy link
Author

tantita commented Mar 30, 2016

Thanks alot, will update n feed u back

@tantita
Copy link
Author

tantita commented Mar 31, 2016

The connection is stable now. I think this issue can be closed now. Thanks alot

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

No branches or pull requests

2 participants