Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

johnstcn
Copy link
Member

When calculating the queue position inGetProvisionerJobsByIDsWithQueuePosition we only counted jobs withstarted_at = NULL. This is misleading, as it allows canceling or canceled jobs to take up rows in the computed queue position, giving an impression that the queue is larger than it really is.

This modifies the query to also exclude jobs with a nullcanceled_at,completed_at, orerror field for the purposes of calculating the queue position, and also adds a test to validate this behaviour.

(Note: due to the behaviour ofdbgen.ProvisionerJob withdbmem I had to use other proxy methods to validate the corresponding dbmem implementation.)

Emyrk reacted with thumbs up emoji
@@ -50,23 +50,29 @@ WHERE
id = ANY(@ids :: uuid [ ]);

-- name: GetProvisionerJobsByIDsWithQueuePosition :many
WITHunstarted_jobs AS (
WITHpending_jobs AS (
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

review: Renamed for clarity.

dannykopping reacted with thumbs up emoji
Comment on lines +60 to +65
AND
canceled_at IS NULL
AND
completed_at IS NULL
AND
error IS NULL
Copy link
MemberAuthor

Choose a reason for hiding this comment

The 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_atIS NOT NULL) THEN    CASE        WHEN (error<>''::text) THEN'failed'::provisioner_job_status        WHEN (canceled_atIS 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_atIS NOT NULL) THEN'canceling'::provisioner_job_status        WHEN (started_at ISNULL) THEN'pending'::provisioner_job_status        ELSE'running'::provisioner_job_status    ENDEND)

Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For fixing the mentioned issue, this LGTM, nice work. Down the line I think we need to address provisioner matching for these queries too.

johnstcn reacted with thumbs up emoji
AND
completed_at IS NULL
AND
error IS NULL
),
queue_position AS (
SELECT
id,
ROW_NUMBER() OVER (ORDER BY created_at ASC) AS queue_position
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Account matching tags? Is that provisioner tags?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Take into account 😄. Matching provisioner tags yes 👍🏻

Copy link
MemberAuthor

@johnstcnjohnstcnDec 12, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Will create a follow-up issue to track this. 👍

Edit:#15843

mafredri reacted with thumbs up emoji
Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Neat we are adding this kinda of stuff 👍

@@ -3804,35 +3804,92 @@ func (q *FakeQuerier) GetProvisionerJobsByIDsWithQueuePosition(_ context.Context
q.mutex.RLock()
defer q.mutex.RUnlock()

jobs := make([]database.GetProvisionerJobsByIDsWithQueuePositionRow, 0)
queuePosition := int64(1)
//WITH pending_jobs AS (
Copy link
Contributor

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 ofdbmem.

johnstcn reacted with thumbs up emoji
Copy link
Member

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 😆

Copy link
Member

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 🥲

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
@johnstcnjohnstcn merged commit36c2cf8 intomainDec 12, 2024
30 checks passed
@johnstcnjohnstcn deleted the cj/ignore-canceled-provisioner-jobs-in-queue-position branchDecember 12, 2024 12:37
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsDec 12, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

@EmyrkEmyrkEmyrk approved these changes

@dannykoppingdannykoppingdannykopping approved these changes

@SasSwartSasSwartAwaiting requested review from SasSwart

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@johnstcn@mafredri@dannykopping@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp