jihoonson opened a new pull request #11189:
URL: https://github.com/apache/druid/pull/11189


   ### Description
   
   Most internal APIs used in Druid's ingestion should be idempotent to handle 
transient errors. This PR fixes the idempotence of two APIs used in native 
batch ingestion.
   
   The first API is the segment allocation API used in dynamic partitioning. 
Currently, transient network errors or task failures can lead to non-contiguous 
segment partitionIds allocated by this API. This can be a problem because 
`PartitionHolder` of those segments of non-contiguous partitionIds will be 
never complete in the broker timeline. As a result, everything will look fine, 
that means, the task will succeed, segments will be published into the metadata 
store, historicals will load and announce them, but you will never be able to 
query them.
   
   To fix the segment allocation API, I had to add a new API that accepts extra 
parameters such as `sequenceName` to guarantee the idempotence. This will break 
the rolling upgrade that replaces nodes with a newer version one at a time. To 
resolve this issue, I added a new taskContext, 
`useLineageBasedSegmentAllocation`, to control which protocol to use for 
segment allocation in dynamic partitioning. This context is true by default and 
must be set to false during rolling upgrade. The in-place rolling upgrade is 
not a consideration because batch ingestion doesn't support it.
   
   The second API is the task report API used in all native batch ingestion 
types. This API can handle retries triggered by transient network errors, but 
cannot handle duplicate reports by task retries. As a result, if there is a 
task that failed after sending its report, the supervisor task will count both 
the report of the failed task and that of the retry task. Because of this bug, 
the parallel task can incorrectly estimate the cardinality of partition column 
and the distribution of partition column in hash and range partitioning, 
respectively.
   
   Finally, to test the fix, I added random task failures and API call retries 
(emulating transient network failures) in 
`AbstractParallelIndexSupervisorTaskTest`. All unit tests extending this class, 
such as `CompactionTaskParallelRunTest`, 
`HashPartitionMultiPhaseParallelIndexingTest`, 
`SinglePhaseParallelIndexingTest`, and 
`RangePartitionMultiPhaseParallelIndexingTest`, now run with potential 
transient task failures and API call retries.
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `SinglePhaseParallelIndexTaskRunner`
    * `TaskMonitor`
    * `AbstractParallelIndexSupervisorTaskTest`
   
   <hr>
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not 
all of these items apply to every PR. Remove the items which are not done or 
not relevant to the PR. None of the items from the checklist below are strictly 
necessary, but it would be very helpful if you at least self-review the PR. -->
   
   This PR has:
   - [x] been self-reviewed.
      - [ ] using the [concurrency 
checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md)
 (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [x] 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)
   - [x] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [x] 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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to