ruanwenjun commented on code in PR #7721:
URL: https://github.com/apache/kyuubi/pull/7721#discussion_r4058875094
##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/MetadataManager.scala:
##########
@@ -344,11 +356,30 @@ class MetadataManager extends
AbstractService("MetadataManager") {
info(s"Retrying metadata requests for $id")
var request = ref.metadataRequests.peek()
while (request != null) {
- request match {
- case insert: InsertMetadata =>
- insertMetadata(insert.metadata, asyncRetryOnError =
false)
- case update: UpdateMetadata =>
- updateMetadata(update.metadata, asyncRetryOnError =
false)
+ try {
+ request match {
+ case insert: InsertMetadata =>
+ insertMetadata(insert.metadata, asyncRetryOnError
= false)
+ case update: UpdateMetadata =>
+ updateMetadata(update.metadata, asyncRetryOnError
= false)
+ }
+ } catch {
+ // A duplicate-key error while retrying a queued
insert means a row
+ // with this identifier already exists, e.g. the
earlier attempt
+ // actually succeeded but its acknowledgement was
lost. Verify the
+ // postcondition instead of leaving this request stuck
at the head
+ // of the queue forever, which would also block all
later requests
+ // for this session (KYUUBI #7720).
+ case rethrow: Throwable
+ if request.isInstanceOf[InsertMetadata] &&
+ unrecoverableDBErr(rethrow) &&
+ verifyInsertPostcondition(request.metadata) =>
+ warn(
+ s"Insert for ${request.metadata.identifier}
returned a " +
+ "duplicate-key error on retry but a matching row
already " +
+ "exists; treating as idempotent success and
removing it " +
+ "from the retry queue.",
+ rethrow)
Review Comment:
Could you handle the exception that occurs when trying to update a
nonexistent record here? That way, we can resolve this type of issue within a
single RP. Then I can close #7709
--
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]