This is an automated email from the ASF dual-hosted git repository.

yjhjstz pushed a commit to branch fix_pgcron
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 787c74288b1d9a2eb1d334f8ecca70c40c01f11d
Author: Jianghua Yang <[email protected]>
AuthorDate: Wed Apr 9 00:38:23 2025 +0800

    Fix activeTaskCount increment for CRON_TASK_WAITING tasks
    
    Previously, activeTaskCount was incremented unconditionally, even for
    tasks in CRON_TASK_WAITING state with an invalid file descriptor (fd <= 0).
    This led to incorrect task accounting and could affect task scheduling 
logic.
    
    This commit adds a check to ensure that activeTaskCount is incremented
    only if the task's file descriptor is valid (fd > 0), which avoids
    counting tasks that are not actively being polled.
---
 src/backend/task/pg_cron.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/task/pg_cron.c b/src/backend/task/pg_cron.c
index 659edc8bb6..ac5cfbe82b 100644
--- a/src/backend/task/pg_cron.c
+++ b/src/backend/task/pg_cron.c
@@ -910,8 +910,8 @@ PollForTasks(List *taskList)
                }
 
                pollFileDescriptor->revents = 0;
-
-               activeTaskCount++;
+               if (pollFileDescriptor->fd >= 0)
+                       activeTaskCount++;
        }
 
        /*


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to