Files
spring-async-demo/scheduling/src/main/resources/schema.sql
Ankur Mhatre eaa8171966 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().
2026-09-01 23:32:16 +05:30

19 lines
772 B
SQL

-- Both tables are created by every replica at startup, so every statement is IF NOT EXISTS.
-- The shedlock table's shape is fixed by ShedLock: name, lock_until, locked_at, locked_by.
-- lock_until and locked_at must be timestamps; with usingDbTime() they are written by the
-- database, so their precision and time zone are the database's, not the JVM's.
create table if not exists shedlock (
name varchar(64) not null,
lock_until timestamp not null,
locked_at timestamp not null,
locked_by varchar(255) not null,
primary key (name)
);
create table if not exists job_execution (
id serial primary key,
job_name varchar(64) not null,
instance_id varchar(64) not null,
started_at timestamp not null
);