You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "skywalker0618 (via GitHub)" <gi...@apache.org> on 2026/09/30 00:55:42 UTC

[PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

skywalker0618 opened a new pull request, #20148:
URL: https://github.com/apache/hudi/pull/20148

   ### Describe the issue this Pull Request addresses
   
   `StreamWriteOperatorCoordinator` runs Hive sync on its own `NonThrownExecutor` after each checkpoint
   commit, and synchronously after the commit that ends a bounded input. The executor only logs a
   failure, so a table that has stopped syncing to the metastore leaves no trace outside the JobManager
   log: the job keeps running and committing, and nothing in its metrics says the table has fallen
   behind in Hive.
   
   ### Summary and Changelog
   
   Flink jobs with Hive sync enabled now report sync health through the job's own metrics, next to the
   existing write, compaction and index metrics.
   
   - New `FlinkHiveSyncMetrics` (extends `HoodieFlinkMetrics`), registered on the coordinator's
     `OperatorCoordinator.Context#metricGroup()` in `initHiveSync()`, so only jobs with Hive sync
     enabled get it:
     - `hiveSyncSuccessCount` and `hiveSyncFailureCount`: counters.
     - `hiveSyncDurationMs`: histogram over the last 100 syncs, failed ones included, since a sync that
       fails after retrying an unreachable metastore is the slow case worth seeing.
     - `hiveSyncLastSuccessTimeMs`: gauge holding the wall-clock time of the last completed sync in
       epoch milliseconds, 0 until the first one.
   - `doSyncHive()` times each sync and records the outcome. A failure is recorded and rethrown
     unchanged, so the existing handling (logging by the executor, or the caller in batch mode) is
     unaffected. A failure closing the sync tool counts as a failed sync.
   - A sync can run on either the Hive sync executor or the coordinator's event executor, so the
     counters are `ThreadSafeSimpleCounter`, the histogram is backed by a synchronized Dropwizard
     reservoir, and the gauge reads a volatile field.
   
   The metrics are reported under the coordinator scope of the write operator, with no subtask index,
   as the sync runs once per commit on the JobManager.
   
   ### Impact
   
   No config or public API change. Jobs with `hive_sync.enabled=true` report four new metrics under
   the write operator's coordinator scope.
   
   ### Risk Level
   
   low
   
   The only behavioural change to the sync path is timing and counting around the existing call. Built
   against Flink 1.18 and 2.2; checkstyle passes.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [ ] Adequate tests were added if applicable
   


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5905699602

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7b142991786215a27a729d081719b19254b66eac",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379",
       "triggerID" : "7b142991786215a27a729d081719b19254b66eac",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7b142991786215a27a729d081719b19254b66eac Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #20148:
URL: https://github.com/apache/hudi/pull/20148#discussion_r4141098903


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -476,9 +485,16 @@ private void syncHive() {
    * Sync hoodie table metadata to Hive metastore.
    */
   public void doSyncHive() {
-    try (HiveSyncTool syncTool = hiveSyncContext.hiveSyncTool()) {
-      syncTool.syncHoodieTable();
+    HoodieTimer timer = HoodieTimer.start();
+    try {
+      try (HiveSyncTool syncTool = hiveSyncContext.hiveSyncTool()) {
+        syncTool.syncHoodieTable();
+      }
+    } catch (Throwable t) {
+      hiveSyncMetrics.markSyncFailed(timer.endTimer());
+      throw t;
     }
+    hiveSyncMetrics.markSyncSucceeded(timer.endTimer());

Review Comment:
   🤖 With `hive_sync.ignore_exceptions=true`, `HiveSyncTool#initSyncClient` swallows a metastore connection failure and leaves `syncClient` null, and `syncHoodieTable()` then does nothing. When that happens, this line counts a success and moves `hiveSyncLastSuccessTimeMs` forward. Should that case count as a failure, or at least be noted in the metric docs?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5902241785

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * f565586897562e34dc8eb32599c11337a0998c31 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "skywalker0618 (via GitHub)" <gi...@apache.org>.
skywalker0618 commented on code in PR #20148:
URL: https://github.com/apache/hudi/pull/20148#discussion_r4141647534


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -476,9 +485,16 @@ private void syncHive() {
    * Sync hoodie table metadata to Hive metastore.
    */
   public void doSyncHive() {
-    try (HiveSyncTool syncTool = hiveSyncContext.hiveSyncTool()) {
-      syncTool.syncHoodieTable();
+    HoodieTimer timer = HoodieTimer.start();
+    try {
+      try (HiveSyncTool syncTool = hiveSyncContext.hiveSyncTool()) {
+        syncTool.syncHoodieTable();
+      }
+    } catch (Throwable t) {
+      hiveSyncMetrics.markSyncFailed(timer.endTimer());
+      throw t;
     }
+    hiveSyncMetrics.markSyncSucceeded(timer.endTimer());

Review Comment:
   Great point, fixed



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #20148:
URL: https://github.com/apache/hudi/pull/20148#discussion_r4145239764


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -476,9 +485,20 @@ private void syncHive() {
    * Sync hoodie table metadata to Hive metastore.
    */
   public void doSyncHive() {
-    try (HiveSyncTool syncTool = hiveSyncContext.hiveSyncTool()) {
-      syncTool.syncHoodieTable();
+    HoodieTimer timer = HoodieTimer.start();
+    try {

Review Comment:
   🤖 nit: the nested try, the early `return` and the three `markSyncXxx` calls make the outcome hard to follow. Could you track a `boolean succeeded` and record the metric once in a `finally`, e.g. `succeeded = syncTool.isSyncClientInitialized(); if (succeeded) { syncTool.syncHoodieTable(); }`?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5923727648

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7b142991786215a27a729d081719b19254b66eac",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379",
       "triggerID" : "7b142991786215a27a729d081719b19254b66eac",
       "triggerType" : "PUSH"
     }, {
       "hash" : "247941e974c86aebda2e47d7dae388872bae2a20",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17381",
       "triggerID" : "247941e974c86aebda2e47d7dae388872bae2a20",
       "triggerType" : "PUSH"
     }, {
       "hash" : "29412bd36632c6e795de5dcc4e7d294988ede3de",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "29412bd36632c6e795de5dcc4e7d294988ede3de",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 247941e974c86aebda2e47d7dae388872bae2a20 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17381) 
   * 29412bd36632c6e795de5dcc4e7d294988ede3de UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5901994171

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * f565586897562e34dc8eb32599c11337a0998c31 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "skywalker0618 (via GitHub)" <gi...@apache.org>.
skywalker0618 commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5906161289

   Hi @danny0405 do you mind taking a look at this one as well? Added some metrics in HMS registration in flink, thanks!


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5923793478

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7b142991786215a27a729d081719b19254b66eac",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379",
       "triggerID" : "7b142991786215a27a729d081719b19254b66eac",
       "triggerType" : "PUSH"
     }, {
       "hash" : "247941e974c86aebda2e47d7dae388872bae2a20",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17381",
       "triggerID" : "247941e974c86aebda2e47d7dae388872bae2a20",
       "triggerType" : "PUSH"
     }, {
       "hash" : "29412bd36632c6e795de5dcc4e7d294988ede3de",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17407",
       "triggerID" : "29412bd36632c6e795de5dcc4e7d294988ede3de",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 247941e974c86aebda2e47d7dae388872bae2a20 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17381) 
   * 29412bd36632c6e795de5dcc4e7d294988ede3de Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17407) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5902114537

   ## [Codecov](https://app.codecov.io/gh/apache/hudi/pull/20148?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 80.42%. Comparing base ([`602cc3d`](https://app.codecov.io/gh/apache/hudi/commit/602cc3d2b7035a87e1b521b0a7f5809b8dbcdb48?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f565586`](https://app.codecov.io/gh/apache/hudi/commit/f565586897562e34dc8eb32599c11337a0998c31?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #20148      +/-   ##
   ============================================
   - Coverage     80.42%   80.42%   -0.01%     
   + Complexity    34900    34899       -1     
   ============================================
     Files          2546     2546              
     Lines        142929   142927       -2     
     Branches      17381    17381              
   ============================================
   - Hits         114948   114946       -2     
     Misses        20064    20064              
     Partials       7917     7917              
   ```
   
   | [Components](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hudi-common](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.97% <ø> (ø)` | |
   | [hudi-client](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.48% <ø> (ø)` | |
   | [hudi-flink](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `85.74% <ø> (-0.01%)` | :arrow_down: |
   | [hudi-spark-datasource](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.85% <ø> (ø)` | |
   | [hudi-utilities](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.19% <ø> (ø)` | |
   | [hudi-cli](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.05% <ø> (ø)` | |
   | [hudi-hadoop](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.98% <ø> (ø)` | |
   | [hudi-sync](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `76.02% <ø> (ø)` | |
   | [hudi-io](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `81.50% <ø> (ø)` | |
   | [hudi-timeline-service](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.06% <ø> (ø)` | |
   | [hudi-cloud](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `81.00% <ø> (ø)` | |
   | [hudi-kafka-connect](https://app.codecov.io/gh/apache/hudi/pull/20148/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.96% <ø> (ø)` | |
   
   | [Flag](https://app.codecov.io/gh/apache/hudi/pull/20148/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hadoop-mr-java-client](https://app.codecov.io/gh/apache/hudi/pull/20148/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `43.98% <ø> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/hudi/pull/20148?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...ache/hudi/sink/StreamWriteOperatorCoordinator.java](https://app.codecov.io/gh/apache/hudi/pull/20148?src=pr&el=tree&filepath=hudi-flink-datasource%2Fhudi-flink%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fhudi%2Fsink%2FStreamWriteOperatorCoordinator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVkaS1mbGluay1kYXRhc291cmNlL2h1ZGktZmxpbmsvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvc2luay9TdHJlYW1Xcml0ZU9wZXJhdG9yQ29vcmRpbmF0b3IuamF2YQ==) | `82.77% <ø> (-0.13%)` | :arrow_down: |
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5903153153

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * f565586897562e34dc8eb32599c11337a0998c31 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 merged PR #20148:
URL: https://github.com/apache/hudi/pull/20148


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #20148:
URL: https://github.com/apache/hudi/pull/20148#discussion_r4151312045


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -457,6 +464,8 @@ private void initHiveSync() {
         .threadFactory(getThreadFactory("hive-sync"))
         .waitForTasksFinish(true).build();
     this.hiveSyncContext = HiveSyncContext.create(conf, this.storageConf);
+    this.hiveSyncMetrics = new FlinkHiveSyncMetrics(context.metricGroup());
+    this.hiveSyncMetrics.registerMetrics();

Review Comment:
   🤖 I think these metrics can go stale under the AdaptiveScheduler. Flink reuses the coordinator metric group (`getOrAddOperator` + `addGroup("coordinator")`) when it rebuilds the ExecutionGraph on a restart or rescale. When the new coordinator registers here, `addMetric` hits a name collision and keeps the old, closed coordinator's counters and gauge. `hiveSyncLastSuccessTimeMs` would then freeze after the first restart. Could you look into whether a recreated coordinator can reuse the existing metric objects?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/sink/TestStreamWriteOperatorCoordinator.java:
##########
@@ -1009,6 +1084,34 @@ private static StreamWriteOperatorCoordinator createCoordinator(Configuration co
     return new StreamWriteOperatorCoordinator(conf, coordinatorContext);
   }
 
+  /**
+   * A coordinator metric group that keeps what is registered on it.
+   */
+  private static final class CapturingCoordinatorMetricGroup extends UnregisteredMetricsGroup

Review Comment:
   🤖 nit: this is almost the same as `CapturingMetricGroup` in `TestFlinkHiveSyncMetrics`. Could we move it into one shared test utility (e.g. under `org.apache.hudi.utils`) and have both tests use it? Then the metric-name constants could be public, so this test wouldn't need hardcoded strings like "hiveSyncFailureCount".
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5904867767

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7b142991786215a27a729d081719b19254b66eac",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379",
       "triggerID" : "7b142991786215a27a729d081719b19254b66eac",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * f565586897562e34dc8eb32599c11337a0998c31 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368) 
   * 7b142991786215a27a729d081719b19254b66eac Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "cshuo (via GitHub)" <gi...@apache.org>.
cshuo commented on code in PR #20148:
URL: https://github.com/apache/hudi/pull/20148#discussion_r4143099475


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -476,9 +485,20 @@ private void syncHive() {
    * Sync hoodie table metadata to Hive metastore.
    */
   public void doSyncHive() {
-    try (HiveSyncTool syncTool = hiveSyncContext.hiveSyncTool()) {
-      syncTool.syncHoodieTable();
+    HoodieTimer timer = HoodieTimer.start();

Review Comment:
   HoodieTimer calculates elapsed time using System.currentTimeMillis(). If the JobManager’s clock changes during a sync—for example, during a long metastore retry—a backward adjustment can produce a negative duration, and a forward adjustment can inflate it. That sample affects the histogram statistics until it leaves the 100-sample window.
   
   Suggested fix: Measure elapsed time with System.nanoTime() and convert to milliseconds. Continue using System.currentTimeMillis() for the last-success timestamp.



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5904794191

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7b142991786215a27a729d081719b19254b66eac",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7b142991786215a27a729d081719b19254b66eac",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * f565586897562e34dc8eb32599c11337a0998c31 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368) 
   * 7b142991786215a27a729d081719b19254b66eac UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "cshuo (via GitHub)" <gi...@apache.org>.
cshuo commented on code in PR #20148:
URL: https://github.com/apache/hudi/pull/20148#discussion_r4143099475


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -476,9 +485,20 @@ private void syncHive() {
    * Sync hoodie table metadata to Hive metastore.
    */
   public void doSyncHive() {
-    try (HiveSyncTool syncTool = hiveSyncContext.hiveSyncTool()) {
-      syncTool.syncHoodieTable();
+    HoodieTimer timer = HoodieTimer.start();

Review Comment:
   HoodieTimer calculates elapsed time using System.currentTimeMillis(). If the JobManager’s clock changes during a sync—for example, during a long metastore retry—a backward adjustment can produce a negative duration, and a forward adjustment can inflate it. That sample affects the histogram statistics until it leaves the 100-sample window.
   
   Suggested fix: Measure elapsed time with System.nanoTime() and convert to milliseconds. Continue using System.currentTimeMillis() for the last-success timestamp.



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5907690499

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7b142991786215a27a729d081719b19254b66eac",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379",
       "triggerID" : "7b142991786215a27a729d081719b19254b66eac",
       "triggerType" : "PUSH"
     }, {
       "hash" : "247941e974c86aebda2e47d7dae388872bae2a20",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17381",
       "triggerID" : "247941e974c86aebda2e47d7dae388872bae2a20",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 247941e974c86aebda2e47d7dae388872bae2a20 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17381) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5906023445

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7b142991786215a27a729d081719b19254b66eac",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379",
       "triggerID" : "7b142991786215a27a729d081719b19254b66eac",
       "triggerType" : "PUSH"
     }, {
       "hash" : "247941e974c86aebda2e47d7dae388872bae2a20",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17381",
       "triggerID" : "247941e974c86aebda2e47d7dae388872bae2a20",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7b142991786215a27a729d081719b19254b66eac Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379) 
   * 247941e974c86aebda2e47d7dae388872bae2a20 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17381) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(flink): add Hive sync metrics to the write coordinator [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20148:
URL: https://github.com/apache/hudi/pull/20148#issuecomment-5905907146

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f565586897562e34dc8eb32599c11337a0998c31",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17368",
       "triggerID" : "f565586897562e34dc8eb32599c11337a0998c31",
       "triggerType" : "PUSH"
     }, {
       "hash" : "7b142991786215a27a729d081719b19254b66eac",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379",
       "triggerID" : "7b142991786215a27a729d081719b19254b66eac",
       "triggerType" : "PUSH"
     }, {
       "hash" : "247941e974c86aebda2e47d7dae388872bae2a20",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "247941e974c86aebda2e47d7dae388872bae2a20",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7b142991786215a27a729d081719b19254b66eac Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17379) 
   * 247941e974c86aebda2e47d7dae388872bae2a20 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org