hutiefang76 opened a new pull request, #13658:
URL: https://github.com/apache/seatunnel/pull/13658

   ### Purpose of this pull request
   
   Yes, this contribution to Apache SeaTunnel fixes Hive batch overwrite data 
loss on Flink 1.20.
   
   Closes #13453.
   
   Parallel Flink committer subtasks currently create independent Hive 
aggregated committers. Each can clear the same table or partition directory 
after another has published its files. The Flink 1.20 adapter now forwards 
aggregate-only committables to one global operator while retaining parallel 
writers. It uses Flink's committable collector and checkpoint state, and 
supplies the restored checkpoint boundary to the actual aggregated committer 
before replay.
   
   The Hive committer also checks the complete batch for moves whose source 
file is gone and exact target is present before deleting any directory. This 
preserves partially published files on retry/restore, including checkpoint 1 
and batches where an unpublished transaction precedes a published one. A failed 
directory deletion is recorded as completed only after it succeeds.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Flink 1.20 Hive overwrite jobs retain all current-batch rows with 
parallel writers, for both partitioned and non-partitioned tables. Partial 
publication can be replayed without removing files already committed by that 
batch. EN/ZH Hive documentation describes this behavior.
   
   The translation change is needed because the existing Flink 1.20 committer 
operator inherits sink parallelism. It restores the global meaning of 
`SinkAggregatedCommitter`; ordinary local-committer priority is retained. 
Public connector APIs, option names/defaults, the generic file committer, and 
existing committable/writer-state serializers are unchanged. Added dependencies 
are test-scoped Flink artifacts already used elsewhere in this repository.
   
   ### How was this patch tested?
   
   - Four new regression assertions failed on the unchanged baseline: no global 
operator, aggregate initialization in the local committer, checkpoint-1 replay 
losing published data, and deletion failure not being retried. The same initial 
13 tests then passed on the patch, with zero skips.
   - Actual Flink 1.20.1 jobs, single/parallel writers and 
partitioned/non-partitioned targets: both baseline single-writer controls 
retained `[0, 1]`; both baseline parallel cases retained only `[0]`. All four 
patched cases retained exactly `[0, 1]` and removed old data.
   - `HiveFlinkOverwriteIT` passed through the repository's Failsafe reactor: 
one test executes that four-job matrix. Its writers stage UTF-8 files, and the 
production Flink adapter, Hive committer and Hadoop LocalFileSystem perform 
publication. Only Metastore calls are mocked.
   - Real Hadoop 3.1.4 HDFS additionally verified two initial-restore controls 
and two partial-publication checkpoint-1 restores. Both baseline partial 
restores lost A and returned one pending transaction; the patch retained 
exactly A+B with no pending transactions in both table layouts.
   - A real Flink operator snapshot/restore test verifies incomplete checkpoint 
accumulation, recovered versus fresh commits, and initialization/closure of the 
same committer instance.
   - Spotless and scoped `verify` checks ran locally. The expanded 
affected-unit reactor passed 132 tests with zero failures, errors or skips, 
including the new operator recovery test and existing writer/serializer tests.
   
   Reproduction commands (JDK 11):
   
   ```bash
   ./mvnw -B -pl 
seatunnel-connectors-v2/connector-hive,seatunnel-translation/seatunnel-translation-flink/seatunnel-translation-flink-20
 -am 
'-Dtest=Hive*Test,FlinkSimpleAggregatedCommitterTest,FlinkGlobalAggregatedCommitterOperatorTest,CheckpointCommitWrapperSerializerTest,FlinkSinkWriterTest'
 -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false -DskipUT=false 
-DskipIT=true -Dlicense.skipAddThirdParty=true -Dskip.ui=true verify
   
   ./mvnw -B -pl seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hive-e2e 
-am -Dtest=NoSuchTest -Dit.test=HiveFlinkOverwriteIT 
-Dsurefire.failIfNoSpecifiedTests=false -Dfailsafe.failIfNoSpecifiedTests=false 
-DfailIfNoTests=false -DskipUT=false -DskipIT=false 
-Dlicense.skipAddThirdParty=true -Dskip.ui=true verify
   ```
   
   On Apple Silicon, the broader existing Hive tests required an externally 
supplied macOS ARM Snappy JNI library because the Hadoop bundle lacks that 
native binary; no project dependency version was changed. The integration 
fixture does not exercise Hive writer formats or a live Metastore. The original 
report's Parquet/OBS environment has not been reproduced here.
   
   ### Check list
   
   * [x] New Java files retain ASF license headers; added dependencies are 
test-only Apache Flink artifacts.
   * [x] English and Chinese Hive documentation updated.
   * [x] Public configuration and serialized payload formats unchanged.
   * [x] Connector unit and integration regression coverage added. Existing 
connector registration and distribution mappings need no changes.
   


-- 
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]

Reply via email to