Skip to content

Commit 6516f7f

Browse files
authored
Fix query execution in countVgpuVMs (#12713)
1 parent 9e386a3 commit 6516f7f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,15 +846,18 @@ public HashMap<String, Long> countVgpuVMs(Long dcId, Long podId, Long clusterId)
846846

847847
try {
848848
pstmtLegacy = txn.prepareAutoCloseStatement(finalQueryLegacy.toString());
849-
pstmt = txn.prepareAutoCloseStatement(finalQuery.toString());
850849
for (int i = 0; i < resourceIdList.size(); i++) {
851850
pstmtLegacy.setLong(1 + i, resourceIdList.get(i));
852-
pstmt.setLong(1 + i, resourceIdList.get(i));
853851
}
854852
ResultSet rs = pstmtLegacy.executeQuery();
855853
while (rs.next()) {
856854
result.put(rs.getString(1).concat(rs.getString(2)), rs.getLong(3));
857855
}
856+
857+
pstmt = txn.prepareAutoCloseStatement(finalQuery.toString());
858+
for (int i = 0; i < resourceIdList.size(); i++) {
859+
pstmt.setLong(1 + i, resourceIdList.get(i));
860+
}
858861
rs = pstmt.executeQuery();
859862
while (rs.next()) {
860863
result.put(rs.getString(1).concat(rs.getString(2)), rs.getLong(3));

0 commit comments

Comments
 (0)