Description of problem: There are a few systemd macros for %pre/%post/... phases of rpm package update. Services are restarted once updated is complete. Some services does not work properly and/or spawn error messages if they are running during update. For this case, it'd help if you could add another set of systemd macros that would stop service before update and start it again once update is complete.
Would you give us a couple of examples of packages whose scriptlets do this?
One example is dovecot. It has master process spawning workers and has dlopen-ed plugins. Bug #134325. Fix was removed during one spec file clean-up and I got email that it caused problems again, so I put it back. Second package is nut which also has several workers communicating together. This package does not have fix for this yet. I filed this bug before fixing it.
If a package can't be restarted cleanly via normal methods in a transaction, perhaps it shouldn't be restarted at all and be left to the administrator?
The problem is not time of the restart, the problem is that some services should not be running with half new, half old files. Master process spawns workers (and communicates with them) and workers dlopen plugins. If old master spawns new worker, it can cause a problem. If old worker tries to dlopen new plugin, it can cause a problem.
I don't think we want to handle this in systemd macros. Programs generally need to deal with files being upgraded in place… In cases where this is not possible, the solution will be specific to the program at hand. Trying to come up with something generic would be a lot of effort that likely wouldn't turn out to be very useful anyway.