wangzhigang1999 opened a new pull request, #7390:
URL: https://github.com/apache/kyuubi/pull/7390
The SQL placeholders expect (targetState, identifier, fromState) but the
code passed (fromState, identifier, targetState), causing the UPDATE to set
state back to fromState and match on targetState instead. This made
cancelUnscheduledBatch silently fail.
### Why are the changes needed?
In `JDBCMetadataStore#transformMetadataState`, the SQL is:
```sql
UPDATE metadata SET state = ? WHERE identifier = ? AND state = ?
```
The placeholders expect `(targetState, identifier, fromState)`, but the code
passes `(fromState, identifier, targetState)`:
```scala
withUpdateCount(connection, query, fromState, identifier, targetState)
```
This causes `cancelUnscheduledBatch("INITIALIZED" -> "CANCELED")` to execute:
```sql
UPDATE metadata SET state = 'INITIALIZED' WHERE identifier = ? AND state =
'CANCELED'
```
Which matches no rows and silently returns `false`. The bug has existed
since v1.8.0 ([KYUUBI #4790]).
### How was this patch tested?
Added a unit test `transformMetadataState should transition state correctly`
in `JDBCMetadataStoreSuite` that:
1. Inserts a metadata record with `state = "INITIALIZED"`
2. Calls `transformMetadataState(id, "INITIALIZED", "CANCELED")`
3. Asserts the method returns `true`
4. Asserts the persisted state is `"CANCELED"`
### Was this patch authored or co-authored using generative AI tooling?
No.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]