-
Notifications
You must be signed in to change notification settings - Fork 625
HDDS-13136. KeyDeleting Service should not run for already deep cleaned snapshots #8525
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,11 +172,11 @@ public void setKeyLimitPerTask(int keyLimitPerTask) { | |
| * the blocks info in its deletedBlockLog), it removes these keys from the | ||
| * DB. | ||
| */ | ||
| private final class KeyDeletingTask implements BackgroundTask { | ||
| final class KeyDeletingTask implements BackgroundTask { | ||
| private final KeyDeletingService deletingService; | ||
| private final UUID snapshotId; | ||
|
|
||
| private KeyDeletingTask(KeyDeletingService service, UUID snapshotId) { | ||
| KeyDeletingTask(KeyDeletingService service, UUID snapshotId) { | ||
| this.deletingService = service; | ||
| this.snapshotId = snapshotId; | ||
| } | ||
|
|
@@ -321,6 +321,10 @@ public BackgroundTaskResult call() { | |
| snapInfo = snapshotId == null ? null : | ||
| SnapshotUtils.getSnapshotInfo(getOzoneManager(), snapshotChainManager, snapshotId); | ||
| if (snapInfo != null) { | ||
| if (snapInfo.getDeepClean()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would read more natural if it's named isDeepCleaned().
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| LOG.info("Snapshot {} has already been deep cleaned. Skipping the snapshot in this iteration.", snapInfo); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SnapshotInfo.toString() is a super long and complex string. What about just the snapshot id + volume/bucket instead?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done, just keeping the snapshotId should be enough for debugging |
||
| return EmptyTaskResult.newResult(); | ||
| } | ||
| if (!OmSnapshotManager.areSnapshotChangesFlushedToDB(getOzoneManager().getMetadataManager(), snapInfo)) { | ||
| LOG.info("Skipping snapshot processing since changes to snapshot {} have not been flushed to disk", | ||
| snapInfo); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,11 +31,14 @@ | |||||||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||||||||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||||||||
| import static org.mockito.ArgumentMatchers.any; | ||||||||
| import static org.mockito.ArgumentMatchers.anyBoolean; | ||||||||
| import static org.mockito.ArgumentMatchers.anyInt; | ||||||||
| import static org.mockito.ArgumentMatchers.anyLong; | ||||||||
| import static org.mockito.Mockito.CALLS_REAL_METHODS; | ||||||||
| import static org.mockito.Mockito.clearInvocations; | ||||||||
| import static org.mockito.Mockito.doAnswer; | ||||||||
| import static org.mockito.Mockito.mockStatic; | ||||||||
| import static org.mockito.Mockito.verify; | ||||||||
| import static org.mockito.Mockito.when; | ||||||||
|
|
||||||||
| import com.google.common.collect.ImmutableMap; | ||||||||
|
|
@@ -48,18 +51,22 @@ | |||||||
| import java.util.LinkedList; | ||||||||
| import java.util.List; | ||||||||
| import java.util.Map; | ||||||||
| import java.util.UUID; | ||||||||
| import java.util.concurrent.TimeUnit; | ||||||||
| import java.util.concurrent.TimeoutException; | ||||||||
| import java.util.concurrent.atomic.AtomicInteger; | ||||||||
| import java.util.concurrent.atomic.AtomicLong; | ||||||||
| import java.util.concurrent.atomic.AtomicReference; | ||||||||
| import java.util.stream.Collectors; | ||||||||
| import java.util.stream.IntStream; | ||||||||
| import org.apache.commons.lang3.RandomStringUtils; | ||||||||
| import org.apache.hadoop.hdds.client.BlockID; | ||||||||
| import org.apache.hadoop.hdds.client.RatisReplicationConfig; | ||||||||
| import org.apache.hadoop.hdds.client.StandaloneReplicationConfig; | ||||||||
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||||||||
| import org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList; | ||||||||
| import org.apache.hadoop.hdds.server.ServerUtils; | ||||||||
| import org.apache.hadoop.hdds.utils.BackgroundTaskQueue; | ||||||||
| import org.apache.hadoop.hdds.utils.db.DBConfigFromFile; | ||||||||
| import org.apache.hadoop.hdds.utils.db.Table; | ||||||||
| import org.apache.hadoop.hdds.utils.db.TableIterator; | ||||||||
|
|
@@ -74,6 +81,7 @@ | |||||||
| import org.apache.hadoop.ozone.om.OzoneManager; | ||||||||
| import org.apache.hadoop.ozone.om.PendingKeysDeletion; | ||||||||
| import org.apache.hadoop.ozone.om.ScmBlockLocationTestingClient; | ||||||||
| import org.apache.hadoop.ozone.om.SnapshotChainManager; | ||||||||
| import org.apache.hadoop.ozone.om.helpers.BucketLayout; | ||||||||
| import org.apache.hadoop.ozone.om.helpers.KeyInfoWithVolumeContext; | ||||||||
| import org.apache.hadoop.ozone.om.helpers.OmBucketInfo; | ||||||||
|
|
@@ -583,6 +591,41 @@ void testSnapshotDeepClean() throws Exception { | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| @Test | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||
| public void testKeyDeletingServiceWithDeepCleanedSnapshots() throws Exception { | ||||||||
| OzoneManager ozoneManager = Mockito.spy(om); | ||||||||
| OmMetadataManagerImpl omMetadataManager = Mockito.mock(OmMetadataManagerImpl.class); | ||||||||
| SnapshotChainManager snapshotChainManager = Mockito.mock(SnapshotChainManager.class); | ||||||||
| OmSnapshotManager omSnapshotManager = Mockito.mock(OmSnapshotManager.class); | ||||||||
| when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager); | ||||||||
| when(ozoneManager.getOmSnapshotManager()).thenReturn(omSnapshotManager); | ||||||||
| when(omMetadataManager.getSnapshotChainManager()).thenReturn(snapshotChainManager); | ||||||||
| when(snapshotChainManager.getTableKey(any(UUID.class))) | ||||||||
| .thenAnswer(i -> i.getArgument(0).toString()); | ||||||||
| Table snapshotInfoTable = Mockito.mock(Table.class); | ||||||||
| when(omMetadataManager.getSnapshotInfoTable()).thenReturn(snapshotInfoTable); | ||||||||
| when(snapshotInfoTable.get(any(String.class))).thenAnswer(i -> { | ||||||||
| SnapshotInfo snapshotInfo = Mockito.mock(SnapshotInfo.class); | ||||||||
| when(snapshotInfo.getSnapshotId()).thenReturn(UUID.fromString(i.getArgument(0))); | ||||||||
| when(snapshotInfo.getDeepClean()).thenReturn(true); | ||||||||
| return snapshotInfo; | ||||||||
| }); | ||||||||
| List<UUID> snapshotIds = IntStream.range(0, 10).mapToObj(i -> UUID.randomUUID()).collect(Collectors.toList()); | ||||||||
| when(snapshotChainManager.iterator(anyBoolean())).thenAnswer(i -> snapshotIds.iterator()); | ||||||||
| KeyDeletingService kds = Mockito.spy(new KeyDeletingService(ozoneManager, scmBlockTestingClient, 10000, | ||||||||
| 100000, conf, 10, true)); | ||||||||
| when(kds.getTasks()).thenAnswer(i -> { | ||||||||
| BackgroundTaskQueue queue = new BackgroundTaskQueue(); | ||||||||
| for (UUID id : snapshotIds) { | ||||||||
| queue.add(kds.new KeyDeletingTask(kds, id)); | ||||||||
| } | ||||||||
| return queue; | ||||||||
| }); | ||||||||
| kds.runPeriodicalTaskNow(); | ||||||||
| clearInvocations(omSnapshotManager); | ||||||||
| verify(omSnapshotManager, Mockito.never()).getActiveSnapshot(any(), any(), any()); | ||||||||
| } | ||||||||
|
|
||||||||
| @Test | ||||||||
| void testSnapshotExclusiveSize() throws Exception { | ||||||||
| Table<String, SnapshotInfo> snapshotInfoTable = | ||||||||
|
|
||||||||
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.
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