Repository navigation
Return an error when parsing runs out of memory - #394
Open
R3gardless wants to merge 1 commit into
Open
R3gardless wants to merge 1 commit into
R3gardless wants to merge 1 commit into
Conversation
The PG_CATCH blocks copied the error data in the same memory context that had just run out of memory, so the allocation failed again outside of PG_TRY and the error was promoted to FATAL, terminating the process. Parse in a child context and delete it before copying the error data, and reset the context before copying it in the JSON and protobuf output too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #389.
When parsing runs out of memory, the
PG_CATCHblocks inpg_query_parse.ccallCopyErrorData()while everything the parser allocated is still there. That allocation fails as well, outside ofPG_TRY, so the error is promoted to FATAL and the process exits.This parses in a child context and deletes it before copying the error data, and resets the context before copying it in the JSON and protobuf output. With the reproduction from the issue,
pg_query_parse(),pg_query_parse_protobuf()andpg_query_fingerprint()now return an "out of memory" error at 300MB and 600MB instead of exiting.make testpasses with and without Valgrind.pg_query_parse_plpgsql()and the fingerprinting step itself need similar changes. I left them out to keep this small, and can send a follow-up if this approach looks fine to you. The protobuf segfault at 1200MB is a separate problem.