Add the scheduling module

Three replicas of one application against one PostgreSQL database, proving
duplicate @Scheduled execution and then removing it with ShedLock: 24
executions where 8 were due, then 7 for 7 ticks.

Also measured: @SchedulerLock without @EnableSchedulerLock does nothing and
warns about nothing; spring.task.scheduling.pool.size=1 does not starve a
fixedRate job but delays it and fires 35 of 40 executions in a burst; and a
node whose clock is 40 seconds fast takes a live lock unless the provider
uses usingDbTime().
This commit is contained in:
2026-09-01 23:28:06 +05:30
parent 9b3fe88813
commit eaa8171966
31 changed files with 1373 additions and 1 deletions

View File

@@ -0,0 +1,60 @@
profile=unlocked replicas=3 run-for=30s job rate=3s job duration=PT0.2S replica-3 clock skew=0s
-- every execution, in order --
instance_id | started_at
-------------+--------------
replica-1 | 22:48:54.564
replica-3 | 22:48:54.752
replica-2 | 22:48:55.052
replica-1 | 22:48:57.551
replica-3 | 22:48:57.736
replica-2 | 22:48:58.030
replica-1 | 22:49:00.551
replica-3 | 22:49:00.736
replica-2 | 22:49:01.030
replica-1 | 22:49:03.551
replica-3 | 22:49:03.736
replica-2 | 22:49:04.030
replica-1 | 22:49:06.551
replica-3 | 22:49:06.736
replica-2 | 22:49:07.030
replica-1 | 22:49:09.551
replica-3 | 22:49:09.736
replica-2 | 22:49:10.030
replica-1 | 22:49:12.551
replica-3 | 22:49:12.736
replica-2 | 22:49:13.030
replica-1 | 22:49:15.551
replica-3 | 22:49:15.736
replica-2 | 22:49:16.030
(24 rows)
-- executions per replica --
instance_id | count
-------------+-------
replica-1 | 8
replica-2 | 8
replica-3 | 8
(3 rows)
-- pairs of executions that overlapped (a second replica started while the first was still working) --
overlapping_pairs
-------------------
8
(1 row)
first | first_at | second | second_at
-----------+--------------+-----------+--------------
replica-1 | 22:48:54.564 | replica-3 | 22:48:54.752
replica-1 | 22:48:57.551 | replica-3 | 22:48:57.736
replica-1 | 22:49:00.551 | replica-3 | 22:49:00.736
replica-1 | 22:49:03.551 | replica-3 | 22:49:03.736
replica-1 | 22:49:06.551 | replica-3 | 22:49:06.736
replica-1 | 22:49:09.551 | replica-3 | 22:49:09.736
(6 rows)
-- the lock row --
name | locked_by | locked_at | lock_until
------+-----------+-----------+------------
(0 rows)