Skip to content

Fix stored-fields frame leak when PerField#finish throws - #16553

Open
michaeljmarshall wants to merge 5 commits into
apache:mainfrom
michaeljmarshall:store-field-frame-leak
Open

Fix stored-fields frame leak when PerField#finish throws#16553
michaeljmarshall wants to merge 5 commits into
apache:mainfrom
michaeljmarshall:store-field-frame-leak

Conversation

@michaeljmarshall

Copy link
Copy Markdown
Member

Description

startStoredFields is called unconditionally before the try block in processDocument and processRowColumns. If fields[i].finish() throws (e.g. a Similarity whose computeNorm returns 0 for a non-empty field), finishStoredFields was skipped, leaving the codec writer with an unmatched startDocument. At flush, writer.finish(maxDoc) sees fewer completed docs than expected and throws "Wrote N docs, finish called with numDocs=M".

Fixed by wrapping the finish loop in a try/finally that guarantees finishStoredFields runs. Same fix applied to both processDocument and processRowColumns.

@martijnvg martijnvg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@javanna javanna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants