Skip to content

Commit

Permalink
server: fix vm_stats records are not removed if batchsize is 0 (#9818)
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache authored Oct 18, 2024
1 parent 20901c7 commit 019f2c6
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,7 @@ public void removeAllByTimestampLessThan(Date limitDate, long limitPerQuery) {

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

long totalRemoved = 0;
long removed;

do {
removed = expunge(sc, limitPerQuery);
totalRemoved += removed;
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));
} while (limitPerQuery > 0 && removed >= limitPerQuery);
long totalRemoved = batchExpunge(sc, limitPerQuery);

logger.info(String.format("Removed a total of [%s] volume_stats rows older than [%s].", totalRemoved, limitDate));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,7 @@ public void removeAllByTimestampLessThan(Date limitDate, long limitPerQuery) {

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

long totalRemoved = 0;
long removed;

do {
removed = expunge(sc, limitPerQuery);
totalRemoved += removed;
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));
} while (limitPerQuery > 0 && removed >= limitPerQuery);
long totalRemoved = batchExpunge(sc, limitPerQuery);

logger.info(String.format("Removed a total of [%s] vm_stats rows older than [%s].", totalRemoved, limitDate));
}
Expand Down
8 changes: 0 additions & 8 deletions framework/db/src/main/java/com/cloud/utils/db/GenericDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,6 @@ public interface GenericDao<T, ID extends Serializable> {

int expungeList(List<ID> ids);

/**
* Delete the entity beans specified by the search criteria with a given limit
* @param sc Search criteria
* @param limit Maximum number of rows that will be affected
* @return Number of rows deleted
*/
int expunge(SearchCriteria<T> sc, long limit);

/**
* expunge the removed rows.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1244,13 +1244,6 @@ public boolean expunge(final ID id) {
}
}

// FIXME: Does not work for joins.
@Override
public int expunge(final SearchCriteria<T> sc, long limit) {
Filter filter = new Filter(limit);
return expunge(sc, filter);
}

@Override
public int expunge(final SearchCriteria<T> sc, final Filter filter) {
if (sc == null) {
Expand Down
5 changes: 0 additions & 5 deletions server/src/test/java/com/cloud/user/MockUsageEventDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,6 @@ public int expunge(SearchCriteria<UsageEventVO> sc) {
return 0;
}

@Override
public int expunge(SearchCriteria<UsageEventVO> sc, long limit) {
return 0;
}

@Override
public void expunge() {

Expand Down

0 comments on commit 019f2c6

Please sign in to comment.