holy-lambda

Patrix 2023-03-31T11:20:20.980839Z

Has anyone created a (native backend) holy-lambda function that connets to an RDS Mysql database?

Patrix 2023-03-31T11:20:57.176739Z

I keep getting this error... (db hostname edited to avoid leaking 馃檪 ) {:type com.zaxxer.hikari.pool.HikariPool$PoolInitializationException, :message "Failed to initialize pool: Cannot connect to MySQL server on \n\nMake sure that there is a MySQL server running on the machine/port you are trying to connect to and that the machine this software is running on is able to connect to this host/port (i.e. not firewalled). Also make sure that the server has not been started with the --skip-networking flag.\n\n", :at [com.zaxxer.hikari.pool.HikariPool throwPoolInitializationException "HikariPool.java" 595]}

Patrix 2023-03-31T11:21:34.199939Z

not sure if I've forgotten some dependencies or something else is going on. The same code and config works perfectly on my machine, but doens't work when using sam local invoke or when running in Lambda. same RDS database, same credentials

Karol W贸jcik 2023-03-31T11:29:20.445049Z

Do you have all the permissions set on Lambda?

Patrix 2023-03-31T11:30:11.004479Z

yes I was about to write that, VPC, security groups, and the execution role allowing VPC access are all set

Patrix 2023-03-31T11:30:57.511909Z

I wonder if these extra stack trace elements might help... [com.mysql.cj.jdbc.*exceptions*.SQLError createSQLException "SQLError.java" 110]} {:type java.lang.ClassCastException, :message "com.mysql.cj.*exceptions*.CJException cannot be cast to com.mysql.cj.*exceptions*.UnableToConnectException", :at [com.mysql.cj.jdbc.ConnectionImpl createNewIO "ConnectionImpl.java" 825]}], :trace [[com.mysql.cj.jdbc.ConnectionImpl createNewIO "ConnectionImpl.java" 825] [com.mysql.cj.jdbc.ConnectionImpl <init> "ConnectionImpl.java" 448] [com.mysql.cj.jdbc.ConnectionImpl getInstance "ConnectionImpl.java" 241] [com.mysql.cj.jdbc.NonRegisteringDriver connect "NonRegisteringDriver.java" 198] [com.zaxxer.hikari.util.DriverDataSource getConnection "DriverDataSource.java" 121] [com.zaxxer.hikari.pool.PoolBase newConnection "PoolBase.java" 358] [com.zaxxer.hikari.pool.PoolBase newPoolEntry "PoolBase.java" 206] [com.zaxxer.hikari.pool.HikariPool createPoolEntry "HikariPool.java" 477] [com.zaxxer.hikari.pool.HikariPool checkFailFast "HikariPool.java" 560] [com.zaxxer.hikari.pool.HikariPool <init> "HikariPool.java" 115] [com.zaxxer.hikari.HikariDataSource <init> "HikariDataSource.java" 81] [hikari_cp.core$make_datasource invokeStatic "core.clj" 265]

Patrix 2023-03-31T12:33:27.111679Z

the part that gets me is that this happens on AWS Lambda or in sam local invoke, so I don't think it's about security groups or IAM roles or VPCs or anything of the sorts... the same code/configuration works when I invoke it directly at the repl or in a test

Karol W贸jcik 2023-03-31T12:34:11.956749Z

Btw, why you want to use hikari for Lambda? Connection pool doesnt make sense for Lambda environment.

Patrix 2023-03-31T12:35:18.202679Z

hmmm it's not a matter of "want" but a matter of "copy pasting my code from other applications to use mysql in this one" 馃槈

Karol W贸jcik 2023-03-31T12:36:03.965739Z

Ok, just for your information using connection pool is risky. You will quickly kill the connection limit.

Patrix 2023-03-31T12:36:23.040179Z

that explains a lot, I've done that in my dev env already lol

Karol W贸jcik 2023-03-31T12:36:45.310069Z

I would try without Hikari.

Patrix 2023-03-31T12:37:17.521039Z

ok, let me try that first and see how it goes

Patrix 2023-04-01T06:07:20.154459Z

okay, after ripping out conman (which was bringing in Hikari) and simplifying a few things, sam local invoke is now working properly. Deploying now to Lambda, fingers crossed.. but already very promising ,thanks for the tip @karol.wojcik!

Patrix 2023-04-01T06:14:16.766569Z

confirmed, DB connection is now working in Lambda as well! can't say "thanks" enough @karol.wojcik 馃檪

Karol W贸jcik 2023-04-01T11:15:58.195299Z

You are very welcome 馃槈

馃憤 1