Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should perform lazy recovery in implicit pre-read #1476

Merged
merged 2 commits into from
Jan 31, 2024

Conversation

brfrn169
Copy link
Collaborator

Description

Currently, when uncommitted records are read while executing implicit pre-read, lazy recovery is not performed, which is unexpected behavior. This PR addresses issue.

Related issues and/or PRs

Changes made

  • Make changes to perform lazy recovery when uncommitted records are read while executing implicit pre-read.

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

Fixed a bug where lazy recovery is not performed when uncommitted records are read while executing implicit pre-read.

Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

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

Good catch! LGTM, thank you!

@@ -135,6 +134,9 @@ public void commit() throws CommitException, UnknownTransactionStatusException {
try {
crud.readIfImplicitPreReadEnabled();
} catch (CrudConflictException e) {
if (e instanceof UncommittedRecordException) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[minor] Or, explicitly catching UncommittedRecordException is also an option?

    // Execute implicit pre-read
    try {
      crud.readIfImplicitPreReadEnabled();
    } catch (UncommittedRecordException e) {
      lazyRecovery(e);
      throw new CommitConflictException("Read uncommitted record while implicit pre-read", e, getId());
    } catch (CrudConflictException e) {
      throw new CommitConflictException("Conflict occurred while implicit pre-read", e, getId());
    } catch (CrudException e) {
      throw new CommitException("Failed to execute implicit pre-read", e, getId());
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that's an option. I didn't do that because I didn't think we needed to change the error message base on the cause, as we pass the cause exception to CommitConflictException.

throw new CommitConflictException("Conflict occurred while implicit pre-read", e /* the cause exception */, getId());

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good

@@ -137,6 +136,9 @@ public void prepare() throws PreparationException {
try {
crud.readIfImplicitPreReadEnabled();
} catch (CrudConflictException e) {
if (e instanceof UncommittedRecordException) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[minor] Same as above

Copy link
Contributor

@jnmt jnmt left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for handling it quickly : )

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

Overall, looking good. Left a minor comment. PTAL!

}

@SuppressFBWarnings("EI_EXPOSE_REP2")
public UncommittedRecordException(
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems not used. Do you want to keep it for future use?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I left this here because it was originally here. But yes, we don't need to leave it. I'll remove it. Thanks.

Copy link
Collaborator Author

@brfrn169 brfrn169 Jan 31, 2024

Choose a reason for hiding this comment

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

Fixed in 5c4d6a7. Thanks.

@brfrn169 brfrn169 requested a review from feeblefakie January 31, 2024 04:31
Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@feeblefakie feeblefakie merged commit 659a551 into master Jan 31, 2024
23 checks passed
@feeblefakie feeblefakie deleted the should-perform-lazy-recovery-in-implicit-pre-read branch January 31, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants