Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1336819

Summary: [RHEL-7-2] Cannot access/write repodata files: [Errno 24] Too many open files
Product: Red Hat Enterprise Linux 7 Reporter: PaulB <pbunyan>
Component: createrepoAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED INSUFFICIENT_DATA QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: emrakova, james.antill, mdomonko, pbunyan, prarit
Target Milestone: rcFlags: pbunyan: needinfo-
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-01-03 14:13:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description PaulB 2016-05-17 13:50:57 UTC
Description of problem:
 While configuring large system (24TB-RAM 768CPUs), createrepo command fails:
Cannot access/write repodata files: [Errno 24] Too many open files
 
Version-Release number of selected component (if applicable):
 distro: RHEL-7.2
 kernel: 3.10.0-327.el7.x86_64
 createrepo: 0.9.9-23.el7.noarch

How reproducible:
 consistently on target host 

Actual results:
I have a directory with 5-60 rpm files.
I cd to the directory and run the "createrepo ." command.
While configuring the system for for remote testing, I found that the createrepo command failed due to the following issue:
---<-snip->---
Spawning worker 492 with 0 pkgs
Spawning worker 493 with 0 pkgs
Spawning worker 494 with 0 pkgs
Spawning worker 495 with 0 pkgs
Spawning worker 496 with 0 pkgs
Spawning worker 497 with 0 pkgs
Spawning worker 498 with 0 pkgs
Spawning worker 499 with 0 pkgs
Spawning worker 500 with 0 pkgs
Spawning worker 501 with 0 pkgs
Spawning worker 502 with 0 pkgs
Spawning worker 503 with 0 pkgs
Spawning worker 504 with 0 pkgs
Spawning worker 505 with 0 pkgs
Spawning worker 506 with 0 pkgs
Cannot access/write repodata files: [Errno 24] Too many open files
---<-snip->---

Expected results:
 successful creation of the repodata file with no errors reported

Additional info:

Comment 1 PaulB 2016-05-17 13:55:15 UTC
All,
While configuring the large system (24TB-RAM 768CPUs) for for remote testing, I found that the createrepo command failed due to the following issue:
---<-snip->---
Spawning worker 492 with 0 pkgs
Spawning worker 493 with 0 pkgs
Spawning worker 494 with 0 pkgs
Spawning worker 495 with 0 pkgs
Spawning worker 496 with 0 pkgs
Spawning worker 497 with 0 pkgs
Spawning worker 498 with 0 pkgs
Spawning worker 499 with 0 pkgs
Spawning worker 500 with 0 pkgs
Spawning worker 501 with 0 pkgs
Spawning worker 502 with 0 pkgs
Spawning worker 503 with 0 pkgs
Spawning worker 504 with 0 pkgs
Spawning worker 505 with 0 pkgs
Spawning worker 506 with 0 pkgs
Cannot access/write repodata files: [Errno 24] Too many open files
---<-snip->---


Looking at the "default" set current limits, I see this:
[root@ ]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 99079946
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 99079946
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@ ]#


In an attempt to tweak the  "open files (-n) 1024"  limit,
we tried the following:
[root@ ]# ulimit -n 2000

[root@ ]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 99079946
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 2000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 99079946
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@ ]# 


Rerunning the createrepo command with "open files (-n) 2000" set,
we get the following issue:
Spawning worker 762 with 0 pkgs
Spawning worker 763 with 0 pkgs
Spawning worker 764 with 0 pkgs
Spawning worker 765 with 0 pkgs
Spawning worker 766 with 0 pkgs
Spawning worker 767 with 0 pkgs
Traceback (most recent call last):
  File "/usr/share/createrepo/genpkgmetadata.py", line 294, in <module>
    main(sys.argv[1:])
  File "/usr/share/createrepo/genpkgmetadata.py", line 268, in main
    mdgen.doPkgMetadata()
  File "/usr/lib/python2.7/site-packages/createrepo/__init__.py", line 421, in doPkgMetadata
    self.writeMetadataDocs(packages)
  File "/usr/lib/python2.7/site-packages/createrepo/__init__.py", line 704, in writeMetadataDocs
    log_messages(num)
  File "/usr/lib/python2.7/site-packages/createrepo/__init__.py", line 676, in log_messages
    for stream in select((job.stdout, job.stderr), (), ())[0]:
ValueError: filedescriptor out of range in select()


I reset the the value:
 [root@ ]# ulimit -n 1024
You have new mail in /var/spool/mail/root
[root@ ]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 99079946
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 99079946
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@ ]# 

And was able to use the following, as a workaround for this issue:
[root@ ]# createrepo --workers 1 .
Spawning worker 0 with 65 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@ ]# 


Best,
-pbunyan

Comment 2 Prarit Bhargava 2016-05-17 14:12:50 UTC
So I think there are two issues.  The first is the 

 Cannot access/write repodata files: [Errno 24] Too many open files

which occurs because the OS has a lot of open files when createrepo is run.  This, as pbunyan, has pointed out can be resolved by increasing the open file limit.

The second problem pbunyan hits is more of a coding problem AFAICT:

  File "/usr/share/createrepo/genpkgmetadata.py", line 294, in <module>
    main(sys.argv[1:])
  File "/usr/share/createrepo/genpkgmetadata.py", line 268, in main
    mdgen.doPkgMetadata()
  File "/usr/lib/python2.7/site-packages/createrepo/__init__.py", line 421, in doPkgMetadata
    self.writeMetadataDocs(packages)
  File "/usr/lib/python2.7/site-packages/createrepo/__init__.py", line 704, in writeMetadataDocs
    log_messages(num)
  File "/usr/lib/python2.7/site-packages/createrepo/__init__.py", line 676, in log_messages
    for stream in select((job.stdout, job.stderr), (), ())[0]:
ValueError: filedescriptor out of range in select()

which implies some declaration or casting issue with with the way the filedescriptors are stored.

P.

Comment 7 Michal Domonkos 2018-11-30 14:12:51 UTC
Can you still reproduce this issue?

Looking into the code, I cannot really grasp why it would spawn so many workers without being explicitly asked with the --workers switch.  The way it works is, if the switch isn't specified, it spawns as many workers as there are CPUs (or as many packages are being processed if the number of CPUs is higher than that).

Comment 8 Michal Domonkos 2018-11-30 14:21:32 UTC
Eh, I was looking at the upstream version; in the RHEL version, the logic always spawns as many workers as there are CPUs (so it's possible the way we detect the number of CPUs is flawed).  But we would still greatly benefit from having a reproducer.