8000 fix(xbrl): stop retrying a document that ran out of memory by stoyanov-x · Pull Request #4813 · daniel3303/Equibles · GitHub
[go: up one dir, main page]

Skip to content
8000

fix(xbrl): stop retrying a document that ran out of memory - #4813

Closed
stoyanov-x wants to merge 1 commit into
daniel3303:mainfrom
stoyanov-x:xbrl-oom-no-retry
Closed

stoyanov-x wants to merge 1 commit into
daniel3303:mainfrom
stoyanov-x:xbrl-oom-no-retry

Conversation

@stoyanov-x
@stoyanov-x stoyanov-x commented Oct 20, 2026 •
Copy link
Copy Markdown
Contributor

Part of #4812.

XbrlFactsExtractionWorker counts an attempt on any per-document fault and lets the document be retried until MaxXbrlFactsAttempts. That is correct for transient faults. An OutOfMemoryException on a large filing is not one: every retry hits the same wall, spends the whole retry budget, and leaves repeated OOM rows in Errors — which read like a data gap rather than a signal.

This adds an explicit catch (OutOfMemoryException) that marks the document exhausted, mirroring what the fiscal-calendar branch already does for evidence that cannot change on retry.

This parks the document — deliberately, and reversibly

XbrlFactsAttempts = MaxXbrlFactsAttempts means the document is never re-attempted automatically, so it will not silently retry forever or silently succeed later. To put parked documents back into rotation once the underlying cause is fixed:

UPDATE "Document" SET "XbrlFactsAttempts" = 0 WHERE "XbrlFactsAttempts" >= <MaxXbrlFactsAttempts>;

Why this is Part of, not Closes

Measured on a 1.25 GiB worker cgroup: the OOM still reproduced 30 minutes after this shipped (alongside the streaming changes), with memory.peak sitting at the cgroup ceiling. This stops the retry loop; it does not stop the OOM. The remaining levers are the worker memory limit and the inline path, which still builds two DOMs per filing.

Re-arm semantics unchanged: a parked document stays parked until someone resets the counter, and the recovery path is documented above so it cannot be forgotten.

Closes daniel3303#4812.

The per-document catch-all counts an attempt and lets the document be retried
until MaxXbrlFactsAttempts. That is right for transient faults, but an
OutOfMemoryException on a large filing is deterministic: every retry hits the same
wall, spends the retry budget, and leaves repeated OOM rows in Errors - which
looks like a data gap rather than a signal.

Handle OOM explicitly and mark the document exhausted, mirroring what the
fiscal-calendar branch already does for evidence that cannot change on retry. The
heap is left alone: after an OOM its state is not something to reason about, so
this only stops the loop.

A streaming rewrite of InlineXbrlParser/StandaloneXbrlParser is the real fix (peak
memory independent of filing size) - that is a larger change and belongs in its
own PR.
@daniel3303
Copy link
Copy Markdown
Owner

I'm leaving this one until it's out of draft. Two points for when it is:

  • An OutOfMemoryException is not always deterministic: it can come from memory pressure created by other work in the same process, and this change parks the document after a single hit. Once the DOM costs are gone, the existing attempt budget may be the safer behaviour.
  • The body says Closes #4812, but your comment on perf(xbrl): stream standalone instances instead of building a DOM #4814 says neither PR alone should close it.

A.L.V.I.S.

@stoyanov-x stoyanov-x changed the title xbrl: stop retrying a document that ran out of memory fix(xbrl): stop retrying a document that ran out of memory Oct 21, 2026
@daniel3303
Copy link
Copy Markdown
Owner

Closing this, for the reasons in my earlier comment. An OutOfMemoryException in this worker often comes from memory pressure caused by other work in the same process, so parking a document after one hit loses filings that would succeed on a later attempt. Carrying on with the batch after an OOM also leaves the process in an unknown state.

The existing attempt budget is the safer behaviour, and #4814 removes the DOM cost on the standalone path. #4812 stays open for the inline path.

A.L.V.I.S.

@daniel3303 daniel3303 closed this Nov 1, 2026
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

0