[Bug] KyuubiStatement execute/close in two thread might cause the operation doesn't be cancel.
- Dominant language
- Scala
- Stars
- 2.4k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
### Search before asking
- [x] I have searched in the [issues](https://github.com/apache/kyuubi/issues?q=is%3Aissue) and found no similar issues.
### Describe the bug
When we execute a SQL statement using KyuubiStatement, it submits an Operation to the Kyuubi server and then obtains an OperationHandle. Any follow-up actions related to the statement will rely on this OperationHandle.
It seems that in some race conditions, if the execute call has been made but the OperationHandle has not yet been returned, closing the Statement at that point may result in the Operation not being properly closed.
### Affects Version(s)
master
### Kyuubi Server Log Output
```logtalk
```
### Kyuubi Engine Log Output
```logtalk
```
### Kyuubi Server Configurations
```yaml
```
### Kyuubi Engine Configurations
```yaml
```
### Additional context
_No response_
### Are you willing to submit PR?
- [x] Yes. I would be willing to submit a PR with guidance from the Kyuubi community to fix.
- [x] No. I cannot submit a PR at this time.
Contributor guide
Research direction
Start at KyuubiStatement's execute and close paths, focusing on when the OperationHandle is obtained and used. Verify the race between execute and close is handled so the submitted Operation is properly closed or cancelled even when the handle has not yet been returned, with coverage for that concurrent case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100