-
Notifications
You must be signed in to change notification settings - Fork 517
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
HDDS-11784. Allow aborting FSO multipart uploads with missing parent directories #7700
base: master
Are you sure you want to change the base?
Changes from all commits
a0c6305
719fd57
e72c6fc
c0629eb
9a1967b
2362d58
c42634e
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 |
---|---|---|
|
@@ -115,6 +115,7 @@ | |
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.BUCKET_NOT_FOUND; | ||
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.FILE_NOT_FOUND; | ||
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.VOLUME_NOT_FOUND; | ||
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.NO_SUCH_MULTIPART_UPLOAD_ERROR; | ||
import static org.apache.hadoop.ozone.OzoneConsts.OM_SNAPSHOT_CHECKPOINT_DIR; | ||
import static org.apache.hadoop.ozone.om.service.SnapshotDeletingService.isBlockLocationInfoSame; | ||
import static org.apache.hadoop.ozone.om.snapshot.SnapshotUtils.checkSnapshotDirExist; | ||
|
@@ -899,11 +900,26 @@ public String getMultipartKeyFSO(String volume, String bucket, String key, Strin | |
final long volumeId = getVolumeId(volume); | ||
final long bucketId = getBucketId(volume, | ||
bucket); | ||
long parentId = | ||
OMFileRequest.getParentID(volumeId, bucketId, key, this); | ||
|
||
String fileName = OzoneFSUtils.getFileName(key); | ||
long parentId; | ||
try { | ||
parentId = OMFileRequest.getParentID(volumeId, bucketId, key, this); | ||
} catch (final Exception e) { | ||
// It is possible we miss directories and exception is thrown. | ||
// see https://issues.apache.org/jira/browse/HDDS-11784 | ||
LOG.warn("Got exception when finding parent id for {}/{}/{}. Use another way to get it", | ||
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. This might be a common occurance in a concurrent system and might not warrant a 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. per @ivandika3 's suggestion, we probably need to update the logic of directory deletions for incomplete MPU so that we can prevent missing parent directories case happening (or make it in a very low probability): #7566 (comment) From high level, I feel if this case happens frequently, it means something is not right (either at code level or design level). How can a key exist but its parent directories already got deleted? Thats why I feel it is good to have this warn log here. Pls let me know your thoughts. |
||
volumeId, bucketId, key, e); | ||
final String multipartKey = | ||
getMultipartKey(volume, bucket, key, uploadId); | ||
final OmMultipartKeyInfo multipartKeyInfo = | ||
getMultipartInfoTable().get(multipartKey); | ||
if (multipartKeyInfo == null) { | ||
LOG.error("Could not find multipartKeyInfo for {}", multipartKey); | ||
throw new OMException(NO_SUCH_MULTIPART_UPLOAD_ERROR); | ||
} | ||
parentId = multipartKeyInfo.getParentID(); | ||
} | ||
|
||
final String fileName = OzoneFSUtils.getFileName(key); | ||
return getMultipartKey(volumeId, bucketId, parentId, | ||
fileName, uploadId); | ||
} | ||
|
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 am going over the code in a bit more detail but why not use the exception handling way to calculate the
parentId
as the default way?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 was my suggestion since there might be some codes that depends on the fact
getParentID
implementation (i.e. parent directory exists).I'm fine to use the updated way as long as there are no regressions found.
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.
Yeah. I just follow @ivandika3 suggestion, which is safer. And I tested if I just use the exception handling way to do it, then
OMKeyCreateRequestWithFSO#getDBMultipartOpenKey
method will throw exception when the MPU is aborted (it breaks testAbortUploadSuccessWithParts test). And this method is used in multiple places. Of course, we can update all these places. I am just not sure if it is safe. Just try to limit the scope of this PR. Pls let me know your thoughts