nzw921rx opened a new issue, #13366:
URL: https://github.com/apache/seatunnel/issues/13366

   ## Problem
   
   On a Zeta job with timer flush enabled and multiple sink writer replicas per 
table (`multi_table_sink_replica > 1`), peak throughput fell to roughly one 
quarter of its usual level. During quiet hours, the same job benefits from 
flushing partially filled batches. Today `sink.flush.interval` applies around 
the clock.
   
   Two parts of the runtime can contribute to the slowdown. Every source timer 
tick announces a waiting injector and acquires the checkpoint lock used by the 
reader and barriers. At the sink, a timer flush waits for pending writes to 
drain, then waits for the registered writers across the replica queues to 
finish flushing. Profiling the source and sink separately would help quantify 
each cost in this workload. [Source 
timer](https://github.com/apache/seatunnel/blob/e2597998a991f30fd7c13a634cdd07c7a0a5db44/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/flow/SourceFlowLifeCycle.java#L213)
 ยท [Multi-table sink 
flush](https://github.com/apache/seatunnel/blob/e2597998a991f30fd7c13a634cdd07c7a0a5db44/seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSinkWriter.java#L995)
   
   ## Proposed behavior
   
   Add an optional job-level `flushSignal.time-range` for workloads with 
predictable off-peak hours. For example, this configuration would allow a timer 
flush attempt every five seconds from 23:00 until 06:00 the following day.
   
   ```hocon
   env {
     sink.flush.interval = 5000
     flushSignal.time-range = {
       start = "23:00"
       end = "06:00"
       zone = "Asia/Shanghai"
     }
   }
   ```
   
   - Evaluate the daily window in the configured time zone, including its start 
and excluding its end. Support windows that cross midnight.
   - Check the window at the source **before** 
`checkpointLockHandoff.injectorArriving()` and before acquiring the checkpoint 
lock. Outside the window, skip the tick. Inside it, use the existing 
fixed-delay schedule and signal ordering. Skipped ticks expire without a 
catch-up burst.
   - Omitting the window keeps today's interval-based behavior. A nonpositive 
`sink.flush.interval` disables the timer. Connector batch-size triggers, 
checkpoints and writer close can flush at any hour.
   
   An alternative for unpredictable traffic is to trigger after a period of 
inactivity. For a multi-table source, one busy table can hide another table's 
idle writer, so a source-wide idle timeout would miss that writer. A fixed 
daily window addresses the reported workload without adding per-record activity 
tracking.
   
   ## Validation
   
   At the same peak input rate and replica count, measure records per second 
and source lock wait with the timer disabled, with it enabled all day, and with 
the peak period excluded by the window. `FlushSignalTotal` should stay flat 
outside the window. Inside it, a partially filled writer should flush even if 
no more records arrive.
   
   Related work includes #10717 (engine timer flush), #12316 (source lock 
handoff) and #13201 (parallel multi-table sink flush).
   


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