Skip to content

Conversation

@adoroszlai
Copy link
Contributor

What changes were proposed in this pull request?

TypedTable.putWithBatch defers closing CodecBuffer until the batch is committed. If value conversion (or putWithBatch itself) throws, the buffers are not added to the batch, so they need to be released eagerly.

Example value conversion error:

NullPointerException
	at org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos$S3Secret$Builder.setAwsSecret(OzoneManagerProtocolProtos.java)
	at org.apache.hadoop.ozone.om.helpers.S3SecretValue.getProtobuf(S3SecretValue.java:100)
	at org.apache.hadoop.hdds.utils.db.DelegatedCodec.toCodecBuffer(DelegatedCodec.java:85)
	at org.apache.hadoop.hdds.utils.db.Codec.toDirectCodecBuffer(Codec.java:73)
	at org.apache.hadoop.hdds.utils.db.TypedTable.putWithBatch(TypedTable.java:171)
	at org.apache.hadoop.ozone.om.OmMetadataManagerImpl$1.addWithBatch(OmMetadataManagerImpl.java:1949)
	at org.apache.hadoop.ozone.om.response.s3.security.OMSetSecretResponse.addToDBBatch(OMSetSecretResponse.java:80)

Key leak:

2024-01-24 09:49:09,454 [Finalizer] WARN  db.CodecBuffer (CodecBuffer.java:detectLeaks(278)) - LEAK 1: [0<=18<=54: 74 65 73 74 55 73 65 72 31 61 ...], refCnt=1, capacity=54 allocation:
org.apache.hadoop.hdds.utils.db.CodecBuffer.<init>(CodecBuffer.java:53)
...
org.apache.hadoop.hdds.utils.db.StringCodecBase.toCodecBuffer(StringCodecBase.java:174)
org.apache.hadoop.hdds.utils.db.StringCodec.toCodecBuffer(StringCodec.java:28)
org.apache.hadoop.hdds.utils.db.StringCodecBase.toCodecBuffer(StringCodecBase.java:42)
org.apache.hadoop.hdds.utils.db.Codec.toDirectCodecBuffer(Codec.java:73)
org.apache.hadoop.hdds.utils.db.TypedTable.putWithBatch(TypedTable.java:170)
org.apache.hadoop.ozone.om.OmMetadataManagerImpl$1.addWithBatch(OmMetadataManagerImpl.java:1949)
org.apache.hadoop.ozone.om.response.s3.security.OMSetSecretResponse.addToDBBatch(OMSetSecretResponse.java:80)

The root cause of this specific conversion problem was fixed in HDDS-10200. This PR is only for the CodecBuffer leak.

https://issues.apache.org/jira/browse/HDDS-10204

How was this patch tested?

TestMultiTenantVolume passed 10x100 (without the fix from HDDS-10200):
https://github.com/adoroszlai/ozone/actions/runs/7658045401

CI:
https://github.com/adoroszlai/ozone/actions/runs/7657732895

@adoroszlai adoroszlai self-assigned this Jan 25, 2024
@adoroszlai adoroszlai requested a review from szetszwo January 25, 2024 20:39
Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the change looks good.

@adoroszlai adoroszlai merged commit dd54a7a into apache:master Jan 26, 2024
@adoroszlai adoroszlai deleted the HDDS-10204 branch January 26, 2024 12:46
@adoroszlai
Copy link
Contributor Author

Thanks @szetszwo for the review.

adoroszlai added a commit to adoroszlai/ozone that referenced this pull request Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants