Ping?<br><br>On Wednesday, December 10, 2014, Umut Tezduyar Lindskog <<a href="mailto:umut@tezduyar.com">umut@tezduyar.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Dec 8, 2014 at 8:09 PM, Lennart Poettering<br>
<<a href="javascript:;" onclick="_e(event, 'cvml', 'lennart@poettering.net')">lennart@poettering.net</a>> wrote:<br>
> On Sun, 30.11.14 14:38, Umut Tezduyar Lindskog (<a href="javascript:;" onclick="_e(event, 'cvml', 'umut@tezduyar.com')">umut@tezduyar.com</a>) wrote:<br>
><br>
>> Hi,<br>
>><br>
>> We are experiencing an unbreakable loop in manager_dispatch_gc_queue.<br>
>> Problem happens when systemd runs in sysV compatibility mode (Porky<br>
>> enables this).<br>
>><br>
>> Seems like manager_dispatch_gc_queue's while loop gets stuck and seems<br>
>> like unit_gc_sweep cannot make a decision about the unit. As a result,<br>
>> it marks the unit with offset_unsure and adds the unit back to gc<br>
>> queue.<br>
>><br>
>> If I am reading the code correctly recursive unit_gc_sweep will never<br>
>> be able to remove the unit from the gc queue if it is referenced by<br>
>> another unit and if another unit is referenced by the unit.<br>
>><br>
>> A is referenced by B<br>
>> B is referenced by A<br>
><br>
> So in this case first A will be processed by the GC sweep, it will<br>
> follow the link to B while setting the state to IN_PATH and invoke the<br>
> GC sweep on that. B will then be set to IN_PATH too. GC sweep now<br>
> follows its link back, and up at A again, but this time return quickly<br>
> because its state is set to IN_PATH. Due to this, it will then set B's<br>
> state to UNSURE, and return to A, which in effect will now be set to<br>
> UNSURE too. Now, we return into GC queue dispatch call, which will<br>
> notice that it is UNSURE and uprgade that to BAD, and kill it because<br>
> there's nothin in the unit's dependency network that is clearly a<br>
> GOOD, and hence should be removed.<br>
><br>
> The essence of cycle breaking here is really in<br>
> manager_dispatch_gc_queue() which uprgades UNSURE to BAD in the end. I<br>
> am not seeing how this could end up in an endless loop hence.<br>
<br>
I have debugged it more and as you have said there is no bug in code<br>
but it takes so long to go out of unit_gc_sweep I thought there is a<br>
forever loop.<br>
<br>
Attached is my patch on 216 and<br>
<a href="https://drive.google.com/file/d/0B_uiALgWpGXtZ0VidURxSnVhcDA/view?usp=sharing" target="_blank">https://drive.google.com/file/d/0B_uiALgWpGXtZ0VidURxSnVhcDA/view?usp=sharing</a><br>
is a part of the log after patch.<br>
<br>
It has been 3 hours since I issued "systemctl isolate" and according<br>
to the logs I can see that garbage collection logic is making it's way<br>
back up. I guess it will eventually resolve itself but after so many<br>
hours.<br>
<br>
(Search for "-                     -" and it is happening every 300.000 lines)<br>
<br>
Problem seemed to be introduced on "95ed329" - Move handling of sysv<br>
initscripts to a generator.<br>
<br>
This is totally due to how sysV generator is linking services but I<br>
think slowness on GC can happen on a complex system with many units<br>
linked with each other.<br>
<br>
Thoughts?<br>
Umut<br>
<br>
><br>
>><br>
>> We have this circular referenced by dependency between units and I am<br>
>> quite sure they are due to sysV compatibility.<br>
>><br>
>> I know that systemd does not allow circular dependency between units<br>
>> (ex, wants, or after) but do we allow circular referenced by<br>
>> dependency? If so, then it is expected that manager_dispatch_gc_queue<br>
>> gets stuck.<br>
>><br>
>> We can reproduce it on 216/217 when we isolate a target.<br>
>><br>
>> Note: Line <a href="http://cgit.freedesktop.org/systemd/systemd/tree/src/core/manager.c?id=941a643569dc6b53d0b334276d2a3cc0ed159e88#n875" target="_blank">http://cgit.freedesktop.org/systemd/systemd/tree/src/core/manager.c?id=941a643569dc6b53d0b334276d2a3cc0ed159e88#n875</a><br>
>> should be before<br>
>> <a href="http://cgit.freedesktop.org/systemd/systemd/tree/src/core/manager.c?id=941a643569dc6b53d0b334276d2a3cc0ed159e88#n872" target="_blank">http://cgit.freedesktop.org/systemd/systemd/tree/src/core/manager.c?id=941a643569dc6b53d0b334276d2a3cc0ed159e88#n872</a><br>
>> since unit_gc_sweep() sets the u->in_gc_queue = true if it cannot make<br>
>> a decision and we set it back to false.<br>
><br>
> This is intended. After the sweep returned back to the anchor we can<br>
> make our decision: either add the unit to the cleanup queue in which<br>
> case it should removed from the GC queue, or it is reinstantated as<br>
> a good unit that should continue to exist, in which case it should be<br>
> removed from the GC queue too.<br>
><br>
> Can't see a bug here...<br>
><br>
> Can you elaborate on how precisely you are encountering the GC loop?<br>
><br>
> Lennart<br>
><br>
> --<br>
> Lennart Poettering, Red Hat<br>
</blockquote>