MisterRaindrop commented on code in PR #2060:
URL: https://github.com/apache/cloudberry/pull/2060#discussion_r4175785519


##########
src/test/regress/sql/task.sql:
##########
@@ -49,10 +49,23 @@ alter task vacuum_db database task_dbno user task_cron;
 alter task vacuum_db user hopedoesnotexist;
 
 -- valid interval tasks
+--
+-- These four only exercise the schedule parser, they are never meant to run.
+-- Deactivate each one as soon as it exists: while a second-based task stays
+-- active the scheduler keeps firing it, and every run draws a run id from the
+-- cluster-wide Oid counter (NextRunId -> GetNewOidWithIndex).  A task still
+-- firing later in the same regression run shifts the counter that
+-- oid_wraparound hardcodes, and DROP TASK, which also deletes the task's
+-- pg_task_run_history rows, fails with "tuple concurrently updated" when it
+-- races the run the scheduler is in the middle of recording.
 create task valid_task_1 schedule '1 second' as 'select 1';
+alter task valid_task_1 not active;

Review Comment:
   Could we make the task deactivation atomic? In this regression test, `CREATE 
TASK` commits an active task before the following `ALTER TASK ... NOT ACTIVE` 
runs. If the test process is delayed between those statements, the scheduler 
can start the one-second task and allocate run IDs, preserving the OID/race 
condition this change is intended to eliminate.
   
   I reproduced this with an isolated Cloudberry cluster: leaving a 
scheduler-visible gap produced task runs, while wrapping `CREATE TASK` and 
`ALTER TASK ... NOT ACTIVE` in the same transaction produced none. Please wrap 
these pairs in a transaction so the scheduler can only observe the final 
inactive state. The PAX copy should be updated as well.



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


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

Reply via email to