-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Database connection issues when using CRaC with quarkus #45857
Comments
/cc @barreiro (jdbc) |
I created a repository to reproduce. git clone https://github.com/ybezsonov/unicorn-store-jakarta
App runs on http://localhost:8080
#15 6.134 An exception during a checkpoint operation: |
Hello,
To be clear, that is not a supported/tested scenario as far as I'm aware. Requalifying this as a question.
I think you want to drain the connection pool instead. That would be
Assuming you drain the connection pool before the checkpoint, I don't think so. Agroal will automatically create new connections upon connection request if the pool is empty, Though I assume CRaC may come with other constraints, so there may other things to do before checkpoint than draining the connection pool. |
Hello, |
Not that I know. If you close a datasource, you must re-create it, and the Agroal integration in Quarkus just isn't designed to do that. You would have to completely bypass the whole datasource integration. Which I guess is possible, but not something I'd recommend. I'd focus on finding out why flushing isn't enough -- i.e. why after removing all connections, CRaC still fails. Surely it's no longer about connections? Perhaps some socket related to some protocol-specific side-channel in the PostgreSQL driver?
This too would be way beyond the anticipated use cases. Looks like you'll either need:
|
Yes, the dedicated CRaC integration to Quarkus lifecycle would be preferrable. Own datasource management is too much for such case. With flush I have this error |
This looks related to some async classloading in Quarkus that happens to keep references to JAR files -- presumably because the class is lazily-loaded? You're looking at a general problem in Quarkus here, it really doesn't look related to datasources or Agroal. So, yeah, we need to talk to Galder, whom I already pinged twice so I'll refrain from doing it again :) |
AFAIK there's no support for CRaC in Quarkus to do save/restore. The only reason CRaC is currently in Quarkus is for AWS Lambda snapstart functionality. |
Thank you for the explanation. I think I misunderstood the documentation and thought that other CRaC use cases are supported. |
Describe the bug
Hi,
I have a Jakarta EE application which runs on Quarkus and uses a PostgreSQL datasource and jakarta.persistence.Entity. I provide datasource parameters via environment variables quarkus.datasource.* at startup, and everything works as expected.
I want to use CRaC with Quarkus. I enabled it, and when I do a checkpoint, I get this error:
#11 6.143 An exception during a checkpoint operation:
#11 6.143 jdk.internal.crac.mirror.CheckpointException
#11 6.143 Suppressed: jdk.internal.crac.mirror.impl.CheckpointOpenSocketException: Socket[addr=db-cluster.cluster.rds.amazonaws.com/10.0.3.155,port=5432,localport=39960]
#11 6.143 at java.base/jdk.internal.crac.JDKSocketResourceBase.lambda$beforeCheckpoint$0(JDKSocketResourceBase.java:68)
I tried to implement:
@OverRide
public void beforeCheckpoint(Context<? extends Resource> context) throws Exception {
dataSource.close();
}
The checkpoint is successful now, but when I try to restore and call an API which uses the database, I get this error:
jakarta.el.ELException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection [This pool is closed and does not handle any more connections!]
Is there a bug with handling database connection during CRaC Checkpoint and Restore? Could you please tell me if I need to do something else to handle database connection?
Is there a way to restore connection afterRestore?
Expected behavior
quarkus should close database connection beforeCheckpoint and restores afterRestore
Actual behavior
database connection is open beforeCheckpoint and prevent checkpoint to be successful.
if connection is closed beforeCheckpoint it doesn't restore automatically afterRestore
How to Reproduce?
/src/main/resources/META-INF/web.xml
com.unicorn.store.data.CheckpointUtil
docker run -p 8080:8080
-e QUARKUS_DATASOURCE_JDBC_URL=$QUARKUS_DATASOURCE_JDBC_URL
-e QUARKUS_DATASOURCE_PASSWORD=$QUARKUS_DATASOURCE_PASSWORD
-e QUARKUS_DATASOURCE_USERNAME=postgres
app:latest
Output of
uname -a
orver
6.1.119-129.201.amzn2023.x86_64
Output of
java -version
openjdk version "21.0.5" 2024-10-15 LTS OpenJDK Runtime Environment Corretto-21.0.5.11.1 (build 21.0.5+11-LTS) OpenJDK 64-Bit Server VM Corretto-21.0.5.11.1 (build 21.0.5+11-LTS, mixed mode, sharing)
Quarkus version or git rev
<quarkus.platform.version>3.17.7</quarkus.platform.version>
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.9
Additional information
No response
The text was updated successfully, but these errors were encountered: