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

RepoSack: New API to reload system repo #1702

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Sep 17, 2024

Introduce a new API to clear all solvables from the system repo and
reload fresh data from the RPM database.

Re-creating the Base object can be resource-intensive, and there is a
use case in dnfdaemon where the current session (which wraps around the
Base instance) needs to be reused even after executing an RPM
transaction - whether for queries or running another transaction.

For: #1653

Introduce a new API to clear all solvables from the system repo and
reload fresh data from the RPM database.

Re-creating the Base object can be resource-intensive, and there is a
use case in dnfdaemon where the current session (which wraps around the
Base instance) needs to be reused even after executing an RPM
transaction - whether for queries or running another transaction.
@m-blaha
Copy link
Member Author

m-blaha commented Sep 17, 2024

@jrohel @kontura do you see any issues with this?
It can also be used by dnfdaemon to handle messages from rpm-plugin-dbus-announce rpm plugin.

@kontura
Copy link
Contributor

kontura commented Sep 17, 2024

@jrohel @kontura do you see any issues with this? It can also be used by dnfdaemon to handle messages from rpm-plugin-dbus-announce rpm plugin.

It does make me feel uneasy. It basically invalidates the pool right? Libsolv ids might have changed. So any Package object, Goal or PackageQuery in progress should be invalidated as well.

If I understand correctly for example existing Package could simply transform into a different one after the reload is used. I could see this causing quite hard to find bugs.

@m-blaha
Copy link
Member Author

m-blaha commented Sep 17, 2024

Yes, that's right. Any place that keeps an id of an installed package is invalid after this call.

@jan-kolarik jan-kolarik self-requested a review September 17, 2024 14:45
@@ -792,4 +792,9 @@ void SolvRepo::create_environment_solvable(
repodata_internalize(data);
}

void SolvRepo::empty() {
// TODO(mblaha): is resuseid=true safe enough?
Copy link
Contributor

@jrohel jrohel Sep 18, 2024

Choose a reason for hiding this comment

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

Code from libsolv:

  if (reuseids && repo->end == pool->nsolvables)
    {
      /* it's ok to reuse the ids. As this is the last repo, we can
         just shrink the solvable array */

It looks like reuseids works only when the repo is last. DNF places the system repo first. Behind it are available repos. The system repo is last only if it is the only one (we don't have available repos loaded).

Note:
OK. Maybe after the first reload the system repository will be the last one.

@jrohel
Copy link
Contributor

jrohel commented Sep 18, 2024

You are introducing a new API method void reload_system_repo(). DNF saves the system repository to the pool first, followed by the others. Thus, installed solvables have a lower id than available. What do you expect to happen after calling the libsolv function repo_empty(repo, true) when there are other repos after the repo? Will space and solvables ids be able to be reused? I'm not sure about that. And what if the new system repo is larger (a package has been installed)? Surely the repo won't fit in the original space. Will the entire repo be saved to the end of the pool? Or will it be scattered in the pool - part in the original location and part at the end of the pool?

When we sort packages and they have the same nevra, the solvable id comes into play. Thus, moving the system repo to the end affects the sorting of the packages. The question is how much does it matter.

In general we are getting into the untested area of using libsolv.

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.

3 participants