#2382 systemd default service exception for rpmdb-rebuild service
Closed: Invalid 3 years ago by churchyard. Opened 3 years ago by pmatilai.

As a part of https://fedoraproject.org/wiki/Changes/Sqlite_Rpmdb, we're in the process of adding a one-shot service to perform database rebuilds (where format conversion can be a side-effect) during boot IFF a flag-file is present, much like selinux relabeling is done.

Due to the nature and intended use of the service, the systemd SOP macros and procedures don't seem applicable as Stephen Gallagher points out in https://bugzilla.redhat.com/show_bug.cgi?id=1826658#c1

This is an exception request to allow rpm to enable this rebuild-service unconditionally from its own %posttrans, but other solutions to the problem would be equally welcome.


To provide a little more detail into the proposed solution here:

In addition to adding the preset enablement for rpmdb-rebuild.service, we would add the following script to the %posttrans section of the RPM package:

%posttrans
if [ -x /usr/bin/systemctl ] ; then 
        /usr/bin/systemctl --no-reload preset rpmdb-rebuild.service || : 
fi

The effect of this is that at the end of any transaction where the rpm package is installed or uninstalled, we will set the enabled/disabled state of rpmdb-rebuild.service to the value contained in the presets file. As we've been asked to enable this service by default, that will have the effect of ensuring that this service is enabled every time RPM is updated.

If for some reason a user truly wanted to disable this service (which seems unlikely), they would need to mask it (systemctl mask rpmdb-rebuild.service). That said, given that the service only has an effect on the system when something has created /var/lib/rpm/.rebuilddb, I doubt anyone would ever bother trying to disable it.

I'm strongly in favor of this solution. +1

If for some reason a user truly wanted to disable this service (which seems unlikely), they would need to mask it (systemctl mask rpmdb-rebuild.service). That said, given that the service only has an effect on the system when something has created /var/lib/rpm/.rebuilddb, I doubt anyone would ever bother trying to disable it.

If this proposal is accepted, can we please ensure this is noted in the release notes issue?

/usr/bin/systemctl --no-reload preset rpmdb-rebuild.service

That, or simply "[...] enable rpmdb-rebuild.service" as then this could be managed entirely from inside rpm.spec without spreading the details across multiple packages. But I'm fine with either.

We use the presets as a single location to identify what is running by default on Fedora. I'd really like for us not to go back to the Bad Old Days of having service foo enable throughout the package set.

Ack, I'm not going to argue that.

Metadata Update from @bookwar:
- Issue tagged with: meeting

3 years ago

I don't see the motivation for treating this case different than any other package which adds a service file to an exisiting rpm. Normally, I would expect three things to happen: a preset to be in fedora-release, a normal scriptlet to be added to do the preset on installs, and a custom scriptlet to be added to do preset also on package upgrades (e.g. a %triggerun on the old rpm version as mentioned on the mailing list). The proposal here is to make the preset operation on each reinstall of the rpm package, and that goes against the philosophy so far of doing presets only on initial installation. The deal always was: presets determine the default, but admin can do systemctl enable/disable at any time and that stays.

For initial installation, systemd does preset-all at the end of installation. So the service will be enabled if enabled in presets. For upgrades, it doesn't matter when systemctl is called, any time is fine, so a normal %triggerun scriptlet should be OK.

I don't see the motivation for treating this case different than any other package which adds a service file to an exisiting rpm.

Fair enough. I'm not wanting to be different just for the sake of being different, but I didn't see (and still don't) this case documented in the systemd guidelines. Maybe I'm just going blind (the evidence has been mounting...)

For initial installation, systemd does preset-all at the end of installation. So the service will be enabled if enabled in presets. For upgrades, it doesn't matter when systemctl is called, any time is fine, so a normal %triggerun scriptlet should be OK.

Oh but the order does matter for upgrades, if the preset is set before the presets have been updated it defeats the purpose. But yes, a %triggerun will avoid the ordering issue.

The motivation for the big hammer approach is to ensure that everybody will get their databases converted when the time comes as this seemed like a priority pre-condition for the sqlite database feature in the first place. So if FESCo is okay with the idea that if the once-in-a-lifetime scriptlet happens to be missed for whatever reason, people will end up with nag messages about inconsistent database configuration ("warning: Found bdb Packages database while attempting sqlite backend: using bdb backend.") then fine by me.

So... do I actually need an exception to do this?

%triggerun -- rpm < 4.15.90-somerelease
if [ -x /usr/bin/systemctl ]; then
/usr/bin/systemctl --no-reload preset rpm ||:
fi

I can't find anything about such a thing in the docs so I just don't know.
With F32 out now, the moment to switch over to sqlite in rawhide is upon us so I'd like a fast closure here one way or the other, please.

I don't think any exception is needed for this.

No exception is needed (since it's just aligning it to the accepted preset).

Please go ahead and make that change for RPM. I just built fedora-release with the new preset, so that will be in Rawhide after the next compose.

Closing as invalid as no exception is apparently needed. Good luck with the switch.

Metadata Update from @churchyard:
- Issue close_status updated to: Invalid
- Issue status updated to: Closed (was: Open)

3 years ago

Ack, thanks for clarification + feedback.

Login to comment on this ticket.

Metadata