Skip to content

#551: Keep fact replacement atomic#554

Open
GHX5T-SOL wants to merge 1 commit into
zerocracy:masterfrom
GHX5T-SOL:551
Open

#551: Keep fact replacement atomic#554
GHX5T-SOL wants to merge 1 commit into
zerocracy:masterfrom
GHX5T-SOL:551

Conversation

@GHX5T-SOL

Copy link
Copy Markdown
Contributor

/claim #551

Closes #551.

Summary

  • Move the delete step for Fbe.overwrite, Fbe.delete, and Fbe.delete_one inside the same fb.txn block as the replacement insert.
  • Add regression tests proving the original fact remains when the replacement insert raises.

Validation

  • bundle check
  • bundle exec ruby -Itest test/fbe/test_overwrite.rb -- --no-cov
  • bundle exec ruby -Itest test/fbe/test_delete.rb -- --no-cov
  • bundle exec ruby -Itest test/fbe/test_delete_one.rb -- --no-cov
  • git diff --check
  • bundle exec rubocop lib/fbe/overwrite.rb lib/fbe/delete.rb lib/fbe/delete_one.rb test/fbe/test_overwrite.rb test/fbe/test_delete.rb test/fbe/test_delete_one.rb
  • bundle exec rake test
  • bundle exec rubocop
  • bundle exec rake

No secrets or live-user data used; validation was local and within the repo scope.

@bibonix bibonix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The delete-then-insert sequence in Fbe.delete, Fbe.delete_one, and both branches of Fbe.overwrite now sits inside the fb.txn block, so a raised insert rolls the delete back instead of leaving the factbase with the old fact gone. The three new regression tests inject a raising Factbase::Pre to force the insert to fail and then assert that the original fact and every untouched property survive the call. CI is green on actionlint, copyrights, markdown-lint, pdd, reuse, typos, xcop, yamllint, and the rake jobs on ubuntu-24.04 and macos-15. No inline comments.

@yegor256

Copy link
Copy Markdown
Member

@GHX5T-SOL merge conflict here

@yegor256

Copy link
Copy Markdown
Member

Please fix the merge conflicts so this pull request can be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fbe.overwrite, Fbe.delete, Fbe.delete_one delete the old fact outside the txn, losing it if the insert raises

3 participants