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

   ### Purpose of this pull request
   
   Yes, I am contributing to Apache SeaTunnel.
   
   Related to #13408. This is a **draft for implementation and semantics 
review, not ready to merge**.
   
   Kafka Sink currently emits Canal update images as DELETE and INSERT. This 
patch exposes the existing Canal merge serializer through the opt-in 
`merge_update_event` option, defaulting to `false`. With the option enabled, 
adjacent UPDATE_BEFORE / UPDATE_AFTER rows at one writer produce one UPDATE 
containing the full before-image in `old` and the after-image in `data`. The 
writer suppresses the buffered before-image instead of publishing its null 
serialized payload as a Kafka tombstone. Key serialization keeps merge mode 
disabled.
   
   The patch also clears the Canal serializer's pending before-image after a 
non-before row, preventing reuse by a later unrelated update, and corrects the 
existing serializer test to serialize each input only once. This format-level 
change also affects file sinks using merge mode and requires broader lifecycle 
review.
   
   Rebased onto current `dev` (`dfdee68897d5f85b5e39d9c9dd8b698d77dc1fd6`), 
preserving the upstream `KafkaSinkSerializer` extraction. Includes 
English/Chinese Kafka documentation, focused unit tests, and an extension to 
the existing KafkaFormatIT: the same input is written to default and 
merge-enabled sinks; the new assertions expect 9 INSERTs, 2 UPDATEs with full 
before/after values, and 1 DELETE, with no tombstones.
   
   ### Does this PR introduce any user-facing change?
   
   Yes. Kafka Sink accepts `merge_update_event = true` when `format = 
"canal_json"`. The default remains false and retains the existing DELETE/INSERT 
behavior. No new dependencies, connector registration, or state format changes 
are introduced.
   
   ### Merge blockers / decisions needed
   
   - **Unmatched images:** an unmatched UPDATE_AFTER currently serializes as 
UPDATE with `old: null`; the earlier remote round-trip probe failed in the 
Canal reader. The current unit assertion characterizes this output and does not 
establish reader compatibility. Unmatched/repeated UPDATE_BEFORE images can be 
overwritten or discarded. Agree and implement an explicit policy before merge.
   - **Pair identity and routing:** matching currently uses adjacency only, 
without table/key identity checks. The merged record uses after-image 
key/topic/partition/header routing. Key/topic changes, interleaving, and 
multi-writer ordering need a defined policy and regression coverage.
   - **Checkpoint, recovery and end-of-input:** the pending before-image is not 
included in Kafka sink state. Establish the engine ordering guarantees and 
handle possible split pairs and unfinished input for transactional and 
non-transactional modes before claiming delivery guarantees.
   - **Consumer compatibility:** `old` contains full before values. Verify 
affected consumers and file-sink merge behavior, including input object reuse. 
Related work: #12867 (unchanged before fields), #12870 (serializer metadata), 
#13384 / #13393 (filtering unmatched images).
   
   The draft deliberately does not close #13408 or claim production readiness. 
Maintainer feedback on these semantics will guide the follow-up implementation.
   
   ### How was this patch tested?
   
   Executed remotely on the user-designated Linux server with JDK 17 and the 
repository Maven wrapper; no local tests were run.
   
   - Targeted reactor `install` (including compile/package/verify): **44 tests 
passed, zero failures/errors/skips**: KafkaFactoryTest (23), 
DefaultSeaTunnelRowSerializerTest (14), CanalJsonSerDeSchemaTest (7).
   - Spotless apply/check on Kafka, JSON format, and Kafka E2E modules.
   - Full repository tests and recovery/fault-injection testing were not run.
   - Maven Wrapper download initially failed with TLS EOF; reused the 
already-cached wrapper JAR and Maven cache with offline mode. No repository 
dependency configuration was changed.
   - Live KafkaFormatIT execution is blocked by the unavailable 
`postgres:alpine3.16` image: Docker Hub pull returns EOF. This is not reported 
as a passed E2E test.
   
   ```bash
   ./mvnw -o -B \
     -pl 
seatunnel-connectors-v2/connector-kafka,seatunnel-formats/seatunnel-format-json 
\
     -am -Dskip.ui=true -DskipIT=true -DskipITs=true \
     
-Dtest=KafkaFactoryTest,DefaultSeaTunnelRowSerializerTest,CanalJsonSerDeSchemaTest
 \
     -Dsurefire.failIfNoSpecifiedTests=false -Dsurefire.timeout=60 install
   
   ./mvnw -o -B \
     -pl 
seatunnel-connectors-v2/connector-kafka,seatunnel-formats/seatunnel-format-json,seatunnel-e2e/seatunnel-connector-v2-e2e/connector-kafka-e2e
 \
     spotless:check
   ```
   
   ### Check list
   
   - [x] English and Chinese documentation updated.
   - [x] Focused unit tests added/updated.
   - [x] Existing Kafka E2E case extended.
   - [ ] Complete live E2E and lifecycle/recovery coverage.
   - [ ] Resolve unmatched-image, pairing and routing semantics before marking 
ready.
   


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