danny0405 opened a new issue, #20576:
URL: https://github.com/apache/hudi/issues/20576

   ### Bug Description
   
   **What happened:**
   
   Flink stream-read metrics parse timeline timestamps using the reader JVM's 
default timezone, even when the table uses 
`hoodie.table.timeline.timezone=UTC`. This can offset `issuedInstant`, 
`splitLatestCommit`, and their delay gauges by hours.
   
   Found while reviewing #20564. This is pre-existing: the earlier 
implementation also called the same parser and compared its result with 
`Instant.now()`. Switching to an injected `Clock` does not introduce or fix the 
problem.
   
   At reviewed commit `bc41326be5c24f8e400e67da8e3174ed8071c6d2`, 
[HoodieInstantTimeGenerator.parseDateFromInstantTime](https://github.com/apache/hudi/blob/bc41326be5c24f8e400e67da8e3174ed8071c6d2/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieInstantTimeGenerator.java#L86)
 parses a `LocalDateTime` and unconditionally applies `ZoneId.systemDefault()`. 
`FlinkStreamReadMetrics` uses this parser without the table's timezone.
   
   **What you expected:**
   
   Parse the commit timestamp in the timezone used by the table timeline before 
comparing absolute instants. For a UTC timeline, changing the reader JVM's 
timezone must not change the epoch timestamps or measured delays.
   
   **Steps to reproduce:**
   
   1. Use a table with `hoodie.table.timeline.timezone=UTC`.
   2. Run the reader JVM with `-Duser.timezone=Asia/Shanghai`.
   3. Consider commit `20261111100000000` (10:00 UTC), with current time fixed 
at `2026-11-11T10:10:00Z`.
   4. The existing parser interprets the commit as 10:00 Shanghai time, or 
`02:00Z`. The calculated delay is 29,400 seconds instead of 600 seconds.
   
   Minimal parser-level reproducer, run with Hudi on the classpath and the JVM 
timezone above:
   
   ```java
   Instant parsed = HoodieInstantTimeGenerator
       .parseDateFromInstantTime("20261111100000000")
       .toInstant();
   Instant now = Instant.parse("2026-11-11T10:10:00Z");
   System.out.println(parsed);
   System.out.println(Duration.between(parsed, now).getSeconds());
   ```
   
   The output implied by the current implementation is `2026-11-11T02:00:00Z` 
and `29400`. This report is based on source inspection; the snippet and an 
end-to-end Flink job have not been executed.
   
   ### Environment
   
   **Hudi version:** Source reviewed at 
`bc41326be5c24f8e400e67da8e3174ed8071c6d2` in #20564; the parser behavior 
predates that PR.
   **Query engine:** Flink, legacy stream reader and Source V2 metric paths.
   **Relevant configs:**
   - Table: `hoodie.table.timeline.timezone=UTC`
   - Reader JVM: `-Duser.timezone=Asia/Shanghai`
   
   ### Suggested scope and validation
   
   - Obtain the table timezone via 
`metaClient.getTableConfig().getTimelineTimezone().getZoneId()` and pass it 
explicitly to metric timestamp parsing.
   - Consider a reusable `parseDateFromInstantTime` overload accepting 
`ZoneId`, preserving existing timestamp compatibility handling. Avoid changing 
shared JVM-wide timezone state to parse a particular table.
   - Test UTC timelines with non-UTC reader JVMs, using an independently fixed 
expected `Instant`. Building the test clock with the same parser can conceal 
the error.
   - Cover local timelines with matching writer/reader zones and retain 
idle/active split behavior.
   
   **Separate LOCAL limitation:** `LOCAL` resolves to the current JVM's default 
timezone; it does not persist the writer's concrete zone ID. Reading a LOCAL 
timeline in another timezone cannot reliably recover the original zone from 
this setting alone. Document or track that limitation separately from honoring 
an explicit UTC configuration.
   
   ### Logs and Stack Trace
   
   No exception is required; the failure is incorrect metric values.
   
   ### Related work
   
   - #15907 tracks the broader requirement for timeline APIs to honor the 
configured timezone. This issue scopes the Flink stream-read metrics follow-up.
   - #20564 fixes metric lifecycle and live delay reporting; this timezone fix 
can be handled independently.
   


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