Implement Connection Pooling and Threading#91
Implement Connection Pooling and Threading#91MrLight wants to merge 12 commits intomichelin:masterfrom
Conversation
|
Thanks, for this MR, I will review it asap. |
|
Thanks, for looking into this. |
|
I have published a beta release in "my" fork. If you like you can have look there... |
devnied
left a comment
There was a problem hiding this comment.
Thank you for this great PR!
I have a few pieces of feedback based on my review.
I also need to test a few edge cases before I can approve it.
|
|
I have reworked the code, so that it should fit into the new structure. I can't test the oauth stuff, but should work as expected. |
|
Thanks for the rebase. |
Not really sure, what you are referencing to. The idea is exactly this. The Connection creation logic has moved into the With this go-lang will create a connection pool with multiple connections. Concept is that we do not need to execute each and every query in case of Warehouse overload. We will drop all new queries until the warehouse is responsive again. |



This implements Connection Pooling for the Snowflake Connection.
The code today doesn't reuse the snowflake connection. After each query the connection is dropped. This PullRequest will add ConnectionPooling to store open connections for later reuse. The poolsize and the connection timeout can be configured in the PluginConfig.
When the snowflake warehouse is in hard load it could be possible, that too much queries will be forwarded to snowflake, which will end in an overloaded Snowflake Warehouse. The poolsize will limit the concurrent queries which are forwarded to snowflake, but all additional Grafana queries will be stored in the query queue of the plugin. To drop new queries in the situation of overload a max. queued queries option is available. If more queries as configured are waiting a error will be returned to the panel. This will give snowflake the possibility to recover.
To implement the options in the ConfigEditor the editor code is changed from the legacy forms to the newer grafana forms.
If a Panel has multiple queries, the snowflake query will be done in multiple threads after this change.
All changes are speeding up the query execution and will reduce snowflake cloud query costs for connection creation.
This is the first pull-request. A second one implementing plugin-side caching is prepared. Please let me know if you are willing to implement such huge changes into your code base.