RockteMQ-AI commented on issue #2289:
URL: 
https://github.com/apache/rocketmq-dashboard/issues/2289#issuecomment-5311670837

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed** | Severity: **Medium**
   
   The reported race condition has been verified against the codebase.
   
   **Root Cause:** `MybatisPlusSettingsRepository.saveGeneralSettings()` (lines 
90–96) performs a read-then-insert pattern: `selectById(SETTINGS_ID)` → check 
null → `insert()`. Two concurrent first-time saves can both observe no row, 
causing the second insert to fail with an unhandled `DuplicateKeyException` 
(500).
   
   **Partial mitigation:** `SettingsService.saveGeneralSettings()` is 
`synchronized`, but this only protects within a single JVM — multi-instance 
deployments are exposed.
   
   **Fix direction:** Replace the read-then-insert with an upsert/retry pattern 
(e.g., `INSERT ... ON DUPLICATE KEY UPDATE` or catch-and-retry with 
`selectById` + `updateById`).
   
   An automated fix proposal can be generated. Reply `/approve` to proceed with 
PR generation.
   
   ---
   *Automated evaluation by RockteMQ-AI*


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

Reply via email to