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

DRILL-8483: SpilledRecordBatch memory leak when the program threw an … #2888

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Changes from all 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 @@ -532,6 +532,8 @@ public IterOutcome innerNext() {
return rightUpstream;
}

boolean isExistException = false;

try {
/*
* If we are here for the first time, execute the build phase of the hash
Expand Down Expand Up @@ -687,6 +689,24 @@ public IterOutcome innerNext() {
return IterOutcome.NONE;
} catch (SchemaChangeException e) {
throw UserException.schemaChangeError(e).build(logger);
} catch (OutOfMemoryException oom) {
isExistException = true;
throw UserException.memoryError(oom).build(logger);
} catch (Exception e) {
//Internal catch OutOfMemoryException, resulting in throwing other exceptions or others
isExistException = true;
throw UserException.executionError(e).build(logger);
} finally {
boolean isReleaseBuildBatch = buildBatch != null && buildBatch instanceof SpilledRecordBatch;
boolean isReleaseProbeBatch = probeBatch != null && probeBatch instanceof SpilledRecordBatch;
//release buildBatch spill memory
if (isExistException && isReleaseBuildBatch) {
buildBatch.cancel();
}
//release probeBatch spill memory
if (isExistException && isReleaseProbeBatch) {
probeBatch.cancel();
}
}
}

Expand Down
Loading