Last active
December 27, 2015 12:59
-
-
Save benders/7329754 to your computer and use it in GitHub Desktop.
Figure out WTF is in our delayed_job queue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
count(*) as count, priority, object, method from ( | |
SELECT | |
@load_start := LOCATE('object: LOAD;', handler), | |
@method_start := LOCATE('method: ', handler) + 9, | |
@method_end := LOCATE('args:', handler) - 1, | |
IF(@load_start, | |
@object_start := @load_start + 13, | |
@object_start := LOCATE('object: !ruby/object:', handler) + 21 | |
), | |
IF(@load_start, | |
@object_end := @method_start - 10, | |
@object_end := LOCATE('id: ', handler) - 3 | |
), | |
priority, | |
RTRIM(SUBSTRING_INDEX(SUBSTRING(handler, @object_start, @object_end - @object_start), ';', 1)) as object, | |
RTRIM(SUBSTRING(handler, @method_start, @method_end - @method_start)) as method | |
FROM delayed_jobs | |
WHERE run_at <= UTC_TIMESTAMP() | |
AND failed_at IS NULL | |
AND priority > -100 | |
) jobs | |
GROUP BY priority, object, method | |
ORDER BY count DESC; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN; | |
INSERT INTO failed_delayed_jobs (SELECT * FROM delayed_jobs WHERE failed_at IS NOT NULL); | |
DELETE FROM delayed_jobs WHERE failed_at IS NOT NULL; | |
COMMIT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment