Skip to content

Commit

Permalink
Fix validation runtime hanle leak
Browse files Browse the repository at this point in the history
  • Loading branch information
ulysses-you committed Nov 15, 2023
1 parent bc25d07 commit d4c0d53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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

0 comments on commit d4c0d53

Please sign in to comment.