1fanwang commented on code in PR #20660:
URL: https://github.com/apache/hudi/pull/20660#discussion_r4703840572


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/HoodieSource.java:
##########
@@ -101,6 +104,9 @@ public HoodieSource(
     this.tableName = metaClient == null
         ? scanContext.getConf().get(FlinkOptions.TABLE_NAME)
         : metaClient.getTableConfig().getTableName();
+    this.timelineTimeZone = metaClient == null
+        ? HoodieTableConfig.TIMELINE_TIMEZONE.defaultValue()

Review Comment:
   Confirmed and reproduced your exact scenario (the 8-hour Asia/Shanghai 
offset). Fixed in 
https://github.com/apache/hudi/commit/ac6525924f41fe335dbb5bcb0717b7f62531bd25 
by moving timezone resolution off the frozen construction-time value: the 
enumerator now resolves it from its own split discoverer, which already 
re-checks table existence on every scan, and the reader resolves and caches it 
lazily the same way StreamReadMonitoringFunction already does. Verified against 
the existing enumerator and reader test suites, with no new dedicated test for 
this specific path.



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/StreamReadMonitoringFunction.java:
##########
@@ -333,10 +335,20 @@ public void snapshotState(FunctionSnapshotContext 
context) throws Exception {
 
   private void registerMetrics() {
     MetricGroup metrics = getRuntimeContext().getMetricGroup();
-    readMetrics = new FlinkStreamReadMetrics(metrics, tableName);
+    readMetrics = new FlinkStreamReadMetrics(metrics, tableName, 
this::getTimelineTimeZone);
     readMetrics.registerMetrics();
   }
 
+  /**
+   * The metrics are registered before the table is guaranteed to exist, so 
the timezone comes from
+   * the meta client, which is created once the table does.
+   */
+  private HoodieTimelineTimeZone getTimelineTimeZone() {
+    return metaClient == null
+        ? HoodieTableConfig.TIMELINE_TIMEZONE.defaultValue()

Review Comment:
   Confirmed and reproduced: a snapshot right after restore, before any scan, 
used the LOCAL fallback instead of the real timezone. Fixed in 
https://github.com/apache/hudi/commit/ac6525924f41fe335dbb5bcb0717b7f62531bd25 
exactly as you suggested: the checkpoint state is always persisted, and only 
the gauge update now waits until metaClient is resolved. Added a regression 
test covering both the before-resolution and after-resolution states.



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