Akshat-Jain opened a new pull request, #16606:
URL: https://github.com/apache/druid/pull/16606
### Description
This PR adds retries to handle connection reset errors during
GZIPInputStream. We were running into the following error if the connection
resets in the middle of ingesting a gz file, causing the ingestion task to fail:
```
java.lang.RuntimeException: java.lang.IllegalStateException:
java.io.EOFException: Unexpected end of ZLIB input stream
at org.apache.druid.java.util.common.Either.valueOrThrow(Either.java:95)
at
org.apache.druid.frame.processor.FrameProcessorExecutor$1ExecutorRunnable.runProcessorNow(FrameProcessorExecutor.java:259)
at
org.apache.druid.frame.processor.FrameProcessorExecutor$1ExecutorRunnable.run(FrameProcessorExecutor.java:138)
at org.apache.druid.msq.exec.WorkerImpl$1$2.run(WorkerImpl.java:840)
at
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
org.apache.druid.query.PrioritizedListenableFutureTask.run(PrioritizedExecutorService.java:259)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalStateException: java.io.EOFException: Unexpected
end of ZLIB input stream
at
org.apache.druid.data.input.impl.FastLineIterator.readNextLine(FastLineIterator.java:124)
at
org.apache.druid.data.input.impl.FastLineIterator.hasNext(FastLineIterator.java:91)
at org.apache.druid.data.input.TextReader$1.hasNext(TextReader.java:80)
at
org.apache.druid.data.input.IntermediateRowParsingReader$1.hasNext(IntermediateRowParsingReader.java:66)
at
org.apache.druid.java.util.common.parsers.CloseableIterator$2.findNextIteratorIfNecessary(CloseableIterator.java:72)
at
org.apache.druid.java.util.common.parsers.CloseableIterator$2.hasNext(CloseableIterator.java:93)
at
org.apache.druid.java.util.common.parsers.CloseableIterator$1.hasNext(CloseableIterator.java:42)
at
org.apache.druid.msq.input.external.ExternalSegment$1$1.hasNext(ExternalSegment.java:95)
at
org.apache.druid.java.util.common.guava.BaseSequence$1.next(BaseSequence.java:115)
at org.apache.druid.segment.RowWalker.advance(RowWalker.java:75)
at
org.apache.druid.segment.RowBasedCursor.advanceUninterruptibly(RowBasedCursor.java:110)
at
org.apache.druid.segment.RowBasedCursor.advance(RowBasedCursor.java:103)
at
org.apache.druid.msq.querykit.scan.ScanQueryFrameProcessor.populateFrameWriterAndFlushIfNeeded(ScanQueryFrameProcessor.java:342)
at
org.apache.druid.msq.querykit.scan.ScanQueryFrameProcessor.populateFrameWriterAndFlushIfNeededWithExceptionHandling(ScanQueryFrameProcessor.java:309)
at
org.apache.druid.msq.querykit.scan.ScanQueryFrameProcessor.runWithSegment(ScanQueryFrameProcessor.java:248)
at
org.apache.druid.msq.querykit.BaseLeafFrameProcessor.runIncrementally(BaseLeafFrameProcessor.java:89)
at
org.apache.druid.msq.querykit.scan.ScanQueryFrameProcessor.runIncrementally(ScanQueryFrameProcessor.java:156)
at
org.apache.druid.frame.processor.FrameProcessors$1FrameProcessorWithBaggage.runIncrementally(FrameProcessors.java:75)
at
org.apache.druid.frame.processor.FrameProcessorExecutor$1ExecutorRunnable.runProcessorNow(FrameProcessorExecutor.java:230)
... 8 more
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
at
java.base/java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:245)
at
java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:159)
at
java.base/java.util.zip.GZIPInputStream.read(GZIPInputStream.java:118)
at
org.apache.druid.data.input.BytesCountingInputEntity$BytesCountingInputStream.read(BytesCountingInputEntity.java:108)
at java.base/java.io.FilterInputStream.read(FilterInputStream.java:107)
at
org.apache.druid.data.input.impl.FastLineIterator.readNextLine(FastLineIterator.java:120)
... 26 more
```
This PR wraps the GZIPInputStream in a retry wrapper using a new class
`RetryingGZIPInputStream` that handles such connection failures, and tries to
continue the operation using retries.
### Test plan
1. I setup a simple http server using Python’s utility: `python -m
http.server 9333` - I had wikipedia.json.gz in the same directory for the
server to serve.
2. I triggered an MSQ ingestion using HTTP source as
`http://localhost:9333/wikipedia.json.gz`
3. I exited the Python process immediately after starting the ingestion.
4. I verified that the task was failing at this point prior to this PR's
changes. But with this PR's changes, retry mechanism kicks in.
5. I re-ran the Python server in the middle of the ongoing retries.
6. Validated that the next retry iteration was able to continue and take the
task to successful completion.
7. Verified that the number of rows ingested was correct. Also tried
querying the data, works fine.
##### Key changed/added classes in this PR
* `RetryingGZIPInputStream`: Class to facilitate retries over a
GZIPInputStream.
* `RetryingInputStreamUtils`: A utils class to extract common functionality
between `RetryingGZIPInputStream` and `RetryingInputStream`.
This PR has:
- [x] been self-reviewed.
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked
related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code
wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths,
ensuring the threshold for [code
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]