charlesdong1991 commented on code in PR #555:
URL: https://github.com/apache/fluss-rust/pull/555#discussion_r3299471764


##########
crates/fluss/src/client/table/scanner.rs:
##########
@@ -378,6 +436,51 @@ impl LogScannerInner {
         }
     }
 
+    /// Records the start of a `poll()` call and emits
+    /// `SCANNER_TIME_BETWEEN_POLL_MS`. The first poll emits `0.0`,
+    /// matching Java's `ScannerMetricGroup.recordPollStart`
+    /// (`timeMsBetweenPoll = lastPollMs != 0L ? pollStartMs - lastPollMs : 
0L`).
+    ///
+    /// In debug builds, panics if a previous poll has not yet recorded
+    /// its end — that indicates a concurrent `poll()` on the same scanner,
+    /// which violates the single-consumer contract (Java enforces this
+    /// with `LogScannerImpl.acquire()` and throws
+    /// `ConcurrentModificationException`).
+    fn record_poll_start(&self) {
+        let now = Instant::now();
+        let mut state = self.poll_state.lock();
+        debug_assert!(
+            state.poll_start_at.is_none(),
+            "concurrent poll() detected on the same scanner; \
+             LogScanner / RecordBatchLogScanner are single-consumer \
+             (see LogScannerImpl.acquire() for Java parity)"
+        );
+        let between_ms = match state.last_poll_at {
+            Some(prev) => now.duration_since(prev).as_secs_f64() * 1000.0,
+            None => 0.0,
+        };
+        state.time_between_poll_ms = between_ms;
+        metrics::gauge!(SCANNER_TIME_BETWEEN_POLL_MS).set(between_ms);

Review Comment:
   sure! 👍 



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