GRUD_DEV-1222/fix/cached-plan-issue#326
Merged
Merged
Conversation
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against c83a50d |
There was a problem hiding this comment.
Pull request overview
Adds a targeted retry mechanism in the Vert.x PostgreSQL SQLConnection wrapper to mitigate PostgreSQL’s “cached plan must not change result type” error by discarding the affected connection and re-running the operation on a fresh connection.
Changes:
- Detects the PostgreSQL cached-plan error via exception message matching.
- Logs a warning and retries the failed operation using a newly acquired connection.
Comments suppressed due to low confidence (1)
src/main/scala/io/vertx/scala/SQLConnection.scala:124
- In the cached-plan retry branch,
connis closed inside therecoverWith(line 114) but then is closed again after therecoverWithcompletes (line 123) when the retry succeeds. Also,newConnis only closed on the success path; iffn(newConn)fails, the_ <- close(newConn)step is skipped and the connection can leak. Restructurewrapso connections are closed exactly once and in afinally-style block (e.g.,transformWith/andThento always close), and ensurenewConnis closed even whenfn(newConn)fails.
for {
_ <- close(conn)
newConn <- connection()
retryResult <- fn(newConn)
_ <- close(newConn)
} yield retryResult
case ex: Throwable =>
logger.error(s"Database query/update/execute failed. Close connection.", ex)
close(conn).flatMap(_ => Future.failed[A](ex))
})
_ <- close(conn)
} yield result
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
so we have no stale prepared statements
Zwergal
approved these changes
Feb 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Submit a pull request
Related Ticket: GRUD_DEV-1222
Please make sure the following is true
Other information/comments (e.g. reasons why points are not checked from above)
Die Lösung war, zusätzlich zum Schema reset auch den connection pool zurückzusetzen. Wenn sich in Tests die Reihenfolge von columns und ihren typen ändern, kann es sein, dass im connection pool die prepared statements nichts davon mitkriegen. Dadurch dass unser Schema sehr dynamisch ist, kann das zum Problem werden.
Ich kann nur vermuten, warum das bisher beim Test kein Problem war. Ich denke, dass einfach immer die gleiche Testtable erstellt wird und dadurch die prepared statements auch einfach immer gepasst haben. Im BE haben wir aber auch immer wieder einen flaky Test, der sich daurch evtl. erklären lässt.
Mal sehn, im Optimalfall ist das Problem auch gelöst.