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
context, sack: Support all rpmdb path variants #915
context, sack: Support all rpmdb path variants #915
Conversation
@rh-atomic-bot try |
We rely on identifying whether the rpmdb path has changed to determine whether we need to re-cache data from there. Now that RPM has multiple rpmdb options and there are two common paths in use by RPM-based systems, we need to handle all of these. Closes: #915 Approved by: <try>
The patch cannot destroy dnf because we do not use rpmdb cache. But from a general perspective the patch is wrong. It is workarrond that temporary resolves the issue but in long term perspective it will cause the problem. Specially in case of downgrade of rpm it will be a disaster. |
@j-mracek The correct "long-term" fix would be to rework this to get the rpmdb information from rpm itself, or use new RPM APIs (if any exist) for dealing with this. I figure that would probably make sense for dnf5, since we can raise the floor to RPM 4.16 API there. |
It will be enough to ask rpm to return path to rpmdb. @pmatilai Is in RPM something like that? |
No, rpm explicitly does not expose internal db paths because they are not anybodys business. Rpm >= 4.15 has rpmdbCookie() which can be used to retrieve a "has rpmdb changed" hash, much like libsolv/libdnf is now calculating on its own. Rpm >= 4.16 will additionally have rpmdbStat() and rpmdbFStat() for performing a stat() -like operation on the rpmdb. |
Unless this can be backported to 4.14.x and made available in both RHEL 8 and SLE 15 rpm (cc: @mlschroe), I don't think we can rely on that for dnf 4.x. |
Oh and actually looking at the patch: you certainly shouldn't be hard-coding /var/lib/rpm and the like for the base directory anywhere. Rpm itself will simply look at %{_dbpath} macro, I see no reason why dnf should do anything else. |
Talking about backports seems premature when we don't have any implementation taking advantage of that stuff. Well, libsolv internally uses rpmdbFStat() if available already. |
@pmatilai I'm certainly not going to change to use an API that I can't use, as I have to care about openSUSE Leap 15.x with RPM 4.14.x. |
Methods such as conditional compilation exist to deal with s*** that is only available in newer versions. It's not like this is in any way a special, previously unheard of situation. Rpm 4.14.x doesn't really have this whole issue as there's exactly one supported backend. |
@pmatilai In RHEL yes. But not in SUSE distributions, where NDB is also supported since SLE 15 SP2 (openSUSE Leap 15.2). And in openSUSE Tumbleweed (which will become SLE 16/openSUSE Leap 16), NDB will be the only rpmdb backend in a matter of days... |
I'm only talking about upstream rpm here. Distro backports are issues of said distros. |
@pmatilai You're working on rpm 4.14.3 release. If that API is present there, then I can use it. Otherwise, I don't know how I could, other than doing function check and fallback, which would still lead to the code looking like this anyway. |
💔 Test failed - status-papr |
@@ -226,7 +226,14 @@ dnf_sack_new(void) | |||
static int | |||
current_rpmdb_checksum(Pool *pool, unsigned char csout[CHKSUM_BYTES]) | |||
{ | |||
const char *rpmdb_prefix_paths[] = { "/var/lib/rpm/Packages", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can drop support of DNF_SACK_LOAD_FLAG_BUILD_CACHE for system repo.
There are two good reasons for that:
- The calculation of checksumm doesn't work correctly in some cases (the reason why DNF stop to support it)
- There is no performance benefit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, discovery and dropping of non-working baggage is one of the better possible outcomes 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't forget we'll need similar functionality in the new dnf-daemon we're going to deliver as part of dnf5 work.
Basically something to help the daemon recognize that rpmdb has changed and it should reload data.
/* setup a file monitor on the rpmdb, if we're operating on the native / */ | ||
if (g_strcmp0(priv->install_root, "/") == 0) { | ||
rpmdb_path = g_build_filename(priv->install_root, "var/lib/rpm/Packages", NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file path is used to set signal when change of RPMDB take place.
g_signal_connect(priv->monitor_rpmdb, "changed",
G_CALLBACK(dnf_context_rpmdb_changed_cb), context);
@pmatilai Please is there any option how to set such a callback inside rpm? I am looking how to not need to know where RPM stores data. Deleted code will not produce any future issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rpm doesn't support any "changed" callbacks on the rpmdb. What's the use-case of that? This sounds to me like a symptom of something else (locking probably) needing fixing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality is required for PackageKit daemon. Daemon loads data (installed and available packages) and reload them only when something is changed. Like when something is installed using rpm, PackageKit daemon must get signal that RPMDB was changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack, figures.
Maybe it could simply watch for the entire directory instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, the existing additions for rpmdb change monitoring do almost nothing for this particular use-case, they only really help the kind of on-startup cache-validity check that libsolv, yum etc do (heck even apt-rpm did that). Opened a ticket for adding change notifications but that's not going to help right now:
@Conan-Kudo: at this point, what matters is that we find a proper solution to these "lookey, this here file is the rpmdb" path games going forward. Until that solution exists yacking about backports is nothing but stop-energy pollution - we don't even know yet whether rpmdbCookie() or any of the new related APIs are useful or will be used for libdnf. |
@Conan-Kudo 50% of the problem could be resolved by #916 |
e7a0591
to
9584c58
Compare
We rely on identifying whether the rpmdb path has changed to determine whether we need to re-cache data from there. Now that RPM has multiple rpmdb options and there are two common paths in use by RPM-based systems, we need to handle all of these.
9584c58
to
a379606
Compare
@rh-atomic-bot retry |
@j-mracek @dmach Unfortunately, I'm out of time, so I'm shipping this patch in the openSUSE |
I would like to allow rpmdb cache for DNF-5, but we should use rpmdbCookie() to get rpmdn checksum. Hope that RPM will cache checksumm therefore it will be not calculated after each call. But for the second part, we need for a daemon mechanism how send a signal that rpmdb was changed. @pmatilai Please could you investigate it? |
The problem is that librpm has no means to track multiprocess users for notification, we'd basically need a daemon-process for ourselves through which all access to rpmdb is managed to achieve that. I suppose in theory we could add a some rpm-specific convenience wrapper for inotify but I'm not sure that actually achieves anything at all. Like noted earlier, I'd suggest simply replacing the current Packages monitor by monitoring the entire %_dbpath directory and when modifications are detected, do rpmdbCookie() to see if its relevant for you. |
@pmatilai I wanted to do quick check how rpmdbCookie() works but I'm probably doing something wrong and I couldn't get any useful output from it:
@j-mracek From the implementation of rpmdbCookie() the value is not cached and is calculated on each call again. |
@pmatilai oh, my bad. I needed to do |
Yup, the db needs to be open for that. It should probably emit some kind of noises when used on a closed db... |
☔ The latest upstream changes (presumably ee81887) made this pull request unmergeable. Please resolve the merge conflicts. |
This is obsolete with #916 merged. |
We rely on identifying whether the rpmdb path has changed to
determine whether we need to re-cache data from there. Now
that RPM has multiple rpmdb options and there are two common
paths in use by RPM-based systems, we need to handle all of
these.
Fixes #362