Datasource concurency issue in dashboard with multiple panels

Hi,

I’m currently working on a simple custom datasource which compute calculations, and that’s not the first Grafana datasource which I worked on.

I won’t share my datasource’s code because the problem seems to come from it, but I need some assistance on Grafana datasource’s comprehension, I suspect some kind of concurency isses between multiple queries at the same moment.

My custom datasource actually works and I can integrate it into panels without issues, but when I use it in multiple panels in the same Grafana dashboard, some of the panel end up with errors from my datasource (despite having no issues when focusing on the panel with the v or using it in a dashboard with only 1 or 2 panels, but only when the dashboard display multiple panels in the same views).
The more panels using my custom data source are displayed in the dashboard, the more likely they are to generate errors.

What my custom datasource compute is eval/expr, so it need to compute the expression sorted in a way in order to handle parenthesis & co, it works, but when in dashboard with multiple panels the query crash randomly with the error “An error occurred within the plugin” (despite all the possible error are being catched in my code).

So my question is: How does Grafana datasources handle query ? If a dashboard perform multiple queries on the same datasource with different parameters, If I don’t use pointers (it’s wrote using Go) or anything fancy but mere slices, queries won’t collide between each other or changes variable’s content across functions ? Did one of you already experimented this kind of situation ? I need to be reassured.

Best regards,

1 Like

Alright, it may indeed be a performance issue, I’ll investigate this point.

Thanks for the quick reply !

1 Like

So what was the issue you marked as solved? for posterity.

I changed my algorythm in order to be quicker and consume fewer resources and it did works