Skip to content

<fix>[plugin]: prevent concurrent plugin driver registration - #4698

Open
ZStack-Robot wants to merge 1 commit into
feature-5.5.38-taiwang-sms-gatewayfrom
sync/shan.wu/fix/ZSTAC-87773-plugin-driver-registration
Open

<fix>[plugin]: prevent concurrent plugin driver registration#4698
ZStack-Robot wants to merge 1 commit into
feature-5.5.38-taiwang-sms-gatewayfrom
sync/shan.wu/fix/ZSTAC-87773-plugin-driver-registration

Conversation

@ZStack-Robot

Copy link
Copy Markdown
Collaborator

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

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

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Could not fetch remote config from http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml: TimeoutError: The operation was aborted due to timeout
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 85fbea2a-eb9a-4674-b1b4-52214c2d936c

📥 Commits

Reviewing files that changed from the base of the PR and between 7a1dc91 and 684ff77.

⛔ Files ignored due to path filters (1)
  • conf/persistence.xml is excluded by !**/*.xml
📒 Files selected for processing (1)
  • core/src/main/java/org/zstack/core/plugin/PluginManagerImpl.java

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


Walkthrough

插件驱动注册流程新增基于 UUID 的分布式锁。流程先持久化或更新数据库记录,再更新内存注册表,并同步插件元数据。

Changes

插件驱动注册

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant