Skip to content
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-7087. Manage RocksObjects to detect leaks #3656

Merged
merged 9 commits into from
Aug 6, 2022

Conversation

duongkame
Copy link
Contributor

@duongkame duongkame commented Aug 4, 2022

What changes were proposed in this pull request?

We need a mechanism to detect if any RocksObject is not closed before being GCed.
This PR replaces the usage of RocksObject classes in org.rocksdb.* package by managed RocksObject classes whose finalizers are intercepted to assert of their instances are closed before GCed.

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

Sample data

Metric showing memory leaks.

Screen Shot 2022-08-04 at 11 11 08 AM

Sample error message when RocksObject is used in Ozone.

Banned imports detected:

Reason: Use managed RocksObjects under org.apache.hadoop.hdds.utils.db.managed instead.
	in file: org/apache/hadoop/hdds/utils/db/DBStoreBuilder.java
		org.rocksdb.RocksDB                   	(Line: 52, Matched by: org.rocksdb.**)
	in file: org/apache/hadoop/hdds/utils/db/RDBBatchOperation.java
		org.rocksdb.WriteBatch                	(Line: 22, Matched by: org.rocksdb.**)
		org.rocksdb.WriteOptions              	(Line: 23, Matched by: org.rocksdb.**)
	in file: org/apache/hadoop/hdds/utils/db/TableConfig.java
		org.rocksdb.ColumnFamilyOptions       	(Line: 28, Matched by: org.rocksdb.**)
	in file: org/apache/hadoop/hdds/utils/db/RDBSstFileWriter.java
		org.rocksdb.EnvOptions                	(Line: 23, Matched by: org.rocksdb.**)
		org.rocksdb.Options                   	(Line: 24, Matched by: org.rocksdb.**)
		org.rocksdb.SstFileWriter             	(Line: 26, Matched by: org.rocksdb.**)
	in file: org/apache/hadoop/hdds/utils/db/RDBSstFileLoader.java
		org.rocksdb.IngestExternalFileOptions 	(Line: 20, Matched by: org.rocksdb.**)
	in file: org/apache/hadoop/hdds/utils/db/RDBStore.java
		org.rocksdb.DBOptions                 	(Line: 41, Matched by: org.rocksdb.**)
		org.rocksdb.TransactionLogIterator    	(Line: 43, Matched by: org.rocksdb.**)

How was this patch tested?

Standard CI: https://github.com/duongnguyen0/ozone/actions/runs/2805369172

@kerneltime
Copy link
Contributor

I like this approach; @jojochuang mentioned that there might be ways in the pom for all packages other than managed packaged to block rocks DB import.

@jojochuang
Copy link
Contributor

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.

@DuongNguyen0 , thanks a lot for working on this! The idea of having managed objects is great. We should remove the import of org.rockdb.* from the other classes in order to avoid missing the changes. See also the comments inlined.

@duongkame duongkame changed the title HDDS-7087. Tracker to detect RocksObject leaks HDDS-7087. Manage RocksObjects to detect leaks Aug 5, 2022
@duongkame
Copy link
Contributor Author

Thanks @kerneltime, @jojochuang and @szetszwo for the early review and suggestions. I've updated the code to (mostly) ban the usage of org.rocksdb.

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.

Just a minor comment inlined.

@szetszwo
Copy link
Contributor

szetszwo commented Aug 5, 2022

2 successful and 8 skipped checks

Why the checks were skipped?

@duongkame duongkame marked this pull request as ready for review August 5, 2022 20:20
@duongkame
Copy link
Contributor Author

2 successful and 8 skipped checks

Why the checks were skipped?

Because I was a draft PR. Now all the checks are running.

@szetszwo szetszwo merged commit 192eff1 into apache:master Aug 6, 2022
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.

4 participants