[Yum-devel] [PATCH] Avoid dangling iterators if auto_close is used

Panu Matilainen pmatilai at laiskiainen.org
Fri Feb 11 14:46:56 UTC 2011


On 02/11/2011 04:25 PM, seth vidal wrote:
> On Fri, 2011-02-11 at 14:20 +0200, Panu Matilainen wrote:
>> Closing the rpmdb which has active iterators turns the iterators
>> into zombies that whose locks can only be freed when the process
>> terminates. Rpm is being a reckless mom...
>> ---
>>   yum/rpmsack.py |    2 ++
>>   1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/yum/rpmsack.py b/yum/rpmsack.py
>> index 0982a7c..24bb9ce 100644
>> --- a/yum/rpmsack.py
>> +++ b/yum/rpmsack.py
>> @@ -658,6 +658,7 @@ class RPMDBPackageSack(PackageSackBase):
>>                   po._has_hdr = False
>>                   del po.hdr
>>               self._cached_conflicts_data = result.values()
>> +            del mi
>>
>>               if self.auto_close:
>>                   self.ts.close()
>> @@ -1276,6 +1277,7 @@ class RPMDBPackageSack(PackageSackBase):
>>                       break
>>               else:
>>                   ret.append(po)
>> +        del mi
>>
>>           if self.auto_close:
>>               self.ts.close()
>
> why do you have to specifically delete the match iterators?

Because with self.auto_close enabled, ts.close() destroys the 
transaction + db handle before the iterator falls out of scope. And when 
that happens, the iterator becomes a zombie which is hanging to locks 
but cannot be freed.

Quite obviously it should be rpm's responsibility (see 
http://rpm.org/ticket/820) but it's hardly going to get fixed for all 
the deployed rpm versions out there.

	- Panu -


More information about the Yum-devel mailing list