Open Ralnoc opened 4 years ago
I have made an alteration that on Initial testing seems to resolve the issue, and so far does not show any adverse effects having this change in place. This makes sense as it is likely related to the issue I linked in the original description which revolves entirely around the use of the subqueryload()
function.
Making the following alteration in redash/models/__init__.py
has so far stopped the manifestation of this issue in our lab environment.
diff --git a/redash/models/__init__.py b/redash/models/__init__.py
index cc16088..85c45ae 100644
--- a/redash/models/__init__.py
+++ b/redash/models/__init__.py
@@ -883,7 +883,7 @@ class Dashboard(ChangeTrackingMixin, TimestampMixin, BelongsToOrgMixin, db.Model
query = (
Dashboard.query
.options(
- subqueryload(Dashboard.user).load_only('_profile_image_url', 'name'),
+ joinedload(Dashboard.user).load_only('_profile_image_url', 'name'),
)
.outerjoin(Widget)
.outerjoin(Visualization)
I have not identified any performance issues with this change yet. We will be rolling this change into Dev today as a means to validate the behavior. If it continues to resolve the issue, we should have it running in Production by end of day tomorrow and I will raise a PR here with the changes, referencing this issue.
@susodapop - As you can see above, I've raised the PR to resolve the issue a minor reporting issue in the Presto Query Runner. I'll switch over there and monitor for any questions or concerns with the PR.
Issue Summary
In some situations, when doing a search for dashboards is resulting in an
AttributeError
exception onobj.user.to_dict()
. I have been unable to yet pinpoint any direct cause, only the process that leads up to the issue. In addition, the issue only manifests when searching, and only with some characters, not all. Primarily if there is a large number of results. If I just navigate through the pages on the Dashboards list, there is no issues experienced.The order that I have been able to trace through the code, which leads to this problem is this:
User types in search in the Dashboards page of Re:Dash
DashboardListResource
is called to search DB for dashboards the meets the query usingmodels.Dashboard.search
- SuccessfulDashboardListResource
orders the results of that query - SuccessfulDashboardListResource
callsserialize_dashboard
as part of the pagination process for the the results of the order_results - Successfulhandlers.base.paginate
paginates the results and passes it over toserialize_dashboards
- Successfulserialize_dashboard
executes to serialize the paginated results to return - Fails (items = [serializer(result) for result in results.items]
fails with the exceptionAttributeError: 'NoneType' object has no attribute 'to_dict')
This issue appears to have started after we upgraded from Re:Dash 6.0.0 to 8.0.0. We used the normal DB upgrade scripts as part of the upgrade process. We have tested the Queries and Users API endpoints and none of them throw this exception. It only happens on Dashboards and only when doing a search.
We suspect it is possible an issue with SQLAlchemy related to: https://github.com/sqlalchemy/sqlalchemy/issues/3650
This is the traceback being experienced:
Steps to Reproduce
This is a breaking behavior the impairs the ability to Navigate Dashboards.
Technical details: