Skip to content

feat: add atomic event ledger sink profile for Kafka Connect and NiFi - #30561

Merged
XuPeng-SH merged 15 commits into
matrixorigin:mainfrom
jiangxinmeng1:codex/issue-29857
Oct 22, 2026
Merged

XuPeng-SH merged 15 commits into
matrixorigin:mainfrom
jiangxinmeng1:codex/issue-29857

Conversation

@jiangxinmeng1

@jiangxinmeng1 jiangxinmeng1 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Refs #29857

What this PR does / why we need it:

Adds an initial deployable Kafka Connect sink profile for non-idempotent counter events, with NiFi 2.4 publishing the same immutable envelope into Kafka. The sink commits the event ledger, counter effect, bounded ledger budget, and MatrixOne checkpoint in one database transaction. It handles duplicate IDs, conflicting digests, owner epochs, and an uncertain COMMIT response without applying an effect twice.

The adapter requires stable event IDs and a strict versioned JSON envelope. It binds the broker topic ID to each checkpoint, rejects deleted/recreated or compacted topics, checks retention before assignment and each put, and requires read_committed consumption. The MatrixOne checkpoint is the recovery authority; Kafka committed offsets are not treated as proof of a database commit.

This is the first increment profile, with manual scope/checkpoint provisioning. The NiFi path is PublishKafka → Kafka → this Connect sink. Direct NiFi PutSQL, deletes, schema evolution, arbitrary business DML, and cross-system distributed EOS are outside this profile. Three broker RPCs per nonempty put callback are the initial safety cost; throughput qualification remains for production deployments.

Validation:

  • mvn -q -f connectors/mo-eos-sink/pom.xml verify passed at review-fix commit a80f66dbc5; new path-scoped Maven CI is included. Connector/J URL parsing is now checked with the same connection properties used by the sink, for every host. Regression tests reject host-scoped socketTimeout=0, connectTimeout=0, mixed-case overrides, and an override on the second load-balance host.
  • On remote [email protected], the built plugin ran in a real Connect 3.7 worker against Kafka 3.7 and MatrixOne. A fresh group sought from the MO checkpoint and processed events after the final code change.
  • The real Kafka/MO integration probe passed duplicate replay, whole-batch rollback, epoch fencing, retention overrun before assignment and before put, aborted-transaction offset holes, same-name topic recreation, compacted-topic rejection, and exact-byte case/trailing-space/Unicode event IDs. At Kafka offset 4, an old owner attempted its pending SQL write after ownership changed; the durable ledger (2 rows), total (10), budget (2 rows/226 bytes), and checkpoint (3) remained unchanged. The new owner then applied it once: ledger 3 rows, total 21, checkpoint 4, and offered broker offset 5. The old owner’s preCommit was fenced. The probe completed with PASS real Kafka/MO on 2026-10-21.
  • A packet-aware proxy forwarded a real MO COMMIT and dropped only its response. Recovery found the committed ledger/checkpoint; replay applied the effect once. Zero-delta and missing-business-row cases passed.
  • With broker offset still uncommitted, a Connect worker was SIGKILLed after MO commit, restarted, and replayed the same event without a second effect. In a fresh Kafka 3.7 Connect worker takeover on 2026-10-21, worker A committed offset 0 to MO (total 7, ledger 1, checkpoint 0, owner epoch 1); after A was paused, worker B claimed the partition (epoch 2) and replayed the identical event at Kafka offset 1. MO stayed at total 7, ledger 1, budget 1 row/127 bytes; its checkpoint advanced to 1, and the broker group committed offset 2 with lag 0. After A resumed, the durable values stayed unchanged (epoch advanced to 4), and the broker remained at offset 2 with lag 0.
  • A real NiFi 2.4 GenerateFlowFile + PublishKafka flow sent two identical immutable events. Connect advanced the checkpoint across both Kafka records; MO recorded one event ID and one +9 effect.

The worker-process takeover test did not inject a pending stale SQL write after resume; the separate real Kafka/MO probe exercised that pending-write and preCommit fencing path. A MatrixOne process SIGKILL, production capacity, and multi-CN qualification remain. No pending GitHub CI result is claimed here.

Design review gate

The design document is included in this PR at commit 00c4f773ba. It identifies issue #29857 and this implementation PR. @misuxi manually approved that exact design revision in a private discussion. The PR author recorded the design-phase PASS, approver, and reviewed revision in the document on 2026-10-20. This is an author-recorded private decision, separate from implementation approval.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@XuPeng-SH

XuPeng-SH commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · superseded

Commit: c246244e1f6f9ff5a358326fa431da36828873b5

"interrupted"

@XuPeng-SH

XuPeng-SH commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: c246244e1f6f9ff5a358326fa431da36828873b5

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · superseded

Commit: 2713d4dcd135421e9917c1f19d9e8e74c2fca505

"interrupted"

@XuPeng-SH

XuPeng-SH commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 2713d4dcd135421e9917c1f19d9e8e74c2fca505

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 2713d4dcd135421e9917c1f19d9e8e74c2fca505

Assessment: request_changes

Reviewed all 19 files and the protocol’s ownership, recovery and cleanup paths. The design approval record is complete, and five unit tests pass. However, a supported JDBC URL form bypasses timeout enforcement, and required stale-owner write validation remains unverified.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

  • P2 connectors/mo-eos-sink/src/main/java/io/matrixone/connect/eos/SinkSettings.java:44: Use jdbc:mysql://address=(host=127.0.0.1)(port=6001)(socketTimeout=0)/profile with finite mo.jdbc timeout settings, then encounter an endpoint that accepts TCP but stalls.
    Impact: The filter checks only query parameters. Connector/J accepts the host-scoped property and overrides the enforced socket timeout with zero, allowing synchronous JDBC operations to block indefinitely. Validate effective properties across supported URL forms, or reject host-level overrides, and add a regression test.
    Evidence: Using exact production sources and Connector/J 8.4.0, the URL passed SinkSettings and resolved socketTimeout=0. SinkStore.read remained blocked beyond 1500 ms despite a configured 250 ms deadline and thread interruption; the ordinary-URL control terminated. Retained jdbc-url-timeout-probe-v2.log matches exit-0 receipt checks/1792552661504780577-4.json.

  • P2 connectors/mo-eos-sink/src/test/java/io/matrixone/connect/eos/IntegrationProbe.java:129: A replacement owner claims the partition while the former owner retains a pending delivery, then the former owner resumes its write.
    Impact: Validation requirement: execute the new stale-put scenario against real Kafka/MatrixOne and retain the planned worker takeover/resume evidence, including unchanged durable state and broker-offset audits. The source-level test omission is addressed, but the required distributed contract is not yet demonstrated.
    Evidence: IntegrationProbe is an opt-in main program using FakeContext; Maven verify does not execute it. local_validation is empty, no current integration receipts/logs are supplied, and the PR still explicitly states that its worker experiment did not inject stale SQL. The approved design requires zombie-owner fencing validation. This is missing validation, not an observed SQL-fence failure.

Validation:

  • Isolation preflight passed. Exact production and test copies compiled with OpenJDK 21 targeting Java 17.

  • All five committed JUnit tests passed with no skips or failures; junit-tests.log matches checks/1792552749658900916-4.json.

  • The stalled-peer component probe confirmed the host-property timeout bypass. An encoded-query-key hypothesis was disproven and excluded.

  • Source/evidence audit passed: exact head/base, clean checkout, complete patch, 19 file fingerprints, approved design body, copied dependencies and command/source/exit/log correspondence. Receipt: checks/1792552863899780228-4.json.

  • Artifacts and detailed review are retained under /home/xupeng/.local/state/mo-bot/jobs/8f69f418d00873173b15b80d/attempt-1.

Limitations:

  • No real Kafka, Connect, MatrixOne or NiFi integration execution was performed locally. Frozen java-package CI success establishes packaging/unit coverage, not execution of the opt-in probes.

  • Ordinary MatrixOne SQL paths are unchanged. Connector broker RPCs, fresh JDBC connections and per-scope serialization remain throughput costs; capacity and multi-CN performance were not measured.

  • The linked issue’s full text was absent; requirements were assessed from the supplied PR and approved design.

@XuPeng-SH

XuPeng-SH commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · done

Commit: 89bef9cb8efe615d7a5e3c4a7cfb62dbbe1fa757

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · superseded

Commit: 89bef9cb8efe615d7a5e3c4a7cfb62dbbe1fa757

task canceled or execution/log limit exceeded

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-xupeng · review

Commit: 89bef9cb8efe615d7a5e3c4a7cfb62dbbe1fa757

Assessment: request_changes

Reviewed the complete 19-file delta and prior concerns. The ownership design is coherent, but a reproduced configuration bug allows distinct scopes to share persistent state.

Model: gpt-6-astra / xhigh

Session: 01a15209-2c6d-71e2-b8f3-aa17387fa283 · slot 2 · generation 0

  • P2 connectors/mo-eos-sink/src/main/java/io/matrixone/connect/eos/SinkSettings.java:58: Load connector properties containing mo.scope=orders\ud800 or orders\udc00 while the valid scope orders? is provisioned.
    Impact: UTF-8 encoding silently replaces the unpaired surrogate with '?'. Startup succeeds using another scope's ledger, totals, budget and checkpoint keys, permitting incorrect deduplication or ownership takeover. Reject malformed scope strings before encoding and add configuration regression tests.
    Evidence: ScopeEntryProbe exercised AtomicSinkConnector.start and taskConfigs using unmodified production classes. Both malformed scopes produced key 6f72646572733f and the same event digest as orders?. SinkStore uses these bytes for every scope binding. Valid Unicode, case and trailing-space controls remained distinct. Retained scope-entry-probe.log and checks/1792570210861756048-3.json document the reproduction.

Validation:

  • Reused CI run 39559291593, job 119086413673: Java 17 Maven verify passed all five unit tests and built the shaded package. Independently verified that its checkout tree exactly matches the frozen head.

  • Isolation preflight passed. Compiled all five production Java classes and ran the scope probes through the supplied test-exec. Compilation receipt: 1792570083778818213-3.json; public-entrypoint reproduction receipt: 1792570210861756048-3.json.

  • Reconciled source fingerprints, commands, exits and logs under /home/xupeng/.local/state/mo-bot/jobs/d184a57aa23988ad8174dbdf/attempt-1. review-validation-manifest.json and review-audit.log retain the audit; receipt 1792570309091545274-4.json confirms all 19 source files remain unchanged.

Limitations:

  • The scope reproduction exercised connector initialization and digest generation; downstream database impact was traced through SQL parameter bindings, without executing database writes.

  • Real Kafka/MO/Connect/NiFi and process-failure scenarios were not executed locally. Author-reported results lack supplied raw receipts; Maven CI does not execute the opt-in integration probes.

@XuPeng-SH

XuPeng-SH commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · done

Commit: 5a78a4d796d3044145d67c1c0858c7bb7fb7962d

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 5a78a4d796d3044145d67c1c0858c7bb7fb7962d

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 5a78a4d796d3044145d67c1c0858c7bb7fb7962d

Assessment: request_changes

Reviewed the complete 19-file delta. The custom SinkTask coherently owns atomic ledger, effect, budget and checkpoint updates. Prior timeout, scope-encoding and stale-write test concerns are addressed. The shaded package builds and all six unit tests pass, but required distributed fault-validation evidence remains unverified.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

  • P2 docs/design/issue_29857_sink_profile.md:368: Accepting the new exactly-once profile requires demonstrating COMMIT-response loss, process failure around commit, and stale-owner recovery through the real adapter and database.
    Impact: Validation requirement: recover the reported integration and worker-fault artifacts before approval, including source/JAR fingerprints, commands, terminal results and event/checkpoint/broker-offset audits. Run only missing scenarios, including before-commit process failure if not already covered. This is not an observed transaction or fencing defect.
    Evidence: The approved design requires these checks at lines 368–379. evidence.json.local_validation is empty, and the supplied packet contains narrative results without retained execution artifacts. IntegrationProbe and CommitAckProbe are opt-in main programs; Maven CI and the six locally executed unit tests do not run them. IntegrationProbe also uses FakeContext, so it cannot alone establish worker-process takeover and restart behavior.

Validation:

  • Verified frozen HEAD/base, clean source, the complete patch and unchanged module-copy fingerprints. review-audit.json and review-audit.log match exit-0 receipt checks/1792638408084059522-4.json.

  • Shaded Maven package build passed with tests explicitly skipped: maven-build.log and checks/1792638315047003217-3.json.

  • All six committed unit tests passed through test-exec, with zero failures or skips: junit-tests.log, junit-reports and checks/1792638356685346514-3.json. OpenJDK 21 compiled for Java 17.

  • Isolation preflight passed. The initial isolated Maven attempt failed dependency resolution before executing tests; dependency setup and subsequent build/test execution recovered successfully.

  • Artifacts are retained under /home/xupeng/.local/state/mo-bot/jobs/f643d10af0dc8d186e7a05c9/attempt-1.

Limitations:

  • No real Kafka/MatrixOne/Connect/NiFi fault scenarios were executed locally. Their required execution evidence remains the approval gap.

  • Ordinary MatrixOne SQL paths are unchanged. Per-partition broker RPCs, fresh JDBC connections and per-scope serialization are explicit connector costs; production throughput and multi-CN qualification remain unmeasured.

  • Issue #29857's full text was absent from the frozen packet; requirements were assessed from the supplied PR and approved design.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-xupeng · review

Commit: 5a78a4d796d3044145d67c1c0858c7bb7fb7962d

Assessment: approve

Reviewed the complete 19-file delta, transaction ownership and recovery, packaging, tests, documentation, and prior concerns. The scoped design is coherent, and the earlier findings are addressed. No actionable unresolved findings remain.

Model: gpt-6-astra / xhigh

Session: 01a14d34-4e51-79a3-a62d-6c9c16279dc8 · slot 0 · generation 0

Validation:

  • Isolation preflight passed; source remained unchanged.

  • Maven compiled production and test sources and successfully built the shaded plugin with tests skipped.

  • All six checked-in JUnit tests passed against the shaded artifact through the supplied isolated executor, including malformed scopes, JDBC timeout overrides, strict envelopes, and stalled-peer handling.

  • Verified connector/JDBC discovery entries, exact-head build inputs, and matching command/source/exit receipts and logs. Evidence retained under /home/xupeng/.local/state/mo-bot/jobs/190924f0e3b7348da8160b97/attempt-1 in evidence-audit.json, java-input-ledger.json, junit-reports, and checks.

  • Confirmed the design differs from its recorded approved revision only in the approval-status paragraph.

Limitations:

  • Real Kafka/MO/Connect/NiFi integration and fault runs were reviewed as author reports; their raw execution evidence was not supplied, and those scenarios were not independently rerun.

  • Production throughput and multi-CN behavior were not measured. The documented broker-RPC overhead and scope-wide budget serialization remain accepted initial-profile tradeoffs.

  • The linked issue body was not supplied; requirements were assessed from the frozen PR evidence and versioned design.

@mergify

mergify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-22 03:10 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-22 06:01 UTC · at 63f115c7e053f5241f63fd6d5ba5bd10c2691f4d

This pull request spent 2 hours 51 minutes 6 seconds in the queue, with no time running CI.

Reason

Pull request #30561 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — 63f115c7 Deployed Oct 22, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/feature kind/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants