Skip to content

[Hotfix] Fix Edit Catalog database-filter,After TableRuntime metric re-register conflict#4138

Open
czy006 wants to merge 2 commits intoapache:masterfrom
czy006:issues/amoro-fix-metrics-rg
Open

[Hotfix] Fix Edit Catalog database-filter,After TableRuntime metric re-register conflict#4138
czy006 wants to merge 2 commits intoapache:masterfrom
czy006:issues/amoro-fix-metrics-rg

Conversation

@czy006
Copy link
Copy Markdown
Contributor

@czy006 czy006 commented Mar 23, 2026

Fix Edit Catalog database-filter,After TableRuntime metric re-register conflict

Why are the changes needed?

When use external catalog,edit database-filter catalog properties,re-register table runtime failed

2026-03-20 16:13:34,333 ERROR [table-explorer-executor-0] [org.apache.amoro.server.table.DefaultTableService] [] - TableExplorer sync table TableIdentity{database=sl_oki_prod, tableName=payment_view__payment_case__case_log} error org.apache.amoro.exception.PersistenceException: java.lang.IllegalArgumentException: Metric is already been registered. at org.apache.amoro.exception.AmoroRuntimeException.wrap(AmoroRuntimeException.java:142) ~[amoro-common-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.amoro.server.persistence.PersistentBase.doAsTransaction(PersistentBase.java:96) ~[amoro-ams-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.amoro.server.table.DefaultTableService.syncTable(DefaultTableService.java:497) ~[amoro-ams-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.amoro.server.table.DefaultTableService.lambda$exploreExternalCatalog$10(DefaultTableService.java:366) ~[amoro-ams-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?] at java.lang.Thread.run(Thread.java:955) [?:?] Caused by: java.lang.IllegalArgumentException: Metric is already been registered. at org.apache.amoro.shade.guava32.com.google.common.base.Preconditions.checkArgument(Preconditions.java:143) ~[amoro-shade-guava-32-32.1.1-jre-0.7.0-incubating.jar:32.1.1-jre-0.7.0-incubating] at org.apache.amoro.metrics.MetricRegistry.lambda$register$1(MetricRegistry.java:86) ~[amoro-common-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at java.util.concurrent.ConcurrentHashMap.computeIfPresent(ConcurrentHashMap.java:1822) ~[?:?] at org.apache.amoro.metrics.MetricRegistry.register(MetricRegistry.java:77) ~[amoro-common-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.amoro.server.table.TableOptimizingMetrics.registerMetric(TableOptimizingMetrics.java:223) ~[amoro-ams-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.amoro.server.table.TableOptimizingMetrics.registerMetrics(TableOptimizingMetrics.java:242) ~[amoro-ams-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.amoro.server.table.AbstractTableMetrics.register(AbstractTableMetrics.java:57) ~[amoro-ams-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.amoro.server.table.paimon.PaimonTableRuntime.registerMetric(PaimonTableRuntime.java:134) ~[amoro-ams-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.amoro.server.table.DefaultTableService.triggerTableAdded(DefaultTableService.java:554) ~[amoro-ams-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at org.apache.amoro.server.table.DefaultTableService.lambda$syncTable$25(DefaultTableService.java:507) ~[amoro-ams-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[?:?] at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) ~[?:?] at org.apache.amoro.server.persistence.PersistentBase.doAsTransaction(PersistentBase.java:91) ~[amoro-ams-0.9-SNAPSHOT.jar:0.9-SNAPSHOT] ... 6 more

Brief change log

  • triggerTableAdded must be dispose the same serverTableIdentifier tableRuntime
  • registeredMetricKeys clear and try to registerMetrics

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before making a pull request

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not documented)

@github-actions github-actions bot added the module:ams-server Ams server module label Mar 23, 2026
@czy006 czy006 force-pushed the issues/amoro-fix-metrics-rg branch from 938ec96 to b170000 Compare April 15, 2026 08:42
@czy006 czy006 requested a review from xxubai April 15, 2026 09:08
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 79.06977% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.87%. Comparing base (b7f7de3) to head (b170000).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...apache/amoro/server/table/DefaultTableService.java 75.67% 8 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4138      +/-   ##
============================================
+ Coverage     29.75%   29.87%   +0.11%     
- Complexity     4258     4270      +12     
============================================
  Files           677      679       +2     
  Lines         54744    54869     +125     
  Branches       6968     6996      +28     
============================================
+ Hits          16288    16390     +102     
- Misses        37246    37260      +14     
- Partials       1210     1219       +9     
Flag Coverage Δ
core 29.87% <79.06%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ams-server Ams server module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants