Repository navigation
[fix](fe) Preserve Kinesis initial shard position state - #67879
Closed
0AyanamiRei wants to merge 1 commit into
Closed
0AyanamiRei wants to merge 1 commit into
0AyanamiRei wants to merge 1 commit into
Conversation
### What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary: Kinesis Routine Load used an empty progress map as the signal that a job was undergoing its initial shard setup. This is not a valid lifecycle invariant: after a closed parent shard is fully consumed, KinesisProgress removes that shard, and the progress map can become empty even though the job has already completed its initial positioning.
If a reshard creates a child shard before the next FE refresh, updateNewShardProgress() sees an empty progress map and treats the child as an initial shard. It applies the configured LATEST position, which starts after the current tip and skips records written to the child before FE discovers it. The same state could be lost across image recovery because the previous implementation had no durable job-level initialization marker.
Keep initial-position state separate from the current set of tracked shards. New jobs start with the marker unset, and the marker is set after initial shard positions are established or a Kinesis task transaction is processed. Later shards therefore start at TRIM_HORIZON even when all prior shard progress has been removed. The marker is serialized in the Kinesis routine load job image, recovered for legacy images from their persisted lifecycle state, and reset when ALTER changes the stream and clears progress.
### Release note
Prevent Kinesis Routine Load from skipping records on newly discovered child shards after parent shard progress is exhausted.
### Check List (For Author)
- Test: Unit Test
- `./run-fe-ut.sh --run org.apache.doris.load.routineload.KinesisRoutineLoadJobTest`
- 10 tests passed, 0 failures, 0 errors, 0 skipped
- `build-support/check-build-hygiene.sh` passed
- `build-support/check-format.sh` passed
- `git diff --check` passed
- Behavior changed: Yes. Initial shards preserve the configured default position; shards discovered after initial setup use TRIM_HORIZON.
- Does this need documentation: No. This fixes the existing Kinesis shard lifecycle behavior.
The unit test directly invokes the production FE updateNewShardProgress() path. It models initial shard positioning, removal of the completed parent from progress, and discovery of a child shard, then verifies that the child uses TRIM_HORIZON. No AWS resource is created by this test.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
0AyanamiRei
marked this pull request as draft
September 15, 2026 19:08
Contributor
Author
|
draft,计划是希望对routine load kinese先去持久化的维护一个shards父子关系的拓扑图 |
Contributor
Author
|
Superseded by the Kinesis shard topology change, closing this draft without merging it as-is. The problem this PR fixes is real and is covered, but the marker it introduces would duplicate topology state:
The regression is covered by the new tests:
|
0AyanamiRei
added a commit
to 0AyanamiRei/doris
that referenced
this pull request
Sep 23, 2026
### What problem does this PR solve? Issue Number: None Related PR: apache#67678, apache#67696, apache#67869, apache#67874, apache#67879 Problem Summary: Kinesis shards can split and merge while a routine load job is running. Maintaining only open/closed shard lists and progress cannot express parent-child lineage or the COMMITTED-to-VISIBLE completion barrier, which can schedule children too early, lose lineage, or recreate completed parents. This change adds a durable shard topology state machine, concrete initial-position persistence, idempotent journal/image replay, and Kinesis BE progress handling for EOF and ChildShards metadata. New FE, BE, and regression coverage verifies shard transitions, transaction visibility, latest-position resolution, reshard boundaries, and deterministic Kinesis upstream behavior. ### Release note Add parent-child shard topology tracking and visibility-gated scheduling for Kinesis Routine Load. ### Check List (For Author) - Test: Unit Test - `./run-be-ut.sh --run --filter='*Kinesis*' -j48` - Result: 18 Kinesis tests passed - No FE unit test or AWS regression test was run in this environment. - Behavior changed: Yes (Kinesis Routine Load now schedules shards through the topology state machine.) - Does this need documentation: No
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 problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary:
Kinesis Routine Load used an empty progress map as the signal that a job was undergoing its initial shard setup. This is not a valid lifecycle invariant. When a closed parent shard is fully consumed,
KinesisProgress.update()removes that shard from the progress map. The map can therefore become empty after the job has already completed its initial positioning.A reshard can create child shards before the next FE metadata refresh. In that window,
KinesisRoutineLoadJob.updateNewShardProgress()sees an empty progress map and treats the children as initial shards. It applies the configuredLATESTposition. KinesisLATESTstarts after the current tip, so records written to the children before FE discovers them are skipped.The fix stores this lifecycle state separately from the currently tracked shard positions:
kinesisInitialPositionSet = false.TRIM_HORIZON, even when the progress map is empty.The test directly invokes the production FE method and models the complete boundary: initial shard setup with
LATEST, removal of the completed parent from progress, and discovery of a child shard. It verifies that the child receivesTRIM_HORIZON. Additional assertions cover transaction progress handling, image serialization, and stream-change reset.Release note
Prevent Kinesis Routine Load from skipping records on newly discovered child shards after parent shard progress is exhausted.
Check List (For Author)
./run-fe-ut.sh --run org.apache.doris.load.routineload.KinesisRoutineLoadJobTestexpected: <-2> but was: <LATEST>cd fe && mvn checkstyle:check -pl fe-core -Dcheckstyle.skip=falsepassedbuild-support/check-build-hygiene.shpassedbuild-support/check-format.shpassedgit diff --checkpassedTRIM_HORIZON.The FE unit test was chosen because R4 is a frontend lifecycle-state bug. It calls the production
KinesisRoutineLoadJobimplementation and avoids a timing-dependent AWS integration setup. No AWS credentials were read and no Kinesis stream was created.This PR is based on
origin/masterand contains only the R4 implementation and its FE unit-test coverage. Existing Kinesis BE consumer fixes remain separate.Check List (For Reviewer who merge this PR)