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

Update transaction stage earlier in commit_and_continue_as_read #5615

Merged
merged 3 commits into from
Jun 30, 2022

Conversation

jedelbo
Copy link
Contributor

@jedelbo jedelbo commented Jun 24, 2022

This will ensure the the stage is correct even if subsequent
procedure calls will trigger an exception.

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed.

This will ensure the the stage is correct even if subsequent
procedure calls will trigger an exception.
@cla-bot cla-bot bot added the cla: yes label Jun 24, 2022
@jedelbo jedelbo requested a review from ironage June 24, 2022 12:36
Copy link
Contributor

@ironage ironage left a comment

Choose a reason for hiding this comment

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

Hmm I don't quite get what you have in mind here. But I also don't see how it can hurt either. I'll leave a tentative approval, but it might be best to get another set of eyes on this one.

@tgoyne
Copy link
Member

tgoyne commented Jun 24, 2022

AFAICT, everything between db->grab_read_lock(new_read_lock, version_id); and remap_and_update_refs(m_read_lock.m_top_ref, m_read_lock.m_file_size, false); should not be able to fail. Many of the operations in between aren't noexcept, but the only exceptions they throw are things like failing to lock a mutex. There's maybe an argument that they should be noexcept as we aren't prepared to handle those failing and would prefer to terminate.

That means that the main effect of this is that if remap_and_update_refs() fails (which it quite plausible can if the file has grown), the Transaction is left in the Read stage rather than the Write stage. This is still probably not really correct as continuing to use the Transaction past this point is very unlikely to work, but it is better than leaving it in write mode. Crashes in rollback would certainly make sense if the transaction being rolled back had actually been committed but then the transaction was left in the write stage because remap_and_update_refs() threw.

@finnschiermer
Copy link
Contributor

I changed this so that an exception in commit_and_continue_as_read will cause the Transaction object to reject both reading and writing afterwards.

@finnschiermer finnschiermer requested a review from tgoyne June 29, 2022 13:00
@finnschiermer finnschiermer merged commit 9749059 into master Jun 30, 2022
@finnschiermer finnschiermer deleted the je/fix-rollback branch June 30, 2022 07:38
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants