Repository navigation
Conversation
This branch has not been deployed
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.
What changes were proposed in this pull request?
When
addRowBatchfails,WriterImplcurrently callsclose()from the catch block. This PR replaces that call with a privateabortOnFailure()that only marks the writer closed, removes it from theMemoryManagerand closes thePhysicalWriter. It also makesaddRowBatchfail fast with anIOExceptionwhen the writer is already closed.Why are the changes needed?
Two problems come from calling
close()on the failure path.close()is virtual. Hive'sorg.apache.hadoop.hive.ql.io.orc.WriterImploverrides it asflushInternalBatch(); super.close();, andflushInternalBatch()hands the buffered batch back toaddRowBatch. When a batch fails (for example a dictionarychunkIndex overflowon a large string column), the sequence isaddRowBatch -> close() -> flushInternalBatch -> addRowBatch -> ...with the same failing batch at every level, untilStackOverflowError. Every level re-inserts the batch into the dictionary, so a single failure turns into hours of CPU before the task reports anything. We captured a live Spark task thread with 26,734 frames, 8,811 of them this loop. After the stack unwinds, Spark'sabort()callsclose()again and the whole recursion starts over.close()flushes the current stripe and writes a footer for a writer that just failed mid-batch. The result is a file that reads fine but silently misses rows. A failed write should leave a file that is obviously incomplete, not one that masquerades as complete.This mirrors what Parquet did in PARQUET-2437 : record the failure, stop flushing, and let
close()return without a footer.How was this patch tested?
Was this patch authored or co-authored using generative AI tooling?
Yes, co-authored with Claude Code (Claude Fable 5.1)