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

Fix memory leak issue in ReorganizingLongHash #11953

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix issue when calling Delete PIT endpoint and no PITs exist ([#11711](https://github.com/opensearch-project/OpenSearch/pull/11711))
- Fix tracing context propagation for local transport instrumentation ([#11490](https://github.com/opensearch-project/OpenSearch/pull/11490))
- Fix parsing of single line comments in `lang-painless` ([#11815](https://github.com/opensearch-project/OpenSearch/issues/11815))
- Fix memory leak issue in ReorganizingLongHash ([#11953](https://github.com/opensearch-project/OpenSearch/issues/11953))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,17 @@
mask = capacity - 1;
grow = (long) (capacity * loadFactor);
size = 0;

table = bigArrays.newLongArray(capacity, false);
table.fill(0, capacity, -1); // -1 represents an empty slot
keys = bigArrays.newLongArray(initialCapacity, false);
try {
table = bigArrays.newLongArray(capacity, false);
table.fill(0, capacity, -1); // -1 represents an empty slot
keys = bigArrays.newLongArray(initialCapacity, false);
} finally {
if (table == null || keys == null) {
// it's important to close the arrays initialized above to prevent memory leak
// refer: https://github.com/opensearch-project/OpenSearch/issues/10154
Releasables.closeWhileHandlingException(table, keys);

Check warning on line 129 in server/src/main/java/org/opensearch/common/util/ReorganizingLongHash.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/common/util/ReorganizingLongHash.java#L129

Added line #L129 was not covered by tests
}
}
}

/**
Expand Down