Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getConnection Method is not throwing exception even when the key is expired #2176

Open
dsinghal-nice opened this issue Feb 21, 2024 · 1 comment

Comments

@dsinghal-nice
Copy link

I have a use case where I am using HikariCP for connecting with my Snowflake database using private key. I have initialized my pool when my microservice starts, but we have a policy of private key rotation after a few days. In Snowflake last 2 private keys are stored, which allows the connection to work with old key as well. But when the rotation happens more than 2 times, the Hikari connection should start throwing error which is not happening currently, it still gets the connection and executes the query.

if (hikariDataSource == null) {
            final Properties properties = snowflakeDatasourceConfig.getSnowflakeProperties();
            var hikariConfig = generateHikariConfig(snowflakeDatasourceConfig, properties);
            hikariDataSource = new HikariDataSource(hikariConfig);
        }

I am preparing my DataSource at the beginning of the server start and then using hikariDataSource.getConnection() method every time when I need a new connection for a query to be executed in Snowflake. Ideally the getConnection() method should throw Exception, but it is not.

@dsinghal-nice
Copy link
Author

dsinghal-nice commented Mar 4, 2024

Can someone please help me understand, why getConnection() method is not throwing SQLTransientException as soon as the key is rotated in AWS or the old key is expired (in a simpler way). Hikari CP throws exception after a certain amount of time.

12:28:29.558 [dev] [2.93] [] [] [HikariPool-4 connection adder] ERROR n.s.clie.jdbc.SnowflakeBasicDataSource [] [] [] [] [] Failed to create a connection for {{username}} at jdbc:snowflake://{{account}}.{{private_link}}?allowUnderscoresInHost=true: net.snowflake.client.jdbc.SnowflakeSQLException: !394304!
12:28:29.773 [dev] [2.93] [] [] [http-nio-9090-exec-2] INFO c.n.s.w.q.a.service.QueryEngineServiceImpl [] [] [] [] [] start sfQueryToExecute
12:28:29.887 [dev] [2.93] [] [] [http-nio-9090-exec-2] INFO c.n.s.w.q.a.s.snowfl.SnowflakeQueryExecutor [] [] [] [] [] Query Trace ID: 4e666969c3f455d7, Query Id: 01b2c32c-0904-5fa1-0009-4b8317312322
12:28:29.887 [dev] [2.93] [] [] [http-nio-9090-exec-2] INFO c.n.s.w.q.a.service.QueryEngineServiceImpl [] [] [] [] [] end sfQueryToExecute

As you can see, I am getting error from HikariPool-4 connection adder, but Hikari Pool is still letting me use the connections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant