-
Notifications
You must be signed in to change notification settings - Fork 625
HDDS-13022. Split up exclusive size tracking for key and directory cleanup in SnapshotInfo #8433
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 5 commits
8c626c6
50b1a23
685aac2
c29d3d8
49184f6
2014b2a
ea94417
7bcbda6
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 |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.ozone.client; | ||
|
|
||
| import static org.apache.hadoop.ozone.om.helpers.SnapshotInfo.SnapshotStatus.SNAPSHOT_ACTIVE; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import java.util.UUID; | ||
| import org.apache.hadoop.ozone.om.helpers.SnapshotInfo; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.Mockito; | ||
|
|
||
| /** | ||
| * Test class for OzoneSnapshot class. | ||
| */ | ||
| public class TestOzoneSnapshot { | ||
|
|
||
| private SnapshotInfo getMockedSnapshotInfo(UUID snapshotId) { | ||
| SnapshotInfo snapshotInfo = Mockito.mock(SnapshotInfo.class); | ||
| when(snapshotInfo.getVolumeName()).thenReturn("volume"); | ||
| when(snapshotInfo.getBucketName()).thenReturn("bucket"); | ||
| when(snapshotInfo.getName()).thenReturn("snap"); | ||
| when(snapshotInfo.getCreationTime()).thenReturn(1000L); | ||
| when(snapshotInfo.getSnapshotStatus()).thenReturn(SNAPSHOT_ACTIVE); | ||
| when(snapshotInfo.getSnapshotId()).thenReturn(snapshotId); | ||
| when(snapshotInfo.getSnapshotPath()).thenReturn("volume/bucket"); | ||
| when(snapshotInfo.getCheckpointDir()).thenReturn("checkpointDir"); | ||
| when(snapshotInfo.getReferencedSize()).thenReturn(1000L); | ||
| when(snapshotInfo.getReferencedReplicatedSize()).thenReturn(3000L); | ||
| when(snapshotInfo.getExclusiveSize()).thenReturn(4000L); | ||
| when(snapshotInfo.getExclusiveReplicatedSize()).thenReturn(12000L); | ||
| when(snapshotInfo.getExclusiveDirSize()).thenReturn(2000L); | ||
| when(snapshotInfo.getExclusiveDirReplicatedSize()).thenReturn(6000L); | ||
| return snapshotInfo; | ||
| } | ||
|
|
||
| @Test | ||
| public void testOzoneSnapshotFromSnapshotInfo() { | ||
| UUID snapshotId = UUID.randomUUID(); | ||
| SnapshotInfo snapshotInfo = getMockedSnapshotInfo(snapshotId); | ||
| OzoneSnapshot ozoneSnapshot = OzoneSnapshot.fromSnapshotInfo(snapshotInfo); | ||
| OzoneSnapshot expectedOzoneSnapshot = new OzoneSnapshot( | ||
| "volume", "bucket", "snap", 1000L, SNAPSHOT_ACTIVE, snapshotId, | ||
| "volume/bucket", "checkpointDir", 1000L, 3000L, 6000L, 18000L); | ||
| assertEquals(expectedOzoneSnapshot, ozoneSnapshot); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -303,6 +303,7 @@ message OMRequest { | |||||||||||||
| optional GetObjectTaggingRequest getObjectTaggingRequest = 140; | ||||||||||||||
| optional PutObjectTaggingRequest putObjectTaggingRequest = 141; | ||||||||||||||
| optional DeleteObjectTaggingRequest deleteObjectTaggingRequest = 142; | ||||||||||||||
| repeated SetSnapshotPropertyRequest SetSnapshotPropertyRequests = 143; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| message OMResponse { | ||||||||||||||
|
|
@@ -892,6 +893,9 @@ message SnapshotInfo { | |||||||||||||
| // note: shared sizes can be calculated from: referenced - exclusive | ||||||||||||||
| optional bool deepCleanedDeletedDir = 19; | ||||||||||||||
| optional bytes lastTransactionInfo = 20; | ||||||||||||||
| optional uint64 exclusiveDirSize = 21; | ||||||||||||||
| // snapshot exclusive size after replication | ||||||||||||||
| optional uint64 exclusiveDirReplicatedSize = 22; | ||||||||||||||
|
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. I'd suggest naming the variable as specific as possible since this is updated exclusively by
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 |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| message SnapshotDiffJobProto { | ||||||||||||||
|
|
@@ -2029,6 +2033,7 @@ message SetSnapshotPropertyRequest { | |||||||||||||
| optional SnapshotSize snapshotSize = 3; | ||||||||||||||
| optional bool deepCleanedDeletedDir = 4; | ||||||||||||||
| optional bool deepCleanedDeletedKey = 5; | ||||||||||||||
| optional SnapshotSize snapshotDirSize = 6; | ||||||||||||||
|
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 |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // SnapshotProperty in entirely deprecated, Keeping it here for proto.lock compatibility | ||||||||||||||
|
|
||||||||||||||
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.
Thanks for the patch Swami. But I think I'm missing some important context here.
exclusiveDirSize?exclusiveSize?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.
Summary from offline discussion:
exclusiveDirSizeis used exclusively bySnapshotDirectoryCleaningServiceso as to eliminate race condition withKeyDeletingService, which updatesexclusiveSizeat the same time and can cause race condition. The nameexclusiveDirSizeis misleading from my point of view and thus I suggest changing it.exclusiveSizeis now the combination of both as reflected inOzoneSnapshot. It is unfortunate that we can't change the proto field names without careful compatibility considerations.SnapshotDirectoryCleaningServicewould be removed later according to @swamirishiSnapshotInfowith incorrectexclusiveSizeandexclusiveReplicatedSizecan be updated by resetingdeepCleanedDeletedDirflag then triggering the calculation again. For which we need a small tool for that. cc @sumitagrawl