Fix for usage server getting stuck due to duplicate VM events (#13019)

This commit is contained in:
Abhisar Sinha 2026-06-11 23:50:33 +05:30 committed by GitHub
parent a3970bb153
commit 7bc458ff85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 61 additions and 1 deletions

View File

@ -33,7 +33,6 @@ import java.util.List;
import javax.inject.Inject;
import com.cloud.upgrade.dao.Upgrade42020to42030;
import com.cloud.utils.FileUtil;
import org.apache.cloudstack.utils.CloudStackVersion;
import org.apache.commons.lang3.StringUtils;
@ -90,6 +89,8 @@ import com.cloud.upgrade.dao.Upgrade41810to41900;
import com.cloud.upgrade.dao.Upgrade41900to41910;
import com.cloud.upgrade.dao.Upgrade41910to42000;
import com.cloud.upgrade.dao.Upgrade42000to42010;
import com.cloud.upgrade.dao.Upgrade42020to42030;
import com.cloud.upgrade.dao.Upgrade42030to42040;
import com.cloud.upgrade.dao.Upgrade420to421;
import com.cloud.upgrade.dao.Upgrade421to430;
import com.cloud.upgrade.dao.Upgrade430to440;
@ -238,6 +239,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
.next("4.19.1.0", new Upgrade41910to42000())
.next("4.20.0.0", new Upgrade42000to42010())
.next("4.20.2.0", new Upgrade42020to42030())
.next("4.20.3.0", new Upgrade42030to42040())
.build();
}

View File

@ -0,0 +1,58 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.upgrade.dao;
import java.io.InputStream;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
public class Upgrade42030to42040 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
@Override
public String[] getUpgradableVersionRange() {
return new String[]{"4.20.3.0", "4.20.4.0"};
}
@Override
public String getUpgradedVersion() {
return "4.20.4.0";
}
@Override
public boolean supportsRollingUpgrade() {
return false;
}
@Override
public InputStream[] getPrepareScripts() {
return null;
}
@Override
public void performDataMigration(Connection conn) {
final List<String> indexList = new ArrayList<String>();
logger.debug("Dropping index vm_instance_id from usage_vm_instance table if it exists");
indexList.add("vm_instance_id");
DbUpgradeUtils.dropKeysIfExist(conn, "cloud_usage.usage_vm_instance", indexList, false);
}
@Override
public InputStream[] getCleanupScripts() {
return null;
}
}