<fix>[plugin]: prevent concurrent plugin driver registration - #4698
Conversation
PROBLEM: APIRefreshPluginDriversMsg refreshes all management nodes concurrently. On first load, multiple nodes can observe a missing PluginDriverVO and insert the same UUID, causing duplicate-key failures. The persistence unit also still references the obsolete PluginDriverVO package. SOLUTION: Register the current PluginDriverVO class in the persistence unit. Serialize metadata upserts with a per-plugin database GLock and query the row again after acquiring the lock. Update the local driver registry only after the shared metadata write succeeds. TESTING: The database-backed lock path was exercised remotely with two concurrent callers. CI validation is pending. Resolves: ZSTAC-87773 Change-Id: I886da86d2cd46d8a52138643e1cd5ae49df52fcc
|
Warning
|
| Layer / File(s) | Summary |
|---|---|
注册流程与分布式锁 core/src/main/java/org/zstack/core/plugin/PluginManagerImpl.java |
注册插件时先持久化数据库记录,再更新内存注册表。持久化过程使用基于插件 UUID 的两分钟超时 GLock。 |
插件驱动记录新增或更新 core/src/main/java/org/zstack/core/plugin/PluginManagerImpl.java |
系统按插件 UUID 查询 PluginDriverVO,并创建新记录或同步已有记录的插件元数据。 |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Merge Risk: ⚪ Minimal · up to 684ff
The change serializes plugin metadata updates to prevent duplicate registrations, and no actionable merge-blocking risk remains beyond normal checks and review.
Poem
我是小兔,蹦过注册门,
UUID 锁住并发尘。
先写数据库,
再更新内存,
元数据整齐,
月光下运行安稳。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description check | ✅ Passed | 描述准确说明了并发注册失败、数据库锁、持久化修复和本地注册表更新顺序,与变更内容相关。 |
| Title check | ✅ Passed | 标题清晰概括了防止插件驱动并发注册的主要变更,且与变更内容直接相关。 |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
📝 Generate docstrings
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
sync/shan.wu/fix/ZSTAC-87773-plugin-driver-registration
Comment @coderabbitai help to get the list of available commands.
PROBLEM: Concurrent management-node refresh can insert the same PluginDriverVO UUID and fail with a duplicate key. SOLUTION: Correct the persistence mapping and serialize each plugin metadata upsert with a database GLock before updating the local registry. TESTING: Remote concurrent lock path exercised; CI pending. Resolves: ZSTAC-87773
sync from gitlab !10749