Skip to content

fix(retain): thread ops into handle_document_tracking - #1358

Closed
youchi1 wants to merge 1 commit into
vectorize-io:mainfrom
youchi1:fix/handle-document-tracking-ops
Closed

fix(retain): thread ops into handle_document_tracking#1358
youchi1 wants to merge 1 commit into
vectorize-io:mainfrom
youchi1:fix/handle-document-tracking-ops

Conversation

@youchi1

@youchi1 youchi1 commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Bug

Regression from #1325. fact_storage.py:312 was changed to call delete_stale_observations_for_memories(..., ops=ops) but ops was never added to handle_document_tracking's signature, so every first-batch retain raises:

NameError: name 'ops' is not defined

Effect

Every batch_retain task fails on the first-batch document tracking path. Poller retries, fails again, parent operation gets marked failed. No memories get stored. The gateway log misleadingly shows retains captured because dispatch succeeded.

Fix

Add ops=None to handle_document_tracking's signature. Pass ops=pool.ops from both call sites in orchestrator._streaming_retain_batch. 3 lines changed.

Verified

Reproduced on a live deployment running main as of d8ec2d7. Patch applied, retain plus background consolidation now succeed end to end (created=6 updated=3 on first run after fix).

Regression from vectorize-io#1325 (perf(db): eliminate ResultRow wrapping). Line
fact_storage.py:312 was changed to pass ops=ops to
delete_stale_observations_for_memories, but ops was never added to
handle_document_tracking's signature, so every first-batch retain hit
NameError: name 'ops' is not defined.

Effect: every batch_retain task fails on the first-batch document
tracking path. The poller schedules a retry, the retry fails the same
way, and after the retry budget is exhausted the parent operation is
marked failed. No memories get stored. The gateway's
"hindsight: 1 retains (...) captured" log is misleading — that just
means dispatch succeeded; the daemon's actual write path was raising
all along.

Fix is to give handle_document_tracking an ops parameter (defaulting
to None to preserve the Oracle/junction-table fallback) and pass
pool.ops from both call sites in orchestrator._streaming_retain_batch.

Reproducible on any retain that triggers a first-batch document
upsert. Verified against the daemon's structured log on a live
deployment running main as of d8ec2d7.
@nicoloboschi

Copy link
Copy Markdown
Collaborator

fixed already in #1343

@youchi1
youchi1 deleted the fix/handle-document-tracking-ops branch May 4, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants