Skip to content

Ensure HMS shared lock is dropped on query failure#10401

Merged
losipiuk merged 2 commits intotrinodb:masterfrom
losipiuk:lo/fix-hive-lost-lock
Jan 18, 2022
Merged

Ensure HMS shared lock is dropped on query failure#10401
losipiuk merged 2 commits intotrinodb:masterfrom
losipiuk:lo/fix-hive-lost-lock

Conversation

@losipiuk
Copy link
Copy Markdown
Member

No description provided.

@cla-bot cla-bot bot added the cla-signed label Dec 23, 2021
@losipiuk losipiuk requested review from djsagain, electrum and findepi and removed request for electrum December 23, 2021 15:16
Copy link
Copy Markdown
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it testable?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems weird to commit transaction if our commit failed (ie when failure != null)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - I agree - though I am not sure if just changing this code to explicit abortTransaction here would be good too. Is there a chance that our commit did already partial work and it is too later for abort in HMS?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fortunately there is no "legacy behavior" -- we didn't commit/abort tx when our commit failed, so we can do whatever we want

i didn't test it, but abort seems way more appropriate... if we choose to call commit for some reason, we need to document why we think it's a good idea.

Comment on lines 1407 to 1389
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also extract the cleanup to a method, this would allow you to prove you're not swallowing Throwables

try {
 commit;
}
catch (Throwable commitFailure) {
  try {
    cleanup;
  } catch (Throwable cleanupFailure) {
    /* if ...*/ commitFailure.addSuppressed(cleanupFailure);
  }
  throw commitFailure; // rethrowing Throwable directly helps the compiler.... and future maintainers
}

// (commit succeeded)
cleanup;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reworked - looks nicer - thanks

@losipiuk
Copy link
Copy Markdown
Member Author

Is it testable?

I can think of some UT like testing - but it is not a big benefit I think. I do not see a reasonable way to test it via integration/product test.

@losipiuk losipiuk force-pushed the lo/fix-hive-lost-lock branch 2 times, most recently from 6bded68 to 5be3ab0 Compare January 14, 2022 11:31
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was unused, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

@losipiuk losipiuk force-pushed the lo/fix-hive-lost-lock branch from 5be3ab0 to ff0e989 Compare January 14, 2022 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants