1
0

update: limit the range of schedule candidates for a tick

This commit is contained in:
alikia2x (寒寒) 2025-10-29 22:01:17 +08:00
parent e71c2f140b
commit 093bc3697c
2 changed files with 3 additions and 6 deletions

View File

@ -276,13 +276,9 @@ export async function getSnapshotsInNextSecond(sql: Psql) {
SELECT *
FROM snapshot_schedule
WHERE started_at <= NOW() + INTERVAL '1 seconds'
AND started_at >= NOW() - INTERVAL '1 minutes'
AND status = 'pending'
AND type != 'normal'
ORDER BY CASE
WHEN type = 'milestone' THEN 0
ELSE 1
END,
started_at
LIMIT 10;
`;
}
@ -292,6 +288,7 @@ export async function getBulkSnapshotsInNextSecond(sql: Psql) {
SELECT *
FROM snapshot_schedule
WHERE (started_at <= NOW() + INTERVAL '15 seconds')
AND started_at >= NOW() - INTERVAL '2 minutes'
AND status = 'pending'
AND (type = 'normal' OR type = 'archive')
ORDER BY CASE

View File

@ -11,7 +11,7 @@ export async function removeAllTimeoutSchedules() {
WITH deleted AS (
DELETE FROM snapshot_schedule
WHERE status IN ('pending', 'processing')
AND started_at < NOW() - INTERVAL '30 minutes'
AND started_at < NOW() - INTERVAL '2 minute'
RETURNING *
)
SELECT count(*) FROM deleted;