Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
Add configuration to limit the number of rows deleted from vm_stats#8740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DaanHoogland
merged 5 commits into
apache:4.19
from
scclouds:add-limit-to-vm_stats-deleteJun 20, 2024
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a2f238b
Add configuration to limit the number of rows deleted from vm_stats
ef39209
Address review
JoaoJandre 81bb609
fix tests
JoaoJandre c47ddc6
fix checkstyle
JoaoJandre d401488
Merge remote-tracking branch 'origin/4.19' into add-limit-to-vm_stats…
JoaoJandre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 18 additions & 3 deletions
21 engine/schema/src/main/java/com/cloud/vm/dao/VmStatsDaoImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8 framework/db/src/main/java/com/cloud/utils/db/GenericDao.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12 framework/db/src/main/java/com/cloud/utils/db/GenericDaoBase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1226,9 +1226,14 @@ public boolean expunge(final ID id) { | ||
| } | ||
| } | ||
| // FIXME: Does not work for joins. | ||
| @Override | ||
| public int expunge(final SearchCriteria<T> sc) { | ||
| return expunge(sc, -1); | ||
| } | ||
| // FIXME: Does not work for joins. | ||
| @Override | ||
| public int expunge(final SearchCriteria<T> sc, long limit) { | ||
| if (sc == null) { | ||
| throw new CloudRuntimeException("Call to throw new expunge with null search Criteria"); | ||
| } | ||
| @@ -1241,6 +1246,11 @@ public int expunge(final SearchCriteria<T> sc) { | ||
| str.append(sc.getWhereClause()); | ||
| } | ||
| if (limit > 0) { | ||
JoaoJandre marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| str.append(" LIMIT "); | ||
| str.append(limit); | ||
| } | ||
| final String sql = str.toString(); | ||
| final TransactionLegacy txn = TransactionLegacy.currentTxn(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -114,9 +114,6 @@ | ||
| import com.cloud.resource.ResourceManager; | ||
| import com.cloud.resource.ResourceState; | ||
| import com.cloud.serializer.GsonHelper; | ||
| import com.cloud.server.StatsCollector.AbstractStatsCollector; | ||
| import com.cloud.server.StatsCollector.AutoScaleMonitor; | ||
| import com.cloud.server.StatsCollector.StorageCollector; | ||
| import com.cloud.storage.ImageStoreDetailsUtil; | ||
| import com.cloud.storage.ScopeType; | ||
| import com.cloud.storage.Storage; | ||
| @@ -287,6 +284,11 @@ public String toString() { | ||
| protected static ConfigKey<Boolean> vmStatsCollectUserVMOnly = new ConfigKey<>("Advanced", Boolean.class, "vm.stats.user.vm.only", "false", | ||
| "When set to 'false' stats for system VMs will be collected otherwise stats collection will be done only for user VMs", true); | ||
| protected static ConfigKey<Long> vmStatsRemoveBatchSize = new ConfigKey<>("Advanced", Long.class, "vm.stats.remove.batch.size", "0", "Indicates the" + | ||
JoaoJandre marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| " limit applied to delete vm_stats entries while running the clean-up task. With this, ACS will run the delete query, applying the limit, as many times as necessary" + | ||
| " to delete all entries older than the value defined in vm.stats.max.retention.time. This is advised when retaining several days of records, which can lead to slowness" + | ||
| " on the delete query. Zero (0) means that no limit will be applied, therefore, the query will run once and without limit, keeping the default behavior.", true); | ||
| protected static ConfigKey<Boolean> vmDiskStatsRetentionEnabled = new ConfigKey<>("Advanced", Boolean.class, "vm.disk.stats.retention.enabled", "false", | ||
| "When set to 'true' stats for VM disks will be stored in the database otherwise disk stats will not be stored", true); | ||
| @@ -1952,7 +1954,7 @@ protected void cleanUpVirtualMachineStats() { | ||
| LOGGER.trace("Removing older VM stats records."); | ||
| Date now = new Date(); | ||
| Date limit = DateUtils.addMinutes(now, -maxRetentionTime); | ||
| vmStatsDao.removeAllByTimestampLessThan(limit); | ||
| vmStatsDao.removeAllByTimestampLessThan(limit, vmStatsRemoveBatchSize.value()); | ||
| } | ||
| /** | ||
| @@ -2126,7 +2128,7 @@ public String getConfigComponentName() { | ||
| @Override | ||
| public ConfigKey<?>[] getConfigKeys() { | ||
| return new ConfigKey<?>[] {vmDiskStatsInterval, vmDiskStatsIntervalMin, vmNetworkStatsInterval, vmNetworkStatsIntervalMin, StatsTimeout, statsOutputUri, | ||
| return new ConfigKey<?>[] {vmDiskStatsInterval, vmDiskStatsIntervalMin, vmNetworkStatsInterval, vmNetworkStatsIntervalMin, StatsTimeout, statsOutputUri, vmStatsRemoveBatchSize, | ||
| vmStatsIncrementMetrics, vmStatsMaxRetentionTime, vmStatsCollectUserVMOnly, vmDiskStatsRetentionEnabled, vmDiskStatsMaxRetentionTime, | ||
| MANAGEMENT_SERVER_STATUS_COLLECTION_INTERVAL, | ||
| DATABASE_SERVER_STATUS_COLLECTION_INTERVAL, | ||
8 changes: 4 additions & 4 deletions
8 server/src/test/java/com/cloud/server/StatsCollectorTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.