Cache connections based on the datasource updated timestamp #111
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An issue was created for
athena-datasource
(grafana/athena-datasource#264) where if you rotate AWS credentials and then edit them in the datasource config in grafana, the new credentails aren't used until the datasource is recreated (or the server restarted). This is because database connections there are cached based only on the datasource UID and (if present) the connection arguments.The
grafana-aws-sdk
uses a cache mechanism copied from sqlds, and the same issue is present in all sqlds-based (and awsds-based) datasources as well. To address this I've updated sqlds to include theUpdated
timestamp from the datasource settings in its cache key, and to expose the key mechanism soathena
can use it instead of duplicated code.This does, unfortunately, slightly change the
sqlds
API - theGetDBFromQuery
method now takesbackend.DataSourceInstanceSettings
instead of astring
for the datasource UID. However, as far as I can tell (searching github and google both) this method is only used ingrafana-aws-sdk
, in one place. Personally I think it's probably okay to keep this atv3
despite the API change, but please let me know if you think we need to bump to v4 instead.