A retain whose write transaction fails repeats its fact extraction on the task retry
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 53/100
Research direction
Start in engine/retain/orchestrator.py and trace how _run_delta_db_work and _run_mini_batch_db_work handle write failures after extraction. Read the history of commit 5aa3de601 and issues #7216 and #7217 for the remaining lock-order cycles. Done means a bounded retry reruns the write phase within the same task using extracted facts, while a later task retry still starts from extraction.
Written by the indexing model from the issue text.
Description
Bug Description
When a retain's write transaction fails after fact extraction, the worker retries the whole task, and the retry runs the LLM extraction again for the same chunks.
_run_delta_db_work and _run_mini_batch_db_work (engine/retain/orchestrator.py) run outside retry_with_backoff, so a DeadlockDetectedError or an asyncpg TimeoutError in the write phase fails the task. The poller schedules a retry (HINDSIGHT_API_WORKER_TASK_RETRY_BACKOFF_SECONDS), and the retried task starts from extraction. The extracted facts and embeddings of the failed attempt are not kept, though nothing about them changed: PostgreSQL rolled back only the write. _run_delta_db_work already resets its per-attempt state (log buffer, fact document and chunk ids, pending entity stats) at its start.
5aa3de601 removed retry_with_backoff from both write phases because sorted inserts prevent deadlocks. #7216 and #7217 are two lock-order cycles that still occur on 1.3.1.
Steps to Reproduce
- Run two workers on one bank with the default
HINDSIGHT_API_RETAIN_MAX_CONCURRENT=4. - Retain a few hundred changed documents into the bank at once, so that write phases overlap.
- Read the bank's LLM request traces:
GET /v1/default/banks/{bank_id}/llm-requests?scope=retain_extract_facts. Group the calls bymetadata.operation_idand by the hash of the user message.
Expected Behavior
A write phase that PostgreSQL aborts as a deadlock victim runs again in the same task with the facts already extracted, a bounded number of times, before the task fails. A task retry after that reuses nothing it cannot trust, as today.
Actual Behavior
One bank, 24 hours on 1.3.1: 3,051 retain_extract_facts calls, of which 934 extracted a chunk that the same operation had already extracted. The worker log in the same window shows 75 task retries after DeadlockDetectedError and 43 after TimeoutError in the write phase. Each retry repeats every extraction call of the operation; three retries of a 20-chunk document cost 80 extraction calls instead of 20.
Version
1.3.1
LLM Provider
Gemini (Vertex AI)
- Dominant language
- Python
- Stars
- 45.2k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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 vectorize-io/hindsight
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vectorize-io/hindsight#7254 ·
-
Control Plane shows different calendar dates for the same occurrence in Constellation and TimelineOpencore
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vectorize-io/hindsight#7240 · 1 comment ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vectorize-io/hindsight#7233 ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
vectorize-io/hindsight#7231 ·
-
core
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
vectorize-io/hindsight#7228 · 1 comment ·
All issues in vectorize-io/hindsight
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day