davsclaus commented on code in PR #27693:
URL: https://github.com/apache/camel/pull/27693#discussion_r4249463419


##########
components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventConsumer.java:
##########
@@ -102,15 +114,24 @@ public class PgEventListener implements 
PGNotificationListener {
 
         public void reconnect() {

Review Comment:
   Minor, non-blocking: while the consumer is stopping (status `STOPPING`, so 
`isRunAllowed()` is false), the connection can still be lost in the window 
between `task.cancel(true)` and `shutdown(reconnectPool)` in `doStop()`, for 
example during the `UNLISTEN` in `closeConnection()`. `closed()` then calls 
`reconnect()`, the cancelled task is no longer running, so a new task is 
created and scheduled with a 1s initial delay. `shutdown(reconnectPool)` drops 
that periodic task, nothing counts down its latch, and the driver thread waits 
in `run()` forever (unlimited duration). Not starting a reconnect while 
stopping avoids it:
   
   ```suggestion
           public void reconnect() {
               if (!isRunAllowed()) {
                   // stopping: the reconnect pool is about to be shut down and 
would never run the task
                   return;
               }
   ```
   
   (Alternatively, cancel `reconnectTask` after the pool is shut down: a task 
created before the shutdown is then cancelled, and one created after it fails 
to schedule instead of blocking.)



-- 
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]

Reply via email to