davsclaus commented on code in PR #27693:
URL: https://github.com/apache/camel/pull/27693#discussion_r4245540295
##########
components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventConsumer.java:
##########
@@ -102,15 +107,20 @@ public class PgEventListener implements
PGNotificationListener {
public void reconnect() {
// only submit the task if not already running
- if (!reconnectTask.isRunning()) {
- reconnectTask.run(endpoint.getCamelContext(), () -> {
+ BackgroundTask current = reconnectTask;
+ if (current == null || !current.isRunning()) {
+ // a background task completes only once (running it again
does nothing), so every reconnect needs
+ // its own task
+ final BackgroundTask task = createReconnectTask();
+ reconnectTask = task;
+ task.run(endpoint.getCamelContext(), () -> {
if (isRunAllowed()) {
- LOG.debug("Connecting attempt #{}",
reconnectTask.iteration());
+ LOG.debug("Connecting attempt #{}", task.iteration());
try {
initConnection();
Review Comment:
`initConnection()` overwrites `dbConnection` without closing the dead one,
and a failed attempt after `getConnection()` (e.g. `LISTEN` failing) also leaks
the connection on every retry. With a pooled `datasource` each loss takes a
pool slot that is never returned. A quiet `closeConnection()` before
`initConnection()` (or on failure) would avoid that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]