mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 18:42:30 +03:00
ae5f3fe593
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7376 Co-authored-by: Karthikeyan Chinnakonda <15602904+codingkarthik@users.noreply.github.com> GitOrigin-RevId: 3a287271320fbb489dbabcd163b1b474fa5132b6
13 lines
942 B
Plaintext
13 lines
942 B
Plaintext
UPDATE hdb_catalog.event_log
|
|
SET locked = SYSDATETIMEOFFSET() AT TIME ZONE 'UTC'
|
|
OUTPUT CONVERT(varchar(MAX), inserted.id), inserted.schema_name, inserted.table_name, inserted.trigger_name, inserted.payload, inserted.tries, CONVERT(varchar(MAX), inserted.created_at), CONVERT(varchar(MAX), inserted.next_retry_at)
|
|
WHERE id in
|
|
(SELECT TOP(#{fetchBatchSize}) l.id
|
|
FROM hdb_catalog.event_log l WITH (UPDLOCK, READPAST)
|
|
WHERE (l.delivered = 0 and l.error = 0)
|
|
AND (l.locked IS NULL or l.locked < DATEADD(MINUTE, -30, SYSDATETIMEOFFSET()))
|
|
AND (l.next_retry_at is NULL or l.next_retry_at <= SYSDATETIMEOFFSET())
|
|
AND l.archived = 0
|
|
AND l.trigger_name IN #{triggerNamesTxt}
|
|
-- Note: In MSSQL, when you order it by ASC - it implies nulls first
|
|
ORDER BY l.locked ASC, l.next_retry_at ASC, l.created_at) |