Skip to content

Commit 3e889d3

Browse files
author
gitlab
committed
Merge branch 'fix/ZSTAC-81566-clean@@2' into '5.5.6'
<fix>[ai]: add clusterId column to ModelServiceInstanceVO for node restart recovery See merge request zstackio/zstack!9140
2 parents ce1fd9a + 0dd1285 commit 3e889d3

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

conf/db/upgrade/V5.5.6__schema.sql

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,32 @@ WHERE p.type NOT IN (
190190
'GPU_Co_Processor',
191191
'GPU_Communication_Controller'
192192
);
193+
194+
-- ZSTAC-81566: Persist clusterId on ModelServiceInstanceVO to survive node restart
195+
-- V5.3.22 may have already added this column as INT; ensure BIGINT to match Java Long type
196+
CALL ADD_COLUMN('ModelServiceInstanceVO', 'clusterId', 'BIGINT', 1, NULL);
197+
198+
DROP PROCEDURE IF EXISTS EnsureClusterIdBigint;
199+
DELIMITER $$
200+
CREATE PROCEDURE EnsureClusterIdBigint()
201+
BEGIN
202+
DECLARE col_type VARCHAR(64);
203+
SELECT DATA_TYPE INTO col_type
204+
FROM INFORMATION_SCHEMA.COLUMNS
205+
WHERE TABLE_SCHEMA = 'zstack'
206+
AND TABLE_NAME = 'ModelServiceInstanceVO'
207+
AND COLUMN_NAME = 'clusterId';
208+
209+
IF col_type = 'int' THEN
210+
ALTER TABLE `zstack`.`ModelServiceInstanceVO` MODIFY COLUMN `clusterId` BIGINT NULL;
211+
END IF;
212+
END$$
213+
DELIMITER ;
214+
CALL EnsureClusterIdBigint();
215+
DROP PROCEDURE IF EXISTS EnsureClusterIdBigint;
216+
217+
-- Backfill existing data from PodVO
218+
UPDATE ModelServiceInstanceVO msi
219+
INNER JOIN PodVO p ON msi.vmInstanceUuid = p.uuid
220+
SET msi.clusterId = p.clusterId
221+
WHERE msi.clusterId IS NULL AND p.clusterId IS NOT NULL;

0 commit comments

Comments
 (0)