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

Ensure closing the operation log for batch submission in fast-failed case #5853

Closed
wants to merge 2 commits into from
Closed
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 org.apache.kyuubi.operation

import java.io.IOException
import java.util.concurrent.{Future, ScheduledExecutorService, TimeUnit}
import java.util.concurrent.locks.ReentrantLock

Expand Down Expand Up @@ -247,4 +248,19 @@ abstract class AbstractOperation(session: Session) extends Operation with Loggin
ok.setInfoMessages(hints.asJava)
ok
}

/**
* Close the OperationLog, after running the block
*/
def withClosingOperationLog[T](f: => T): T = {
try {
f
} finally {
try {
getOperationLog.foreach(_.close())
} catch {
case e: IOException => error(e.getMessage, e)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.kyuubi.operation

import java.io.IOException
import java.nio.file.{Files, Paths}
import java.util.Locale
import java.util.concurrent.TimeUnit
Expand Down Expand Up @@ -336,7 +335,7 @@ class BatchJobSubmission(
}
}

override def close(): Unit = withLockRequired {
override def close(): Unit = withLockRequired(withClosingOperationLog {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ( => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was to prevent changing the idents of following lines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a big deal, Git tools like GitHub could ignore space changes during diff view.
() is also fine if you insist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, let me keep it this time. The blame history is more valuable here for me.

if (!isClosedOrCanceled) {
MetricsSystem.tracing(_.decCount(MetricRegistry.name(OPERATION_OPEN, opType)))

Expand Down Expand Up @@ -373,13 +372,7 @@ class BatchJobSubmission(
}
}
}

try {
getOperationLog.foreach(_.close())
} catch {
case e: IOException => error(e.getMessage, e)
}
}
})

override def cancel(): Unit = {
throw new IllegalStateException("Use close instead.")
Expand Down
Loading