...
Job starts once in 20 min by default (configured parameter MERGE_REQUEST_EXPIRATION_SCHEDULE= “*/20 * * * *”).
After starting it gets value from global parameter MERGE_REQUEST_EXPIRATION_MINUTES (by default is 30 60 min).
Select all entries from il.merge_requests with status=NEW or APPROVED:
If inserted_at >= current_datetime() - MERGE_REQUEST_EXPIRATION_MINUTES. Then skip the record
If inserted_at < current_datetime() - MERGE_REQUEST_EXPIRATION_MINUTES. Then update entry:
set status = EXPIRED
set updated_at = current_datetime()
set updated_by = system_user()
...