grafana / grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
https://grafana.com
GNU Affero General Public License v3.0
64.53k stars 12.09k forks source link

Dashboards: Visiting /dashboards itself causes "Page error" #84042

Open jamessanford opened 7 months ago

jamessanford commented 7 months ago

What happened?

/dashboards DashboardListPage returns error: "Page error", "An unexpected error happened", "InternalError: too much recursion"

Et@https://example.com/graph/public/build/DashboardListPage.d27b4433a05dc7d252e6.js:15:7222
div
b@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:454:100807
div
div
d@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:357:17354
div
div
div
div
fe@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:299:4635
u@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:194:29815
div
L@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:357:21098
32538/We<@https://example.com/graph/public/build/DashboardListPage.d27b4433a05dc7d252e6.js:15:13119
Suspense
r@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:194:122062
Ru@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:5705:9531
I@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:444:29242
di@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:435:4481
ni@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:435:12022
ht@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:444:17401
I@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:444:31410
div
div
main
div
Xf@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:5705:2385
di@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:435:4481
ni@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:435:12022
cr@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:435:11439
Hn@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:444:17692
I@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:444:25474
div
o@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:214:13882
h@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:136:9122
f@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:773:96558
d@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:499:21142
r@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:194:122062
g@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:194:122571
it@https://example.com/graph/public/build/3644.93bade7d48e3d75173f7.js:416:521
mg@https://example.com/graph/public/build/5017.830b14490d17e9cbdabb.js:5716:122

What did you expect to happen?

Expected the list of available dashboards to be displayed

Did this work before?

This worked as of version 10.2.3. 10.3.1 and 10.4.0 both fail.

How do we reproduce it?

Is the bug inside a dashboard panel?

No response

Environment (with versions)?

Grafana: 10.4.0 OS: ArchLinux Browser: Firefox

Grafana platform?

A package manager (APT, YUM, BREW, etc.)

Datasource(s)?

No response

tonypowa commented 6 months ago

hi @jamessanford can you share the grafana server error logs?

thank you

jamessanford commented 6 months ago

@tonypowa The failure to display the list of dashboards was caused by old entries in the dashboard table in grafana.db. Removing the rows with delete from dashboard where uid is NULL; for the old rows fixed the bug. The recursion bug causing the list of dashboards to not display was introduced between 10.2.3 (? some possibility it was a little earlier) and 10.3.1.

The old rows stood out because they had an empty uid field in the code where the recursion bug was happening. The old rows are from 2018 and grafana 4.6.3, and the next grafana upgrade was to 5.4.2.

The function called recursively appears to be createFlatTree / mapItem in https://github.com/grafana/grafana/blob/8014665ab55955984a7cebc0b47a12d32f37c666/public/app/features/browse-dashboards/state/hooks.ts#L142

The old dashboard rows were like the following, note there was an empty uid field.

    {
      "kind": "dashboard",
      "uid": "",
      "title": "MTR Test", 
      "url": "/graph/d//mtr-test",
      "tags": [],
      "parentTitle": "General",
      "parentKind": "folder"
    },

The old rows in database table in grafana.db looked like this (data field omitted)

sqlite> SELECT id,version,slug,title,org_id,created,updated_by,created_by,gnet_id,plugin_id,folder_id,is_folder,has_acl,uid,is_public,folder_uid FROM dashboard WHERE uid is NULL;
27|4|timescaledb-test|TimescaleDB Test|1|2018-04-07 22:49:48|6|6|0||0|0|0||0|
28|3|smart-status|SMART Status|1|2018-06-02 23:26:48|6|6|0||0|0|0||0|
29|2|mtr-test|MTR Test|1|2018-07-06 02:30:03|6|6|0||0|0|0||0|
tonypowa commented 6 months ago

many thanks for sharing the solution @jamessanford ! I will forward this issue to the Dashboard squad