Skip to content

maintenance: canonicalize alert label fingerprints - #4283

Open
zqr10159 wants to merge 2 commits into
apache:masterfrom
zqr10159:maintenance/alert-fingerprint-canonicalization
Open

maintenance: canonicalize alert label fingerprints#4283
zqr10159 wants to merge 2 commits into
apache:masterfrom
zqr10159:maintenance/alert-fingerprint-canonicalization

Conversation

@zqr10159

@zqr10159 zqr10159 commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

  • serialize calculator cache label maps as sorted, length-prefixed key/value pairs before hashing
  • preserve label association while remaining deterministic across map iteration order
  • document and test the compatibility boundary between this transient cache coordinate and the durable SingleAlert.fingerprint

Compatibility evidence

AlertUtil.calculateFingerprint is used only for the in-memory calculator cache. AlarmCacheManager reconstructs that coordinate from persisted labels during startup. The durable alert identity is generated separately by AlarmCommonReduce.generateAlertFingerprint; this pull request does not change that path.

The added restart regression loads a persisted firing alert, rebuilds the new cache coordinate from its labels, resolves it through the cache, and verifies that its durable fingerprint remains unchanged. A separate reducer contract verifies the durable fingerprint format and its exclusion of timestamp labels.

Consequently, this change does not rewrite database identities or break group, silence, or inhibition references, and a versioned database migration or dual-read path is not required.

Validation

  • collision regression distinguishes {a:b, c:d} from {a:d, c:b} and map-order regression preserves deterministic output
  • ./mvnw -pl hertzbeat-alerter -am -Dtest=AlertUtilTest,AlarmCacheManagerTest,AlarmCommonReduceTest,MetricsPeriodicAlertCalculatorTest,MetricsRealTimeAlertCalculatorTest,DbAlertStoreHandlerImplTest test -DskipITs -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false — 22 tests passed
  • ./mvnw -pl hertzbeat-alerter test -DskipITs — 439 tests passed, 2 skipped
  • Checkstyle and both Git diff whitespace checks passed
  • no hard-coded CJK scan passed

AI assistance: used for draft implementation and test iteration.
Human validation: focused cache/reducer contracts and the complete alerter test suite passed after rebuilding the current reactor dependencies.
Risk notes: only the transient calculator cache coordinate changes. Persisted alert identity remains unchanged and the cache is rebuilt from labels at process startup.

@zqr10159

Copy link
Copy Markdown
Member Author

Author remediation update:

The upgrade blocker was removed by narrowing canonicalization to transient in-memory cache identity. Durable alert fingerprints and all database and external relationships keep their existing algorithm and values, so an alert firing before upgrade continues the same active record and can resolve after restart. No database, silence, acknowledgement, or inhibition migration is required.

Restart and firing-to-resolve regressions passed (22 focused tests), and the full alerter reactor passed (439 tests). All current GitHub checks are green. The author-side upgrade blocker is resolved; maintainer review is still required.

@zqr10159
zqr10159 marked this pull request as ready for review July 31, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant