Skip to content

Commit 7bc458f

Browse files
authored
Fix for usage server getting stuck due to duplicate VM events (#13019)
1 parent a3970bb commit 7bc458f

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
import javax.inject.Inject;
3535

36-
import com.cloud.upgrade.dao.Upgrade42020to42030;
3736
import com.cloud.utils.FileUtil;
3837
import org.apache.cloudstack.utils.CloudStackVersion;
3938
import org.apache.commons.lang3.StringUtils;
@@ -90,6 +89,8 @@
9089
import com.cloud.upgrade.dao.Upgrade41900to41910;
9190
import com.cloud.upgrade.dao.Upgrade41910to42000;
9291
import com.cloud.upgrade.dao.Upgrade42000to42010;
92+
import com.cloud.upgrade.dao.Upgrade42020to42030;
93+
import com.cloud.upgrade.dao.Upgrade42030to42040;
9394
import com.cloud.upgrade.dao.Upgrade420to421;
9495
import com.cloud.upgrade.dao.Upgrade421to430;
9596
import com.cloud.upgrade.dao.Upgrade430to440;
@@ -238,6 +239,7 @@ public DatabaseUpgradeChecker() {
238239
.next("4.19.1.0", new Upgrade41910to42000())
239240
.next("4.20.0.0", new Upgrade42000to42010())
240241
.next("4.20.2.0", new Upgrade42020to42030())
242+
.next("4.20.3.0", new Upgrade42030to42040())
241243
.build();
242244
}
243245

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.upgrade.dao;
18+
19+
import java.io.InputStream;
20+
import java.sql.Connection;
21+
import java.util.ArrayList;
22+
import java.util.List;
23+
24+
public class Upgrade42030to42040 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
25+
26+
@Override
27+
public String[] getUpgradableVersionRange() {
28+
return new String[]{"4.20.3.0", "4.20.4.0"};
29+
}
30+
31+
@Override
32+
public String getUpgradedVersion() {
33+
return "4.20.4.0";
34+
}
35+
36+
@Override
37+
public boolean supportsRollingUpgrade() {
38+
return false;
39+
}
40+
41+
@Override
42+
public InputStream[] getPrepareScripts() {
43+
return null;
44+
}
45+
46+
@Override
47+
public void performDataMigration(Connection conn) {
48+
final List<String> indexList = new ArrayList<String>();
49+
logger.debug("Dropping index vm_instance_id from usage_vm_instance table if it exists");
50+
indexList.add("vm_instance_id");
51+
DbUpgradeUtils.dropKeysIfExist(conn, "cloud_usage.usage_vm_instance", indexList, false);
52+
}
53+
54+
@Override
55+
public InputStream[] getCleanupScripts() {
56+
return null;
57+
}
58+
}

0 commit comments

Comments
 (0)