The Type=oneshot unit A.service is started hourly by A.timer and it Wants=B.service, but runs Before=B.service. Unit B.service is also Type=oneshot. The requirement here is that their processes should never overlap at run time (oneshot ensures exactly that), all great so far. Now imagine a scenario where both A and B together run for more than an hour (time between A.timer fires). There are two possibilities here:
Aruns more than an hour, then althoughA.timerwants to fire and it probably does, regardless, another instance ofAwill not be started until the first one finishes as service instance uniqueness is one of fundamental principles insystemd. I believe it will be merely queued. Again, all great so far, we have no risk of overlapping processes at run time here.Aruns long enough, so thatB, which runs afterwards, also runs long enough to exceed one hour in total, and as a result,A.timerfires to start newAwhileBis still running. That's where we run into a process overlap because there is noAfter=B.serviceinA.serviceas there is alreadyBefore=B.service.
My question is, basically, whether it is valid to even have both After=B.service and Before=B.service in A.service in the first place? And, of course, would it resolve the overlapping issue described in the second possibility as I theoretically expect? Is there any other systemd-way to solve this issue (e.g. I don't want to get involved with error-prone lock file bloat)?