-
Notifications
You must be signed in to change notification settings - Fork 875
fix(coderd/database): exclude canceled jobs in queue position #15835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,23 +50,29 @@ WHERE | |
id = ANY(@ids :: uuid [ ]); | ||
|
||
-- name: GetProvisionerJobsByIDsWithQueuePosition :many | ||
WITH unstarted_jobs AS ( | ||
WITH pending_jobs AS ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. review: Renamed for clarity. |
||
SELECT | ||
id, created_at | ||
FROM | ||
provisioner_jobs | ||
WHERE | ||
started_at IS NULL | ||
AND | ||
canceled_at IS NULL | ||
AND | ||
completed_at IS NULL | ||
AND | ||
error IS NULL | ||
Comment on lines
+60
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. review: this is in line with the generated provisioner job status: CASE
WHEN (completed_at IS NOT NULL) THEN
CASE
WHEN (error <> ''::text) THEN 'failed'::provisioner_job_status
WHEN (canceled_at IS NOT NULL) THEN 'canceled'::provisioner_job_status
ELSE 'succeeded'::provisioner_job_status
END
ELSE
CASE
WHEN (error <> ''::text) THEN 'failed'::provisioner_job_status
WHEN (canceled_at IS NOT NULL) THEN 'canceling'::provisioner_job_status
WHEN (started_at IS NULL) THEN 'pending'::provisioner_job_status
ELSE 'running'::provisioner_job_status
END
END) |
||
), | ||
queue_position AS ( | ||
SELECT | ||
id, | ||
ROW_NUMBER() OVER (ORDER BY created_at ASC) AS queue_position | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll need to amend this to take into account matching tags. Queue position could be 1/3 for the provisioners that match, but 20/50 on a larger scale (but that's nonsensical). Do we have an issue that tracks this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Account matching tags? Is that provisioner tags? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Take into account 😄. Matching provisioner tags yes 👍🏻 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will create a follow-up issue to track this. 👍 Edit: #15843 |
||
FROM | ||
unstarted_jobs | ||
pending_jobs | ||
), | ||
queue_size AS ( | ||
SELECT COUNT(*) as count FROM unstarted_jobs | ||
SELECT COUNT(*) AS count FROM pending_jobs | ||
) | ||
SELECT | ||
sqlc.embed(pj), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is lovely, but I can't wait to get rid of
dbmem
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a love/hate relationship with dbmem. Part of me will be a bit sad 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m with you @Emyrk, many times it has been a nice way to verify query logic/results by forcing you to reproduce the logic in an alternative way. Still going to be happy that it’s gone though 🥲