[Fix][HiveSink] Implement overwrite semantics for streaming commits to prevent multiple deletions of target directories #10279
+505
−15
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.
Purpose of this pull request
When running SeaTunnel on Flink in STREAMING mode with Hive sink
overwrite: true, the final Hive partition/table directory may lose previously committed files and end up containing only a subset of data (often only files from the last checkpoint).Reproduction
env.job.mode = "STREAMING"overwrite: true'2025-12-16' as pt, so all records go to the same partition)Root Cause
overwrite: trueis normalized toDataSaveMode.DROP_DATA. InHiveSinkAggregatedCommitter#commit(...), the implementation deleted the target table/partition directories before every commit. In Flink streaming,commit()is invoked after every completed checkpoint, so the delete step was executed repeatedly and wiped files committed by earlier checkpoints.Fix
Implemented overwrite semantics that are safe for streaming checkpoints:
checkpointIdfromtransactionDir(pattern like.../T_xxx_<subtaskIndex>_<checkpointId>). If the first checkpoint id seen by this committer is> 1(usually indicates recovery from a previous checkpoint), skip deletion to avoid removing already committed data that matches the restored state.Does this PR introduce any user-facing change?
no
How was this patch tested?
yes,UT and tested in our test env.
Check list
New License Guide
incompatible-changes.mdto describe the incompatibility caused by this PR.