Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions conf/db/upgrade/V5.5.12__schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- ZSTAC-73546: Migrate existing global GPU quota to per-vendor (NVIDIA) quota
-- For users who already set container.gpu.video.ram.size, copy the value as NVIDIA vendor quota.
-- Other vendor quotas will use the GlobalConfig default (32GB) via the quota framework.
DELIMITER $$

CREATE PROCEDURE MigrateGpuQuotaPerVendor()
BEGIN
Comment on lines +6 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

建议在创建存储过程前先 DROP,避免升级重跑失败。

若迁移在中途失败并重试,CREATE PROCEDURE 可能因已存在而报错中断升级。建议增加 DROP PROCEDURE IF EXISTS 以保证幂等性。

🔧 建议修改
 DELIMITER $$
 
+DROP PROCEDURE IF EXISTS MigrateGpuQuotaPerVendor$$
+
 CREATE PROCEDURE MigrateGpuQuotaPerVendor()
 BEGIN
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
CREATE PROCEDURE MigrateGpuQuotaPerVendor()
BEGIN
DELIMITER $$
DROP PROCEDURE IF EXISTS MigrateGpuQuotaPerVendor$$
CREATE PROCEDURE MigrateGpuQuotaPerVendor()
BEGIN
🤖 Prompt for AI Agents
In `@conf/db/upgrade/V5.5.12__schema.sql` around lines 6 - 7, Add idempotency by
dropping the stored procedure before creating it: ensure a DROP PROCEDURE IF
EXISTS MigrateGpuQuotaPerVendor() is executed immediately before the CREATE
PROCEDURE MigrateGpuQuotaPerVendor() statement so repeated/partial upgrade runs
won't fail due to the procedure already existing.

DECLARE done INT DEFAULT FALSE;
DECLARE v_identity_uuid VARCHAR(32);
DECLARE v_identity_type VARCHAR(255);
DECLARE v_value BIGINT;
DECLARE cur CURSOR FOR
SELECT `identityUuid`, `identityType`, `value`
FROM `QuotaVO`
WHERE `name` = 'container.gpu.video.ram.size';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

OPEN cur;
read_loop: LOOP
FETCH cur INTO v_identity_uuid, v_identity_type, v_value;
IF done THEN
LEAVE read_loop;
END IF;

INSERT IGNORE INTO `QuotaVO` (`uuid`, `name`, `identityUuid`, `identityType`, `value`, `lastOpDate`, `createDate`)
VALUES (
REPLACE(UUID(), '-', ''),
'container.gpu.video.ram.size.nvidia',
v_identity_uuid,
v_identity_type,
v_value,
NOW(),
NOW()
);
END LOOP;
CLOSE cur;
END$$

DELIMITER ;

CALL MigrateGpuQuotaPerVendor();
DROP PROCEDURE IF EXISTS MigrateGpuQuotaPerVendor;