-
Notifications
You must be signed in to change notification settings - Fork 593
HDDS-8292. Inconsistent key name handling for FSO bucket files. #4531
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 all commits
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 |
|---|---|---|
|
|
@@ -48,7 +48,7 @@ | |
| * This is returned from OM to client, and client use class to talk to | ||
| * datanode. Also, this is the metadata written to om.db on server side. | ||
| */ | ||
| public final class OmKeyInfo extends WithParentObjectId { | ||
| public final class OmKeyInfo extends WithParentObjectId implements Cloneable { | ||
| private static final Logger LOG = LoggerFactory.getLogger(OmKeyInfo.class); | ||
| private final String volumeName; | ||
| private final String bucketName; | ||
|
|
@@ -789,6 +789,36 @@ public OmKeyInfo copyObject() { | |
| return builder.build(); | ||
| } | ||
|
|
||
| /** | ||
| * Return a new copy of the object. | ||
| */ | ||
| @Override | ||
| public Object clone() throws CloneNotSupportedException { | ||
| OmKeyInfo omKeyInfo = (OmKeyInfo) super.clone(); | ||
|
|
||
| omKeyInfo.metadata = new HashMap<>(); | ||
| omKeyInfo.keyLocationVersions = new ArrayList<>(); | ||
| omKeyInfo.acls = new ArrayList<>(); | ||
|
|
||
| keyLocationVersions.stream().filter(keyLocationVersion -> | ||
| keyLocationVersion != null).forEach(keyLocationVersion -> | ||
| omKeyInfo.keyLocationVersions.add( | ||
| new OmKeyLocationInfoGroup(keyLocationVersion.getVersion(), | ||
| keyLocationVersion.getLocationList(), | ||
|
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. Should we deep copy the contents of this list as well?
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 had the same question but looks like it is a deep copy
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. Hi @errose28 thanks for the review. OmKeyLocationInfo is also deep copied as pointed out by Ritesh.
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.
There is a risk that fixing this issue with deep copy causes a performance regression in list keys. Since this is a pretty critical bug I think the first version of the fix should do a shallow copy. A later implementation can decide to either leave the fix this way, use deep copy (with perf benchmarks to support no regressions), or fix the method to not require modifying the key info.
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. @errose28 agreed that we need something more efficient. The entirety of
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.
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. The follow up jira is fine with me, as long as we are aware that list keys is probably going to be slower than before until it is resolved. |
||
| keyLocationVersion.isMultipartKey()))); | ||
|
|
||
| acls.stream().filter(acl -> acl != null).forEach(acl -> | ||
| omKeyInfo.acls.add(new OzoneAcl(acl.getType(), | ||
| acl.getName(), (BitSet) acl.getAclBitSet().clone(), | ||
| acl.getAclScope()))); | ||
|
|
||
| if (metadata != null) { | ||
| metadata.forEach((k, v) -> omKeyInfo.metadata.put(k, v)); | ||
| } | ||
|
|
||
| return omKeyInfo; | ||
| } | ||
|
|
||
| /** | ||
| * Method to clear the fileEncryptionInfo. | ||
| * This method is called when a KeyDelete operation is performed. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
|
|
||
| import com.google.common.base.Preconditions; | ||
| import com.google.common.base.Strings; | ||
| import org.apache.commons.lang3.ObjectUtils; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.hadoop.hdds.utils.db.Table; | ||
| import org.apache.hadoop.hdds.utils.db.TableIterator; | ||
|
|
@@ -444,6 +445,11 @@ private void getCacheValues() { | |
| continue; | ||
| } | ||
|
|
||
| // Copy cache value to local copy and work on it | ||
|
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. This is a good find @ashishkumar50. Could there be similar patterns with other objects leading to corruption besides OmDirectoryInfo?
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. Hi @swagle , Thanks for the review. OmDirectoryInfo and OmKeyInfo are only objects used for accessing cache in OzoneListStatusHelper. |
||
| Value copyOmInfo = ObjectUtils.clone(cacheOmInfo); | ||
|
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. Do we depend on the bucket locking for concurrency correctness here?
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. Hi @kerneltime , Thanks for the review. In MinHeapIterator already read bucket locking exists. |
||
| if (copyOmInfo != null) { | ||
| cacheOmInfo = copyOmInfo; | ||
| } | ||
| if (StringUtils.isBlank(startKey)) { | ||
| // startKey is null or empty, then the seekKeyInDB="1024/" | ||
| if (cacheKey.startsWith(prefixKey)) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.