JNSimba opened a new pull request, #70866:
URL: https://github.com/apache/doris/pull/70866

   ### Background
   
   Doris CDC streaming jobs read MySQL and PostgreSQL through the CDC client 
that runs alongside each BE. FROM TO jobs write via Stream Load, and jobs using 
the CDC TVF stream rows to the query engine. The FE assigns snapshot splits and 
validates the offsets reported for the task.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #70237 (writer takeover fix included here)
   PR Type: Enhancement
   
   Problem Summary:
   
   When several jobs share a CDC client, their reader queues and write buffers 
can grow together. The CDC client now shares a reader quota across jobs and 
uses a process-wide write buffer threshold to trigger earlier flushes. Snapshot 
tasks can process all assigned splits with fewer live readers and publish the 
complete offset batch after the task finishes. The change also includes writer 
isolation during takeover so a cancelled task cannot use its successor's writer.
   
   ### Details
   
   - **Change map:** 3,389 changed production and configuration lines and 2,135 
changed test lines, with no generated output or documentation changes. Reader 
admission and lifecycle account for about 2,022 lines, including the MySQL and 
JDBC snapshot loops. Task dispatch, cancellation, and writer takeover account 
for about 995 lines. Sink byte accounting and row conversion account for 269 
lines, and FE status and offset validation account for 103 lines.
   - **Before and after:** Previously a snapshot task could open a reader for 
every assigned split and the sink applied its local buffer thresholds 
independently. For example, a task assigned five splits with room for two 
readers now opens two and starts another split when a reader exits. Tasks 
waiting for quota give up their worker, and waiting incremental readers have 
priority for newly available quota. A reader releases quota after it has exited 
and its outstanding batches are closed.
   - **Configs and defaults:** `cdc.reader.memory.ratio` and 
`cdc.sink.memory.ratio` each default to one third of the CDC JVM's maximum 
heap. Set them with JVM properties in `cdc_client_java_opts` and restart the 
CDC client to apply them. The reader reservation is 1.5 times its configured or 
default queue byte limit. The sink threshold is soft. 
`pipeline.max-concurrent-tasks` defaults to 10 workers per phase for FROM TO 
and job-driven TVF tasks, with a shared queue limit of 128 waiting tasks.
   - **Impact on existing users:** Existing streaming job SQL and persisted 
offset formats are unchanged. Jobs can wait for reader quota or run fewer 
snapshot readers concurrently. Reader quota is an estimate and does not bound 
total JVM usage.
   - **Behavior change:** The CDC client applies the shared quotas by default. 
FE checks snapshot split IDs and watermarks before updating task state.
   
   ### Testing
   
   - Development machine: 321 CDC client UTs and 4 MySQL and PostgreSQL 
integration tests passed, including limited snapshot concurrency and TVF quota 
waiting.
   - Development machine: 40 FE UTs passed across offset validation, task 
timeout, offset persistence, and schema persistence.
   - The rebuilt FE and CDC client were deployed with an existing BE binary. 
The existing `test_streaming_mysql_job_snapshot` and 
`test_streaming_postgres_job_snapshot` suites passed, and their outputs matched 
the checked-in expected results.
   - After correcting the job TVF cleanup UT, all 5 `EnvTest` cases passed 
locally. Removing the reader detachment in a temporary copy made the corrected 
test fail on a retained reader.
   
   ### Release note
   
   CDC streaming jobs share a reader memory quota and a sink flush threshold 
within each CDC process. Snapshot tasks start readers as quota permits, and 
waiting incremental tasks get priority for newly available quota.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: Yes, document the default quotas and JVM 
settings in the streaming job guide.
   - Pre-submission status: Partially verified: targeted functional tests 
passed. Production memory and throughput calibration and mixed-version rolling 
upgrades were not tested.
   
   ### AI Disclosure
   
   - Tool: OpenAI Codex
   - Generated: CDC resource control code, related tests, and this description.
   - Human review: The author reviewed the design and specific code and test 
changes during development. Review of the complete diff was not stated.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to