Bug 1594016 - dnf.Base.close() does not close hawkey.log filedescriptor
Summary: dnf.Base.close() does not close hawkey.log filedescriptor
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 29
Hardware: All
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Jaroslav Mracek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1781360 1781364
TreeView+ depends on / blocked
 
Reported: 2018-06-21 21:13 UTC by Orion Poplawski
Modified: 2019-12-10 16:20 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
: 1781360 1781364 (view as bug list)
Environment:
Last Closed: 2019-10-19 15:39:08 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Orion Poplawski 2018-06-21 21:13:36 UTC
Description of problem:

Not sure if this is a dnf issue or father down, but:

#!/usr/bin/python3
import dnf
import psutil

proc = psutil.Process()
base = dnf.Base()
base.conf.assumeyes = True
base.conf.read()
for i in [1, 2, 3]:
    base.fill_sack(load_system_repo='auto')
    base.close()
    print(proc.open_files())


produces:

[popenfile(path='/var/lib/sss/mc/passwd', fd=3, position=0, mode='r', flags=557056), popenfile(path='/var/lib/sss/mc/group', fd=5, position=0, mode='r', flags=557056), popenfile(path='/var/tmp/dnf-orion-admin-75jop0p2/hawkey.log', fd=6, position=4834, mode='a', flags=33793)]
[popenfile(path='/var/lib/sss/mc/passwd', fd=3, position=0, mode='r', flags=557056), popenfile(path='/var/lib/sss/mc/group', fd=5, position=0, mode='r', flags=557056), popenfile(path='/var/tmp/dnf-orion-admin-75jop0p2/hawkey.log', fd=6, position=4880, mode='a', flags=33793), popenfile(path='/var/tmp/dnf-orion-admin-75jop0p2/hawkey.log', fd=7, position=4968, mode='a', flags=33793)]
[popenfile(path='/var/lib/sss/mc/passwd', fd=3, position=0, mode='r', flags=557056), popenfile(path='/var/lib/sss/mc/group', fd=5, position=0, mode='r', flags=557056), popenfile(path='/var/tmp/dnf-orion-admin-75jop0p2/hawkey.log', fd=6, position=4880, mode='a', flags=33793), popenfile(path='/var/tmp/dnf-orion-admin-75jop0p2/hawkey.log', fd=7, position=5014, mode='a', flags=33793), popenfile(path='/var/tmp/dnf-orion-admin-75jop0p2/hawkey.log', fd=8, position=5102, mode='a', flags=33793)]

Note the multiple open files of hawkey.log.

Version-Release number of selected component (if applicable):
python3-dnf-2.7.5-12.fc28.noarch

Related see https://github.com/ansible/ansible/pull/41810

Comment 1 David Wilson 2018-06-22 03:33:52 UTC
Hi there,

This problem seems to be due to 'self._sack = None' in 'def reset()' being insufficient to clear out the last reference to the Sack, causing tp_dealloc() to call hy_sack_free() and subsequently close the file descriptor.

Triggering a manual 'gc.collection()' suggests the problem is also unrelated to a reference cycle within the graph of the Sack object itself, unless it has a missing or buggy tp_traverse implementation.

Please expose an explicit close() method on the Sack object, the existing API is unsafe as it conflates memory management and resource finalization, which always leads to fragile and surprising results

Related digging: https://github.com/dw/mitogen/issues/280#issuecomment-399307248

Comment 2 Ben Cotton 2019-05-02 20:47:28 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 3 Orion Poplawski 2019-05-06 17:42:41 UTC
Still present with python3-dnf-4.2.5-1.fc29.noarch

Comment 4 Jaroslav Mracek 2019-09-10 16:47:56 UTC
I created a patch: https://github.com/rpm-software-management/libdnf/pull/792

Comment 5 Jaroslav Mracek 2019-10-19 15:39:08 UTC
Fixed in Fedora 30 - dnf-4.2.11


Note You need to log in before you can comment on or make changes to this bug.