How to re establish db connections when using crac run-time hooks in AWS lambda with snapstart enabled

I’ve added run-time hooks to provide snapstart functionality in my AWS lambda, I’ve a db connection variable which I’ve added to get initialised before the handler method,
Since I’ve added crac run-time hooks, beforeCheckpoint and afterRestore, my connection variable is intialised before the snapshot and resumed for every invocation, how do I make use of the db incase my connection is closed ?

I’ve tried to gracefully close the db connection and establish during the restore phase, isn’t it similar to normal lambda functionality without snapshot?

Is there any alternative to persistently use db connection with snapstart enabled for lambda ?

Leave a Comment