Skip to content

stored: fix crash when using jit reservation with no matching device; fix reservation error#2141

Merged
BareosBot merged 3 commits intobareos:masterfrom
sebsura:dev/master/ssura/fix-jit-when-no-dev
Feb 24, 2025
Merged

stored: fix crash when using jit reservation with no matching device; fix reservation error#2141
BareosBot merged 3 commits intobareos:masterfrom
sebsura:dev/master/ssura/fix-jit-when-no-dev

Conversation

@sebsura
Copy link
Contributor

@sebsura sebsura commented Jan 28, 2025

Currently, if jit reservation is used but no device could be found, we break out of the backup loop. Afterwards the sd tries to destroy the dcr if it exists, which includes releasing the acquired device. This is done even if no device was attached to the dcr.

See #2139 and #2140

Also fixes a reservation related issue, see: bareos/internal#92

Thank you for contributing to the Bareos Project!

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Required backport PRs have been created
  • Correct milestone is set
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR

@sebsura sebsura self-assigned this Jan 28, 2025
@sebsura sebsura added the bug This addresses a bug label Jan 28, 2025
@sebsura sebsura added this to the 25.0.0 milestone Jan 28, 2025
@sebsura sebsura changed the title stored: fix crash when using jit reservation with no matching device stored: fix crash when using jit reservation with no matching device; fix reservation error Jan 31, 2025
@sebsura sebsura force-pushed the dev/master/ssura/fix-jit-when-no-dev branch from 6cb6f14 to 7bb4eb9 Compare February 6, 2025 09:13
@florian-at-bareos florian-at-bareos self-requested a review February 7, 2025 07:49
Copy link
Contributor

@florian-at-bareos florian-at-bareos left a comment

Choose a reason for hiding this comment

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

Nice work!

The DoAppendData method is incredibly difficult to understand for me because it has so many logical branches with the ok variable. I'm having a very hard time figuring out which code in the method was actually executed if something didn't work and the okvariable was set to false in the middle of the method.

If you understand this method and think it's not to hard to change up this method maybe you could do that, if not just leave it like it is.
I was thinking of changing

something went wrong...
debug messages...
ok = false;
break;
rest of the function still executes...

to

something went wrong...
debug messages...
call clean up functions...
return false;

@sebsura
Copy link
Contributor Author

sebsura commented Feb 20, 2025

We should definitely rework the logic of that function, but as we want to backport these changes to earlier versions, i would not do so in this pr.

sebsura and others added 3 commits February 24, 2025 10:03
Currently, if jit reservation is used but no device could be found, we
break out of the backup loop.  Afterwards the sd tries to destroy the
dcr if it exists, which includes releasing the acquired device.  This
is done even if no device was attached to the dcr.
All jobs reserve a viable volume to use when they reserve a device.
Sadly some code paths ignored this and instead just used the currently
mounted device for writing regardless of whether it was reserved by
somebody else or not.

This caused weird `Volume X wanted by Device Y is in use by device Z`
error messages as device Y actually reserved volume X, but device Z
simply decided to use it as it was currently mounted, which ultimately
cause an operator message to be sent out.

As volumes that are currently mounted in the device are preferred for
reservation anyways, we simply remove the `IsSuitableVolumeMounted()`
code paths.

If this becomes a problem in the future we can simply try to reserve
the currently mounted volume and use it if it worked.
@BareosBot BareosBot force-pushed the dev/master/ssura/fix-jit-when-no-dev branch from decf9aa to 8fcdb7c Compare February 24, 2025 10:03
@BareosBot BareosBot merged commit 6406583 into bareos:master Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bareos-sd crashes if jit reservation is used but no matching device could be found

3 participants