[fix](fe) Preserve Kinesis initial shard position state - #67879
Open
0AyanamiRei wants to merge 1 commit into
Open
[fix](fe) Preserve Kinesis initial shard position state#678790AyanamiRei 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:
|
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)