update: limit the range of schedule candidates for a tick
This commit is contained in:
parent
e71c2f140b
commit
093bc3697c
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user