Build resource cleanup is unrecoverable when Celery publication fails
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 18/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- postgresql, python, sqlite
- Domain
- backend, databases, distributed-systems
Research direction
Start from the post-commit boundary where collect_agent_resources.delay() is published after the execution binding is set to RETIRED, and trace the four affected flows (conversation refresh, forced draft checkout, draft discard, draft apply). The regression harness injects RuntimeError("test broker unavailable") at that real publication point and asserts recovery for refresh, discard and apply. Done means the retirement and a durable outbox intent commit in one transaction, claimed attempts republish from the existing retention queue, and the intent is deleted only after idempotent backend cleanup.
Written by the indexing model from the issue text.
Description
Summary
Build execution-binding retirement is committed before its Celery cleanup task is published. If publication fails, the API request returns an error but the retired binding no longer has a durable dispatch record. The backend binding and workspace can then remain allocated without a way for a later retry to discover them.
Affected flows
The post-commit publication boundary is used by Build conversation refresh, forced draft checkout, draft discard, and draft apply. The impact is especially clear for apply because a successful apply deletes the personal Build draft before cleanup is published. Retrying the request cannot reconstruct the retired binding from that draft.
Steps to reproduce
- Create a personal Build draft with an active execution binding.
- Let the Build mutation commit successfully, then make
collect_agent_resources.delay()raise a broker error. - Observe that the request returns HTTP 500 while the binding is already
RETIREDand the draft pointer is cleared, or the draft is deleted by apply. - Retry the operation or inspect the remaining state. There is no persistent cleanup intent from which to republish the retired binding.
The regression harness uses a deterministic RuntimeError("test broker unavailable") at the real Celery publication boundary. Before the fix, refresh and discard both fail the recovery assertion, and apply leaves no recovery record after deleting its draft.
Expected behavior
Retirement and a durable cleanup dispatch intent should commit atomically. Publication should happen only after that commit. A broker failure should retain the intent for bounded retries, and successful physical cleanup should settle it idempotently.
Repeated delivery remains possible, so this does not require exactly-once delivery. It does require a durable recovery key and cleanup that is safe to repeat.
Actual behavior
The retired binding is persisted, but its only cleanup publication is attempted in memory after the commit. A publication exception is propagated without a durable retry record.
Proposed direction
Add a Build-scoped transactional outbox containing the tenant and binding IDs, attempt generation, last attempt time, and a bounded error type. Claim attempts with a conditional update, republish them from the existing retention queue, and delete an intent only after successful idempotent backend cleanup at the same claim generation. Retain exhausted records for operator review instead of silently dropping them.
Validation for the proposed patch uses Python 3.13.11, SQLite, an in-memory broker, and a loopback checkpoint server. It does not claim a hosted Postgres, external Celery broker, or production Agent backend verification.
- Dominant language
- Python
- Stars
- 162k
- Forks
- 25.6k
- Avg merge
- 15h 9m
- Merged PRs (30d)
- 606
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from langgenius/dify
-
OpenSearch: text_exists() queries OpenSearch _id instead of metadata.doc_id, so it always returns False for indexed chunksPossibly taken @SanemIzci claimed this 1 day ago. Open🐞 bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
langgenius/dify#47109 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Log only execution identifiers when a workflow worker starts a runPossibly taken @kinglegendzzh claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langgenius/dify#47094 · 2 reactions ·
Maintainers usually reply within 1 day
-
Node.js SDK declares a response body for 204 conversation deletionPossibly taken @Wang-Zephyr claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
langgenius/dify#46883 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Provider IDs with a trailing newline are silently accepted and propagatedPossibly taken @Batianxieshen1 claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
langgenius/dify#46875 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Agent Python SDK polling rejects function-tool results that SSE acceptsPossibly taken @EndlessRoad-max claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
langgenius/dify#46868 · 1 reaction ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
micronaut-projects/micronaut-core#14585 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
langgenius/graphon#443 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
[BUG]: Management endpoints /v1/memory/stats and /v1/memory/counts bypass API key authenticationOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
docling-project/docling-serve#788 ·
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
opensearch-project/cross-cluster-replication#1805 ·
Maintainers usually reply within 1 day