Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* in the user given path and a pointer to its parent directory element in the
* path. Also, it stores directory node related metdata details.
*/
public class OmDirectoryInfo extends WithParentObjectId {
public class OmDirectoryInfo extends WithParentObjectId implements Cloneable {
private String name; // directory name

private long creationTime;
Expand Down Expand Up @@ -266,4 +266,13 @@ public OmDirectoryInfo copyObject() {

return builder.build();
}

/**
* Return a new copy of the object.
*/
@Override
public Object clone() throws CloneNotSupportedException {
Comment thread
ashishkumar50 marked this conversation as resolved.
OmDirectoryInfo omDirectoryInfo = (OmDirectoryInfo) super.clone();
return omDirectoryInfo.copyObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -789,6 +789,15 @@ public OmKeyInfo copyObject() {
return builder.build();
}

/**
* Return a new copy of the object.
*/
@Override
public Object clone() throws CloneNotSupportedException {
OmKeyInfo omKeyInfo = (OmKeyInfo) super.clone();
return omKeyInfo.copyObject();
Comment thread
ashishkumar50 marked this conversation as resolved.
Outdated
}

/**
* Method to clear the fileEncryptionInfo.
* This method is called when a KeyDelete operation is performed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -444,6 +445,11 @@ private void getCacheValues() {
continue;
}

// Copy cache value to local copy and work on it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we depend on the bucket locking for concurrency correctness here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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)) {
Expand Down