You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a native quarkus aws lambda, the constructor is invoked for every handler invocation.
That is a problem as the subsequent handler calls won't benefit of the pre-initialised instance.
In the standard lambda implementations the constructor is used to do pre-initialisations like loading some resources or opening connections. The subsequent calls for a warm instance would then just invoke the handler.
Expected behavior
The constructor should be invoked only on cold start so heavy resources/connections can be pre-initialised and be reused across multiple handler invocations
Actual behavior
the constructor is invoked for every handler invocation so the lambda cannot benefit of the pre-initialisation done in the constructor
How to Reproduce?
create a new quarkus lambda project
add a logging statement into the handler's constructor.
test the handler in aws => in the cloudwatch logs you will see that the constructor is invoked for every lambda call (even for the warm ones)
Output of uname -a or ver
Linux 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
openjdk version "11.0.16" 2022-07-19
GraalVM version (if different from Java)
GraalVM 22.2.0 Java 11 CE (quay.io/quarkus/ubi-quarkus-native-image:22.2-java11)
Quarkus version or git rev
2.12.0.Final
Build tool (ie. output of mvnw --version or gradlew --version)
Apache Maven 3.6.3
Additional information
No response
The text was updated successfully, but these errors were encountered:
Thanks a mill for your answer.
In this case there's another small bug.
On the first run the Constructor is invoked twice.
I've left a logging in the constructor to test the behaviour. I see the log appearing twice (both in my tests and on aws as well).
For subsequent calls it is not invoked anymore, so that is indeed sorted.
One more note.
If this is the expected solution, then it would be nice to add this to the quarkus-amazon-lambda-archetype and to the documentation (e.g. here https://quarkus.io/guides/amazon-lambda) as this is the default expected behaviour for lambdas.
Describe the bug
When creating a native quarkus aws lambda, the constructor is invoked for every handler invocation.
That is a problem as the subsequent handler calls won't benefit of the pre-initialised instance.
In the standard lambda implementations the constructor is used to do pre-initialisations like loading some resources or opening connections. The subsequent calls for a warm instance would then just invoke the handler.
Expected behavior
The constructor should be invoked only on cold start so heavy resources/connections can be pre-initialised and be reused across multiple handler invocations
Actual behavior
the constructor is invoked for every handler invocation so the lambda cannot benefit of the pre-initialisation done in the constructor
How to Reproduce?
Output of
uname -a
orver
Linux 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "11.0.16" 2022-07-19
GraalVM version (if different from Java)
GraalVM 22.2.0 Java 11 CE (quay.io/quarkus/ubi-quarkus-native-image:22.2-java11)
Quarkus version or git rev
2.12.0.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.6.3
Additional information
No response
The text was updated successfully, but these errors were encountered: