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

[CORE] Fix validation runtime handle leak #3730

Merged
merged 1 commit into from
Nov 16, 2023
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.
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 @@ -17,6 +17,7 @@
package io.glutenproject.backendsapi.velox

import io.glutenproject.backendsapi.ValidatorApi
import io.glutenproject.exec.Runtimes
import io.glutenproject.substrait.plan.PlanNode
import io.glutenproject.validate.NativePlanValidationInfo
import io.glutenproject.vectorized.NativePlanEvaluator
Expand All @@ -31,8 +32,13 @@ class ValidatorApiImpl extends ValidatorApi {
doExprValidate(Map(), substraitExprName, expr)

override def doNativeValidateWithFailureReason(plan: PlanNode): NativePlanValidationInfo = {
val validator = NativePlanEvaluator.createForValidation()
validator.doNativeValidateWithFailureReason(plan.toProtobuf.toByteArray)
val tmpRuntime = Runtimes.tmpInstance()
try {
val validator = NativePlanEvaluator.createForValidation(tmpRuntime)
validator.doNativeValidateWithFailureReason(plan.toProtobuf.toByteArray)
} finally {
tmpRuntime.release()
}
}

override def doSparkPlanValidate(plan: SparkPlan): Boolean = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public static NativePlanEvaluator create() {
return new NativePlanEvaluator(Runtimes.contextInstance());
}

public static NativePlanEvaluator createForValidation() {
public static NativePlanEvaluator createForValidation(Runtime runtime) {
// Driver side doesn't have context instance of Runtime
return new NativePlanEvaluator(Runtimes.tmpInstance());
return new NativePlanEvaluator(runtime);
}

public NativePlanValidationInfo doNativeValidateWithFailureReason(byte[] subPlan) {
Expand Down
Loading