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

NullPointerException while using poll.withTransaction(TransactionPropagation.CONTEXT) and losing connection to the database #1447

Open
NekiyXX opened this issue Jul 14, 2024 · 0 comments
Labels
Milestone

Comments

@NekiyXX
Copy link

NekiyXX commented Jul 14, 2024

Version

vert.x 4.5.8

Context

There is a NullPointerException in io.vertx.sqlclient when I try to create transaction with Propagation like: poll.withTransaction(TransactionPropagation.CONTEXT) {}

java.lang.NullPointerException: null at java.base/java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011) ~[?:?] at java.base/java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006) ~[?:?] at io.vertx.core.impl.ContextInternal.putLocal(ContextInternal.java:418) ~[vertx-core-4.5.8.jar:4.5.8] at io.vertx.sqlclient.impl.PoolImpl.lambda$startPropagatableConnection$5(PoolImpl.java:149) ~[vertx-sql-client-4.5.8.jar:4.5.8] at io.vertx.core.impl.future.FutureImpl$4.onFailure(FutureImpl.java:188) ~[vertx-core-4.5.8.jar:4.5.8] at io.vertx.core.impl.future.FutureImpl$ListenerArray.onFailure(FutureImpl.java:316) ~[vertx-core-4.5.8.jar:4.5.8] at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:81) ~[vertx-core-4.5.8.jar:4.5.8] at io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:278) ~[vertx-core-4.5.8.jar:4.5.8] at io.vertx.core.impl.future.Mapping.onFailure(Mapping.java:45) ~[vertx-core-4.5.8.jar:4.5.8] at io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:81) ~[vertx-core-4.5.8.jar:4.5.8]

Steps to reproduce

This occurs if the transaction does not exist in the context and the connection to the database is lost.

  1. SqlConnection not found in context and we are going to the 192 line: "return startPropagatableConnection(this, function);"

Pool.java 192
image

  1. After that we try to get connection and put it in context in 149 line:

PoolImpl.java 149
image

  1. But handler.result() return null here because it is CaseHolder:
image This null result vertx try to set in context and we get NullPointer.

Extra

In our project we use vertx.exceptionHandler to caught an unhandled exception and shutdown the server if something goes wrong, in which case Kubernetes should start the pod again. So this nullpointer shutdown our server. Temporarily I added an exceptionHandler to the current vertx context to skip this error. But I think that vertx sql client should not try to set null in the vertx context.

@NekiyXX NekiyXX added the bug label Jul 14, 2024
@vietj vietj modified the milestones: 4.5.9, 4.5.10 Jul 15, 2024
@vietj vietj modified the milestones: 4.5.10, 4.5.11 Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants