Skip to content

Try Catch logic for openBatchSession - #7426

Open
oh0873 wants to merge 7 commits into
apache:masterfrom
oh0873:hoonoh/openBatchSessionExceptionCatchv2
Open

Try Catch logic for openBatchSession#7426
oh0873 wants to merge 7 commits into
apache:masterfrom
oh0873:hoonoh/openBatchSessionExceptionCatchv2

Conversation

@oh0873

@oh0873 oh0873 commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Why are the changes needed?

In Kyuubi Batch v2 version, Batch Service creates batchExecutor to submit a batch job. However, when openBatchSession fails, the executor dies and never recovers.

This results in a jobs stuck at PENDING state and no executor to submit any jobs at INITIALIZED state.

This PR added error handling logic to handle openBatchSession.

This also fixes withUpdateCount call changes fromState to targetState.

How was this patch tested?

Tested in our environment, openBatchSession exceptions like connections per user or DB connection error no longer leaves jobs stuck at PENDING state. Instead all those jobs are labeled as ERROR.

Was this patch authored or co-authored using generative AI tooling?

Test case and bug finding were assisted with Cursor agent.

@oh0873

oh0873 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@pan3793 Can I get a review on this PR?

}

override def start(): Unit = {
val UNINITIALIZED_BATCH_ID = "UNINITIALIZED_BATCH_ID"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: create an object KyuubiBatchService, and move const to there

Comment on lines +124 to +132
try {
metadataManager.failScheduledBatch(batchId)
} catch {
case ex: Exception =>
error(
s"Unable to modify metadata for $batchId to ERROR; " +
"an administrator may need to reset the batch state manually.",
ex)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

consider extracting this part to a method as it repeats twice

@pan3793

pan3793 commented Jul 14, 2026

Copy link
Copy Markdown
Member

thanks, fix makes sense, just two style comments

@oh0873
oh0873 force-pushed the hoonoh/openBatchSessionExceptionCatchv2 branch from 508fc38 to 35a4a76 Compare September 8, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants