-
Notifications
You must be signed in to change notification settings - Fork 276
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
[CLOUD_CONTAINER_DELETION] Core logic for container compaction #1646
[CLOUD_CONTAINER_DELETION] Core logic for container compaction #1646
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1646 +/- ##
============================================
- Coverage 73.56% 73.42% -0.14%
- Complexity 8639 8748 +109
============================================
Files 609 619 +10
Lines 47183 47827 +644
Branches 5962 6035 +73
============================================
+ Hits 34708 35119 +411
- Misses 10694 10903 +209
- Partials 1781 1805 +24 Continue to review full report at Codecov.
|
c7a0711
to
72e3f58
Compare
Codecov Report
@@ Coverage Diff @@
## master #1646 +/- ##
=============================================
- Coverage 73.65% 15.71% -57.95%
+ Complexity 8804 2088 -6716
=============================================
Files 629 630 +1
Lines 48371 48539 +168
Branches 6076 6094 +18
=============================================
- Hits 35626 7626 -28000
- Misses 10872 40476 +29604
+ Partials 1873 437 -1436 Continue to review full report at Codecov.
|
56735bb
to
3874f5a
Compare
Haven't reviewed yet, but Codecov says the diff coverages is just over 40%, so may want to beef that up. |
ambry-api/src/main/java/com/github/ambry/config/CloudConfig.java
Outdated
Show resolved
Hide resolved
cloudContainerCompactionIntervalHours = verifiableProperties.getInt(CLOUD_CONTAINER_COMPACTION_INTERVAL_HOURS, 24); | ||
cloudBlobCompactionStartupDelaySecs = verifiableProperties.getInt(CLOUD_BLOB_COMPACTION_STARTUP_DELAY_SECS, 600); | ||
cloudContainerCompactionStartupDelaySecs = | ||
verifiableProperties.getInt(CLOUD_CONTAINER_COMPACTION_STARTUP_DELAY_SECS, 600); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest using getIntInRange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
ambry-cloud/src/main/java/com/github/ambry/cloud/VcrReplicationManager.java
Show resolved
Hide resolved
ambry-cloud/src/main/java/com/github/ambry/cloud/VcrReplicationManager.java
Show resolved
Hide resolved
cosmosContainerDeletionBatchSize = | ||
verifiableProperties.getInt(COSMOS_CONTAINER_DELETION_BATCH_SIZE, DEFAULT_COSMOS_CONTAINER_DELETION_BATCH_SIZE); | ||
containerCompactionAbsPurgeLimit = | ||
verifiableProperties.getInt(CONTAINER_COMPACTION_ABS_PURGE_LIMIT, DEFAULT_CONTAINER_COMPACTION_ABS_PURGE_LIMIT); | ||
containerCompactionCosmosQueryLimit = verifiableProperties.getInt(CONTAINER_COMPACTION_COSMOS_QUERY_LIMIT, | ||
DEFAULT_COSMOS_CONTAINER_DELETION_BATCH_SIZE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, better to use getIntInRange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its not 100% clear what the theoretical upper limit of this value should be. But it definitely shouldn't be less than 1. Made the changes accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good. A few concerns mentioned.
ambry-cloud/src/main/java/com/github/ambry/cloud/StaticVcrCluster.java
Outdated
Show resolved
Hide resolved
ambry-cloud/src/main/java/com/github/ambry/cloud/VcrMetrics.java
Outdated
Show resolved
Hide resolved
ambry-cloud/src/main/java/com/github/ambry/cloud/VcrReplicationManager.java
Show resolved
Hide resolved
ambry-cloud/src/main/java/com/github/ambry/cloud/VcrReplicationManager.java
Outdated
Show resolved
Hide resolved
ambry-cloud/src/main/java/com/github/ambry/cloud/azure/CosmosDataAccessor.java
Outdated
Show resolved
Hide resolved
throws DocumentClientException { | ||
String query = String.format(CONTAINER_BLOBS_QUERY, accountId, containerId); | ||
SqlQuerySpec querySpec = new SqlQuerySpec(query); | ||
FeedOptions feedOptions = new FeedOptions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code from here down is nearly identical to getDeadBlobs. Please refactor into a common class that take SqlQuerySpec as argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, since we aren't time bucketing the queries like dead blob compaction does, we could run into the same throttling issues that prompted the use of time bucketing there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true. I plan to post a final follow up PR that would add two more optimizations
- Do the container compaction in multiple threads.
- Do a time based bucketing for deletion.
// Read the existing record | ||
String id = CosmosContainerDeletionEntry.generateContainerDeletionEntryId(accountId, containerId); | ||
String docLink = getContainerDeletionEntryDocumentLink(id); | ||
RequestOptions options = getRequestOptions(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of this logic is very similar to updateMetadata(). Possible to reuse/combine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add as an action item for follow up PR.
ambry-cloud/src/main/java/com/github/ambry/cloud/azure/AzureCompactionUtil.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall lgtm. Added some minor comments.
* Compact blobs of the deprecated container from cloud. This method is one of the two entry points in the | ||
* {@link AzureContainerCompactor} class along with {@link AzureContainerCompactor#deprecateContainers(Collection, Collection)}. | ||
* Note that this method is not thread safe as it is expected to run in a single thread. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: missing java doc for @param assignedPartitions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@@ -13,9 +13,12 @@ | |||
*/ | |||
package com.github.ambry.cloud.azure; | |||
|
|||
import com.codahale.metrics.Timer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: you can removed them since they are not been used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
static final String DELETE_PENDING_PARTITIONS_KEY = "deletePendingPartitions"; | ||
private static final String ID_KEY = "id"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
containerDeletionEntrySet.remove(containerDeletionEntry); | ||
for (String partitionId : containerDeletionEntry.getDeletePendingPartitions()) { | ||
try { | ||
int blobCompactedCount = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the blobCompactedCount never been used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will use it in future PR when I plan to add more metrics to the code.
List<? extends PartitionId> assignedPartitions) throws CloudStorageException { | ||
Set<CosmosContainerDeletionEntry> containerDeletionEntrySet = | ||
requestAgent.doWithRetries(() -> cosmosDataAccessor.getDeprecatedContainers(containerDeletionQueryBatchSize), | ||
"GetDeprectedContainers", null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: GetDeprectedContainers -> GetDeprecatedContainers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
3f585ab
to
4dcc9f1
Compare
private static final String EXPIRED_BLOBS_QUERY = constructDeadBlobsQuery(CloudBlobMetadata.FIELD_EXPIRATION_TIME); | ||
private static final String DELETED_BLOBS_QUERY = constructDeadBlobsQuery(CloudBlobMetadata.FIELD_DELETION_TIME); | ||
private static final String CONTAINER_BLOBS_QUERY = | ||
"SELECT TOP %d * FROM c WHERE c.accountId=%d and c.containerId=%d"; | ||
"SELECT TOP %d " + LIMIT_PARAM + " FROM c WHERE c.accountId=" + ACCOUNT_ID_PARAM + " and c.containerId=" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Cosmos will reject this. "%d" needs to be removed, and you need the "*" before FROM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
private static final String EXPIRED_BLOBS_QUERY = constructDeadBlobsQuery(CloudBlobMetadata.FIELD_EXPIRATION_TIME); | ||
private static final String DELETED_BLOBS_QUERY = constructDeadBlobsQuery(CloudBlobMetadata.FIELD_DELETION_TIME); | ||
private static final String CONTAINER_BLOBS_QUERY = | ||
"SELECT TOP %d * FROM c WHERE c.accountId=%d and c.containerId=%d"; | ||
"SELECT TOP %d " + LIMIT_PARAM + " FROM c WHERE c.accountId=" + ACCOUNT_ID_PARAM + " and c.containerId=" | ||
+ CONTAINER_ID_PARAM; | ||
private static final String BULK_DELETE_QUERY = "SELECT c._self FROM c WHERE c.id IN (%s)"; | ||
private static final String DEPRECATED_CONTAINERS_QUERY = | ||
"SELECT TOP %d * from c WHERE c.deleted=false order by c.deleteTriggerTimestamp"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to LIMIT_PARAM too? I missed it earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the Cosmos queries.
@@ -72,15 +72,15 @@ | |||
private static final String LIMIT_PARAM = "@limit"; | |||
private static final String ACCOUNT_ID_PARAM = "@accountId"; | |||
private static final String CONTAINER_ID_PARAM = "@containerId"; | |||
private static final String MAX_ENTRIES_PARAM = "@maxEntries"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between LIMIT and MAX_ENTRIES params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed MAX_ENTRIES.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like it.
…en cloud and helix account service.
d67105d
to
7f6c44c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed all review comments.
private static final String EXPIRED_BLOBS_QUERY = constructDeadBlobsQuery(CloudBlobMetadata.FIELD_EXPIRATION_TIME); | ||
private static final String DELETED_BLOBS_QUERY = constructDeadBlobsQuery(CloudBlobMetadata.FIELD_DELETION_TIME); | ||
private static final String CONTAINER_BLOBS_QUERY = | ||
"SELECT TOP %d * FROM c WHERE c.accountId=%d and c.containerId=%d"; | ||
"SELECT TOP %d " + LIMIT_PARAM + " FROM c WHERE c.accountId=" + ACCOUNT_ID_PARAM + " and c.containerId=" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
private static final String EXPIRED_BLOBS_QUERY = constructDeadBlobsQuery(CloudBlobMetadata.FIELD_EXPIRATION_TIME); | ||
private static final String DELETED_BLOBS_QUERY = constructDeadBlobsQuery(CloudBlobMetadata.FIELD_DELETION_TIME); | ||
private static final String CONTAINER_BLOBS_QUERY = | ||
"SELECT TOP %d * FROM c WHERE c.accountId=%d and c.containerId=%d"; | ||
"SELECT TOP %d " + LIMIT_PARAM + " FROM c WHERE c.accountId=" + ACCOUNT_ID_PARAM + " and c.containerId=" | ||
+ CONTAINER_ID_PARAM; | ||
private static final String BULK_DELETE_QUERY = "SELECT c._self FROM c WHERE c.id IN (%s)"; | ||
private static final String DEPRECATED_CONTAINERS_QUERY = | ||
"SELECT TOP %d * from c WHERE c.deleted=false order by c.deleteTriggerTimestamp"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
@@ -72,15 +72,15 @@ | |||
private static final String LIMIT_PARAM = "@limit"; | |||
private static final String ACCOUNT_ID_PARAM = "@accountId"; | |||
private static final String CONTAINER_ID_PARAM = "@containerId"; | |||
private static final String MAX_ENTRIES_PARAM = "@maxEntries"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed MAX_ENTRIES.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for making the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…din#1646) * Initial implementation of Helix task to sync deleted containers between cloud and helix account service.
Container deletion logic in cloud.