[Bug] Queued InsertMetadata retry can block metadata retry queue forever on duplicate-key error
- 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
MetadataManager.insertMetadata intentionally fails fast when it hits a duplicate-key error (unrecoverableDBErr), rethrowing rather than queuing a retry. However, when an InsertMetadata request that is already in the async retry queue is replayed by startMetadataRequestsAsyncRetryTrigger, it calls insertMetadata(metadata, asyncRetryOnError = false). If that replay hits a duplicate-key error (e.g. because the original insert actually succeeded and only the acknowledgment was lost), the exception is not caught by any case in insertMetadata and propagates out of the retry loop's while block before ref.metadataRequests.remove(request) runs. The request is left at the head of the queue and is retried indefinitely, blocking all later queued requests for that session — the same amplification pattern reported in #7708 for updates, but for inserts.
Additional context:
Raised during review of #7709 by @pan3793: "the queued InsertMetadata retry path has a similar amplification pattern... Worth a follow-up issue."
Affects Version(s): master
Are you willing to submit a PR? Yes.
### 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.
- [ ] No. I cannot submit a PR at this time.
Contributor guide
Research direction
Start with MetadataManager.insertMetadata and startMetadataRequestsAsyncRetryTrigger, following how a queued request is replayed and removed through ref.metadataRequests.remove(request). Compare the insert path with the update retry behavior described in #7708 and verify that a duplicate-key error during replay cannot leave the request at the queue head blocking later requests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100