User story
As a user
I want to be able to add resources and execute "test now" while background hourly cron job are running
So that I don't break the system
steps to repeat
- ensure hourly cronjob is setup
- at the top of the hour, try to add a new resource while the cronjob script
- trace error returned
Solution to regain access
- kill process
- start GeoHealthCheck process again
Proposal
Follow recommendations for "session" stuff. "consider using a session.no_autoflush block if this flush is occurring prematurely "
Analysis
I wonder if this happened because I was entering a new resource at 3pm and the cronjob script would have been running.
Perhaps consider some “session” stuff to avoid errors when script runs at CRON time.
Trace Output
sqlalchemy.exc.InvalidRequestError
InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (OperationalError) database is locked u'UPDATE resource SET title=? WHERE resource.identifier = ?' (u'DEV: EC Data Catalogue External', 40)
Traceback (most recent call last)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/flask/app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functionsrule.endpoint
• File "/home/sampsond/GeoHealthCheck/GeoHealthCheck/GeoHealthCheck/app.py", line 135, in home
response = views.list_resources(resource_type)
• File "/home/sampsond/GeoHealthCheck/GeoHealthCheck/GeoHealthCheck/views.py", line 54, in list_resources
resource_type=resource_type).all()
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2320, in all
return list(self)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2438, in iter
return self._execute_and_instances(context)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2451, in _execute_and_instances
close_with_result=True)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2442, in _connection_from_session
**kw)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 854, in connection
close_with_result=close_with_result)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 858, in _connection_for_bind
return self.transaction._connection_for_bind(engine)
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 305, in _connection_for_bind
self._assert_active()
• File "/home/sampsond/GeoHealthCheck/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 214, in _assert_active
% self._rollback_exception
InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (OperationalError) database is locked u'UPDATE resource SET title=? WHERE resource.identifier = ?' (u'DEV: EC Data Catalogue External', 40)
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.
You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:
• dump() shows all variables in the frame
• dump(obj) dumps all that's known about the object