fix(service): coalesce duplicate EnqueueTaskForIssue on the assignee path (#5914) - #6304
Open
kakiuwang-ui wants to merge 1 commit into
Open
Conversation
…path (multica-ai#5914) Follow-up to multica-ai#5958, which mapped the duplicate-pending-task race to ErrDuplicatePendingTask on the mention path (enqueueMentionTaskWithCommentPlan) but left the issue-assignee path untouched. enqueueIssueTaskWithCommentPlan is the second write point of the idx_one_pending_task_per_issue_agent unique index, so a concurrent duplicate there still logged at ERROR and surfaced as a generic create-task error (HTTP 500 leaking the raw constraint name). - enqueueIssueTaskWithCommentPlan: reuse isDuplicatePendingTaskErr and return the existing ErrDuplicatePendingTask sentinel (slog.Debug, not Error) on the race — identical treatment to the mention path. - enqueueSingleCommentTrigger (issue-assignee case): switch the plain slog.Warn to the shared logCommentEnqueueFailure helper so the now-typed sentinel is downgraded to debug and resolveCommentTriggerEnqueue can coalesce, matching the sibling squad-leader and mention cases. - Add TestEnqueueTaskForIssueCoalescesDuplicatePendingTask alongside the mention-path regression: a second EnqueueTaskForIssue for the same (issue, agent) returns ErrDuplicatePendingTask, does not leak the constraint name/SQLSTATE, and leaves exactly one pending task. Fixes the remaining EnqueueTaskForIssue case called out in multica-ai#5938.
|
@kakiuwang-ui is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #5958, opened at the maintainer's suggestion on #5938:
Problem
#5958 mapped the duplicate-pending-task race to
ErrDuplicatePendingTaskon themention path (
enqueueMentionTaskWithCommentPlan), but the issue-assigneepath was left untouched.
enqueueIssueTaskWithCommentPlanis the second writepoint of the
idx_one_pending_task_per_issue_agentunique index, so a concurrentduplicate there still logged at
slog.Errorand returned a generic wrappedcreate-task error — the same HTTP 500 with the leaked constraint name that #5914
set out to remove.
Changes
server/internal/service/task.goenqueueIssueTaskWithCommentPlan: reuse the existingisDuplicatePendingTaskErrhelper and return the existing
ErrDuplicatePendingTasksentinel (slog.Debug,not
Error) on the race — identical treatment to the mention path. No newhelper or sentinel is introduced.
server/internal/handler/comment.goenqueueSingleCommentTrigger(issue-assignee case): the plainslog.Warnwasleft in place by fix(handler,service): map duplicate-key violations to 409/coalesced instead of 500 (MUL-5285) #5958 precisely because this path never returned the sentinel
yet. Now that it does, switch to the shared
logCommentEnqueueFailurehelper sothe benign race is downgraded to debug and
resolveCommentTriggerEnqueuecoalesces — matching the sibling squad-leader and mention cases directly above.
server/internal/service/duplicate_pending_task_test.goTestEnqueueTaskForIssueCoalescesDuplicatePendingTasknext to the existingmention-path regression: a second
EnqueueTaskForIssuefor the same(issue, agent) returns
ErrDuplicatePendingTask, does not leak the constraintname / SQLSTATE, and leaves exactly one pending task.
Other
EnqueueTaskForIssuecallers (autopilot.go,issue.go,onboarding_shim.go) are intentionally out of scope: they already logged/wrappedthe pre-existing generic error, so their severity is unchanged; the sentinel is
now available via
errors.Isshould they want to special-case it later.Test plan
go test ./internal/service/ ./internal/handler/against live Postgres(migrated to latest, 251) — all pass, including the new regression test.
go vet ./internal/handler/ ./internal/service/clean; changed filesgofmt-clean.Refs #5914, #5958, #5938