orangeCatDeveloper opened a new pull request, #4329:
URL: https://github.com/apache/hertzbeat/pull/4329

   Fixes #3613
   
   SSL certificate monitors return duplicated metric series, and on current 
master editing any monitor that has a port fails outright with `Could not 
commit JPA transaction`.
   
   Root cause: metric history is keyed by the monitor's `instance` string 
(`host:port`), and the modify path appended the port on **every** edit without 
the `isHasPortWithMark` guard the add path has. Each edit changed the identity 
(`github.com:443` → `github.com:443:443` → ...), so storage opened a fresh 
series each time — and once `Monitor.instance` gained format validation, the 
grown value fails validation and rolls the whole edit back. A separate hole on 
the add path concatenated onto a null instance, producing literal `"null:443"` 
identities shared by every API-created monitor.
   
   The fix extracts the duplicated add/modify assembly into one idempotent 
`resolveMonitorInstance`: an instance already carrying a port is left 
untouched, and a missing instance falls back to the host param (then name) 
instead of null. `MonitorServiceTest` pins the stable-across-edits, 
host-fallback, and repeated-resolution behaviors.
   
   Reproduced end-to-end — real backend, one `ssl_cert` monitor against 
github.com:443, edited twice via the API:
   
   ```
   before:
     create (no instance)  -> instance = null:443
     edit #1               -> github.com:443
     edit #2               -> appends to github.com:443:443 -> entity 
validation rejects
                              {"code":4,"msg":"Could not commit JPA 
transaction"}
     stored series for this one monitor:
       null:443            63 rows
       github.com:443      84 rows
       github.com:443:443  609 rows      <- the duplicated series from the issue
   
   after:
     create                -> instance = github.com:443
     edit #1               -> "Modify success" | instance: github.com:443
     edit #2               -> "Modify success" | instance: github.com:443
     stored series:
       github.com:443      231 rows      <- single identity throughout
   ```
   
   Boundary: already-split historical series are not merged retroactively — 
this stops new splits; stale identities age out with retention.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to