Skip to content

Make TX abort after assign safer #17438

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

Merged
merged 1 commit into from
Jun 10, 2025
Merged

Make TX abort after assign safer #17438

merged 1 commit into from
Jun 10, 2025

Conversation

amotin
Copy link
Member

@amotin amotin commented Jun 8, 2025

It is not right, but there are few examples when TX is aborted after being assigned in case of error. To handle it better on production systems add extra cleanup steps.

While here, replace couple dmu_tx_abort() calls in simple cases.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

It is not right, but there are few examples when TX is aborted
after being assigned in case of error.  To handle it better on
production systems add extra cleanup steps.

While here, replace couple dmu_tx_abort() in simple cases.

Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
@amotin amotin changed the title Fix some issues of TX abort after assign Make TX abort after assign safer Jun 8, 2025
@amotin
Copy link
Member Author

amotin commented Jun 8, 2025

Thinking about it again, I've decided that it is wrong to call dmu_tx_abort() on already assigned transactions, since if any modifications are already done as part of the TXG, abort won't undo them. I've fixed couple cases where it was done, but there are at least few more I've spotted in zfs_setattr*() that require closer look, and where this PR should help.

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Jun 8, 2025
@robn
Copy link
Member

robn commented Jun 8, 2025

Thinking about it again, I've decided that it is wrong to call dmu_tx_abort() on already assigned transactions, since if any modifications are already done as part of the TXG, abort won't undo them.

Why does the tx_txg == 0 assert at the top of dmu_tx_abort() not trip in that case?

@robn
Copy link
Member

robn commented Jun 8, 2025

Oh heh, you've already gone there. Ok I'll read the diff first 😅

Copy link
Member

@robn robn left a comment

Choose a reason for hiding this comment

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

The important parts appear to be trading the aborts for commits.

I was going to approve this anyway and say that I guess it doesn't hurt, but I don't love hiding bugs. But then I saw you'd already said "on production systems", which explains why the asserts wouldn't trip.

Still, it might be useful to put something in dbgmsg or similar to at least have a record of something, but I suppose it depends on the nature of your production debugging - no point having something there that no one will ever read.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jun 10, 2025
@behlendorf behlendorf merged commit ba227e2 into openzfs:master Jun 10, 2025
22 of 24 checks passed
@amotin amotin deleted the tx_abort branch June 11, 2025 18:18
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Jun 13, 2025
It is not right, but there are few examples when TX is aborted
after being assigned in case of error.  To handle it better on
production systems add extra cleanup steps.

While here, replace couple dmu_tx_abort() in simple cases.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
Closes openzfs#17438
behlendorf pushed a commit that referenced this pull request Jun 17, 2025
It is not right, but there are few examples when TX is aborted
after being assigned in case of error.  To handle it better on
production systems add extra cleanup steps.

While here, replace couple dmu_tx_abort() in simple cases.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
Closes #17438
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Jun 17, 2025
It is not right, but there are few examples when TX is aborted
after being assigned in case of error.  To handle it better on
production systems add extra cleanup steps.

While here, replace couple dmu_tx_abort() in simple cases.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
Closes openzfs#17438
ixhamza pushed a commit to truenas/zfs that referenced this pull request Jun 20, 2025
It is not right, but there are few examples when TX is aborted
after being assigned in case of error.  To handle it better on
production systems add extra cleanup steps.

While here, replace couple dmu_tx_abort() in simple cases.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
Closes openzfs#17438
amotin added a commit to amotin/zfs that referenced this pull request Aug 7, 2025
It is not right, but there are few examples when TX is aborted
after being assigned in case of error.  To handle it better on
production systems add extra cleanup steps.

While here, replace couple dmu_tx_abort() in simple cases.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
Closes openzfs#17438
amotin added a commit to amotin/zfs that referenced this pull request Aug 7, 2025
It is not right, but there are few examples when TX is aborted
after being assigned in case of error.  To handle it better on
production systems add extra cleanup steps.

While here, replace couple dmu_tx_abort() in simple cases.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
Closes openzfs#17438
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants