Occasionally, calls to different endpoints return an uncaught exception error
sqlalchemy.orm.exc.DetachedInstanceError: Instance <TenantConfig at 0x7f5ab85f9f50> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: https://sqlalche.me/e/14/bhk3
Background on the sqlalchemy error indicates the issue has to do with accessing objects in a Session after it has been closed.
Here is an example full trace:
File "/usr/local/lib/python3.7/site-packages/common/utils.py", line 82, in handle_error raise exc File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 458, in wrapper resp = resource(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/flask/views.py", line 89, in view return self.dispatch_request(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 573, in dispatch_request resp = meth(*args, **kwargs) File "/home/tapis/service/controllers.py", line 130, in get if tenant_configs_cache.get_custom_oa2_extension_type(tenant_id=tenant_id): File "/home/tapis/service/models.py", line 187, in get_custom_oa2_extension_type config = self.get_config(tenant_id) File "/home/tapis/service/models.py", line 171, in get_config if t.tenant_id == tenant_id: File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 481, in __get__ return self.impl.get(state, dict_) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 926, in get value = self._fire_loader_callables(state, key, passive) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 957, in _fire_loader_callables return state._load_expired(state, passive) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/state.py", line 710, in _load_expired self.manager.expired_attribute_loader(self, toload, passive) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/loading.py", line 1395, in load_scalar_attributes "attribute refresh operation cannot proceed" % (state_str(state)) sqlalchemy.orm.exc.DetachedInstanceError: Instance <TenantConfig at 0x7f5ab85f9f50> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: https://sqlalche.me/e/14/bhk3) [in /usr/local/lib/python3.7/site-packages/common/utils.py:87]
Occasionally, calls to different endpoints return an uncaught exception error
sqlalchemy.orm.exc.DetachedInstanceError: Instance <TenantConfig at 0x7f5ab85f9f50> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: https://sqlalche.me/e/14/bhk3
Background on the sqlalchemy error indicates the issue has to do with accessing objects in a
Session
after it has been closed.Here is an example full trace:
File "/usr/local/lib/python3.7/site-packages/common/utils.py", line 82, in handle_error raise exc File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 458, in wrapper resp = resource(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/flask/views.py", line 89, in view return self.dispatch_request(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 573, in dispatch_request resp = meth(*args, **kwargs) File "/home/tapis/service/controllers.py", line 130, in get if tenant_configs_cache.get_custom_oa2_extension_type(tenant_id=tenant_id): File "/home/tapis/service/models.py", line 187, in get_custom_oa2_extension_type config = self.get_config(tenant_id) File "/home/tapis/service/models.py", line 171, in get_config if t.tenant_id == tenant_id: File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 481, in __get__ return self.impl.get(state, dict_) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 926, in get value = self._fire_loader_callables(state, key, passive) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 957, in _fire_loader_callables return state._load_expired(state, passive) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/state.py", line 710, in _load_expired self.manager.expired_attribute_loader(self, toload, passive) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/loading.py", line 1395, in load_scalar_attributes "attribute refresh operation cannot proceed" % (state_str(state)) sqlalchemy.orm.exc.DetachedInstanceError: Instance <TenantConfig at 0x7f5ab85f9f50> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: https://sqlalche.me/e/14/bhk3) [in /usr/local/lib/python3.7/site-packages/common/utils.py:87]