Commit e217ae0
[KYUUBI #7389] Fix wrong parameter binding order in JDBCMetadataStore#transformMetadataState
Closes #7389
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.
Closes #7390 from wangzhigang1999/fix/transformMetadataState-param-order.
Closes #7389
e3142a5 [wangzhigang] [KYUUBI] Fix wrong parameter binding order in JDBCMetadataStore#transformMetadataState
Authored-by: wangzhigang <wzg443064@alibaba-inc.com>
Signed-off-by: Cheng Pan <chengpan@apache.org>
(cherry picked from commit bb67bd6)
Signed-off-by: Cheng Pan <chengpan@apache.org>1 parent ae4fba4 commit e217ae0
2 files changed
Lines changed: 27 additions & 1 deletion
File tree
- kyuubi-server/src
- main/scala/org/apache/kyuubi/server/metadata/jdbc
- test/scala/org/apache/kyuubi/server/metadata/jdbc
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
| 240 | + | |
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
247 | 273 | | |
248 | 274 | | |
249 | 275 | | |
| |||
0 commit comments