Skip to content

Duplicate in-flight prompt IDs can break heap insertion for equal priorities #16952

Open

Description

@denio-machete

Submitting the same canonical prompt_id with the same queue number and a different prompt can raise TypeError inside heapq.heappush, after appending the second entry.

Verified at 7f7fd918ed0815c5d5ef2ccfe44bfc8e72cfd217: /prompt accepts caller UUIDs and numbers and enqueues (number, prompt_id, prompt, ...). PromptQueue.put pushes without checking whether that ID is already pending/running. Equal first two tuple fields make Python compare the two dictionaries.

Minimal Python mechanism (no models or server required):

import heapq
q = []
id = "00000000-0000-4000-8000-000000000001"
heapq.heappush(q, (1.0, id, {"node": "first"}))
heapq.heappush(q, (1.0, id, {"node": "second"}))  # TypeError; q now has two entries

Expected: duplicate in-flight IDs are rejected before insertion under the queue mutex, and the HTTP handler returns a clear client error. The queue remains valid and the first submission stays intact. Checking only outside the mutex leaves a concurrent-submission race.

Acceptance:

  • Equal number/UUID with distinct prompts rejects the second submission without heap mutation.
  • Pending and currently-running ID collisions are both covered.
  • Distinct IDs still queue normally, including equal priorities.
  • The route maps rejection to a clear error response.
  • Completed-history ID reuse is considered separately; this bug does not require choosing that policy.

Scoped duplicate/queue/heapq issue and PR searches found no matching report. Merged #8189 introduced caller IDs; #1300 concerns queue growth performance; #15341 concerns lifecycle hooks.

This is a source/synthetic finding. No live queue, model, media generation, provider call, or production service was used.

Activity

  1. denio-machete commented on Oct 11, 2026

    @denio-machete
    Author

    Local source proposal independently reviewed at 6a069e36b85df7e79f497ec00459b69e2cd9445e from exact upstream 7f7fd918ed0815c5d5ef2ccfe44bfc8e72cfd217.

    The queue rejects pending/running duplicate IDs under its existing mutex before heap mutation; the route maps rejection to HTTP409. Automatic queue-number assignment retains its original placement before asynchronous validation, so this fix preserves request priority semantics. Completed-history reuse remains unchanged.

    Retained extracted-actual-source evidence passed four cases: pending/running duplicates, history reuse, distinct IDs at equal priority, eight concurrent duplicate submissions with one winner, and route conflict/counter behavior. The upstream branch now contains small direct-module and aiohttp route tests instead of the larger private extraction harness. Those committed tests and release checks remain UNRUN in a dependency-complete checkout; the local source proposal is not release acceptance.

    No live queue, full Comfy module import, model, provider or service was used. Source branch remains local; no push/PR/deployment. The issue remains open. Correct final-tree binary diff SHA256: 8b4d590b14d3ad59fa0f67e485991502b9df0c90ba02a0fbcca46359e8d8b48b.

  2. added 5 commits that reference this issue on Oct 13, 2026
    e5b2f15
    d1812b8
    c05c8b9
    e1d371d
    3e6fe6f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions