snowflakedb / gosnowflake

Go Snowflake Driver
Apache License 2.0
292 stars 122 forks source link

Option to skip dbSql registration for canary style driver upgrade rollout #1091

Closed madisonchamberlain closed 4 months ago

madisonchamberlain commented 5 months ago

Description

I am curious if you would accept a change like this. We are thinking of ways to do canary style rollouts of the new driver version. Currently, we can pull two different versions of the driver into our code base with changes to go.mod that look like this:

require (
        github.com/snowflakedb/gosnowflake v1.8.1-0.20240327090609-2141603917de
)

replace (
    github.com/snowflakedb/gosnowflakeVersionDowngrade => github.com/snowflakedb/gosnowflake v1.8.0
)

However, both versions of the driver will call init, and those call sql.Register which says If Register is called twice with the same name or if driver is nil, it panics. so we cannot run this code if the two versions are running on the same service.

Having this would allow us to bypass registration. If you don't like this method I am happy to experiment with some different methods, and if you are interested in it I will extend the readme so others can use this configuration as well, as this would require us to use sql.OpenDB rather than sql.Open. Thanks!

Checklist