grafana / sqlds

A package that assists writing SQL-driven datasources
Apache License 2.0
17 stars 12 forks source link

Multiple connections appear to be broken #48

Closed toddtreece closed 2 years ago

toddtreece commented 2 years ago

It seems like the default key is always replaced when NewDatasource is called, so it seems like the latest connection is always being used. I have a temp workaround for the issue here: https://github.com/grafana/snowflake-datasource/pull/98

It's unclear how this is intended to work or if this is related to the issue, but the query's q.ConnectionArgs variable is always nil.

Related issue: https://github.com/grafana/support-escalations/issues/999

kminehart commented 2 years ago

Ah so by using the same key for every NewDatasource, that causes setups with multiple Snowflake data sources to break in weird ways, as they're overwriting eachother?

kminehart commented 2 years ago

I think this could be pretty easily remedied by including the data source UID in the cache key there. This feature was specifically added to allow multiple connections in 1 data source in some AWS data sources. cc @sunker

toddtreece commented 2 years ago

@kminehart yeah, exactly. they seem to all only be using one connection, and you can kind of reset which connection is being used if you go and do a health check on one of the data sources

This feature was specifically added to allow multiple connections in 1 data source

do you mean storing the connection in NewDatasource or storing the connection in getDB?

andresmgot commented 2 years ago

I can confirm the issue (I was assuming that each datasource instance would have its own sqldatasource instance but it's not working that way). See the fix at #49.

andresmgot commented 2 years ago

fixed in v2.3.1