Skip to content

Commit 019f2c6

Browse files
server: fix vm_stats records are not removed if batchsize is 0 (#9818)
1 parent 20901c7 commit 019f2c6

File tree

5 files changed

+2
-36
lines changed

5 files changed

+2
-36
lines changed

engine/schema/src/main/java/com/cloud/storage/dao/VolumeStatsDaoImpl.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,7 @@ public void removeAllByTimestampLessThan(Date limitDate, long limitPerQuery) {
126126

127127
logger.debug(String.format("Starting to remove all volume_stats rows older than [%s].", limitDate));
128128

129-
long totalRemoved = 0;
130-
long removed;
131-
132-
do {
133-
removed = expunge(sc, limitPerQuery);
134-
totalRemoved += removed;
135-
logger.trace(String.format("Removed [%s] volume_stats rows on the last update and a sum of [%s] volume_stats rows older than [%s] until now.", removed, totalRemoved, limitDate));
136-
} while (limitPerQuery > 0 && removed >= limitPerQuery);
129+
long totalRemoved = batchExpunge(sc, limitPerQuery);
137130

138131
logger.info(String.format("Removed a total of [%s] volume_stats rows older than [%s].", totalRemoved, limitDate));
139132
}

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

+1-8
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,7 @@ public void removeAllByTimestampLessThan(Date limitDate, long limitPerQuery) {
123123

124124
logger.debug(String.format("Starting to remove all vm_stats rows older than [%s].", limitDate));
125125

126-
long totalRemoved = 0;
127-
long removed;
128-
129-
do {
130-
removed = expunge(sc, limitPerQuery);
131-
totalRemoved += removed;
132-
logger.trace(String.format("Removed [%s] vm_stats rows on the last update and a sum of [%s] vm_stats rows older than [%s] until now.", removed, totalRemoved, limitDate));
133-
} while (limitPerQuery > 0 && removed >= limitPerQuery);
126+
long totalRemoved = batchExpunge(sc, limitPerQuery);
134127

135128
logger.info(String.format("Removed a total of [%s] vm_stats rows older than [%s].", totalRemoved, limitDate));
136129
}

framework/db/src/main/java/com/cloud/utils/db/GenericDao.java

-8
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,6 @@ public interface GenericDao<T, ID extends Serializable> {
247247

248248
int expungeList(List<ID> ids);
249249

250-
/**
251-
* Delete the entity beans specified by the search criteria with a given limit
252-
* @param sc Search criteria
253-
* @param limit Maximum number of rows that will be affected
254-
* @return Number of rows deleted
255-
*/
256-
int expunge(SearchCriteria<T> sc, long limit);
257-
258250
/**
259251
* expunge the removed rows.
260252
*/

framework/db/src/main/java/com/cloud/utils/db/GenericDaoBase.java

-7
Original file line numberDiff line numberDiff line change
@@ -1244,13 +1244,6 @@ public boolean expunge(final ID id) {
12441244
}
12451245
}
12461246

1247-
// FIXME: Does not work for joins.
1248-
@Override
1249-
public int expunge(final SearchCriteria<T> sc, long limit) {
1250-
Filter filter = new Filter(limit);
1251-
return expunge(sc, filter);
1252-
}
1253-
12541247
@Override
12551248
public int expunge(final SearchCriteria<T> sc, final Filter filter) {
12561249
if (sc == null) {

server/src/test/java/com/cloud/user/MockUsageEventDao.java

-5
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,6 @@ public int expunge(SearchCriteria<UsageEventVO> sc) {
210210
return 0;
211211
}
212212

213-
@Override
214-
public int expunge(SearchCriteria<UsageEventVO> sc, long limit) {
215-
return 0;
216-
}
217-
218213
@Override
219214
public void expunge() {
220215

0 commit comments

Comments
 (0)