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

   ### What's changed
   
   Close #4172
   
   Fix monitor import (`AbstractImExportServiceImpl#importConfig`) so a single 
bad row no longer corrupts the whole import.
   
   **Cause:** the import runs in one transaction (`MonitorServiceImpl` is 
class-level `@Transactional`). A duplicate name mid-batch throws and rolls back 
the rows already inserted — but the collector jobs `addMonitor` already 
dispatched in memory survive the rollback, leaving orphan tasks and no monitors.
   
   <img width="1915" height="482" alt="capcap-260624-003316" 
src="https://github.com/user-attachments/assets/30689023-0071-4ce2-a4db-8b3f84b00227";
 />
   
   ### Fix
   
   make minimal changes: validate the whole batch up front 
(`validateImportBatch`) — per-entry checks plus in-file duplicate-name 
detection — so the import is all-or-nothing: nothing is persisted until every 
entry is valid, so no partial commit and no orphan tasks. Also lowered 
`IMPORT_TASK_PROCESS_THRESHOLD` (100 → 10) so medium-sized imports still report 
progress.
   
   
   ## Checklist
   
   - [x]  I have read the [Contributing 
Guide](https://hertzbeat.apache.org/docs/community/code_style_and_quality_guide)
   - [ ]  I have written the necessary doc or comment.
   - [x]  I have added the necessary unit tests and all cases have passed.
   
   ## Add or update API
   
   - [ ] I have added the necessary [e2e 
tests](https://github.com/apache/hertzbeat/tree/master/e2e) and all cases have 
passed.
   
   > Importing Invalid Data
   
   <img width="1510" height="617" alt="capcap-260624-095548" 
src="https://github.com/user-attachments/assets/eb566227-8d92-412a-bed2-51677540e538";
 />
   
   > Import Normal Data
   
   <img width="1502" height="409" alt="capcap-260624-095712" 
src="https://github.com/user-attachments/assets/10441204-e3ee-4b26-bc04-1af1ba7c2312";
 />
   
   <img width="1512" height="502" alt="capcap-260624-095814" 
src="https://github.com/user-attachments/assets/40fad04a-6d0d-4821-b990-7a896f31d861";
 />
   


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