Project

General

Profile

Bug #29044

Rework middlewared pipes so that file descriptors won't leak

Added by William Grzybowski over 1 year ago. Updated over 1 year ago.

Status:
Done
Priority:
Critical
Assignee:
Vladimir Vinogradenko
Category:
Middleware
Target version:
Seen in:
Severity:
Med High
Reason for Closing:
Reason for Blocked:
Needs QA:
No
Needs Doc:
No
Needs Merging:
No
Needs Automation:
No
Support Suite Ticket:
n/a
Hardware Configuration:
ChangeLog Required:
No

Description

https://github.com/freenas/freenas/blob/master/src/middlewared/middlewared/job.py#L210

File descriptors are allocated here but there is no guarantee that they will be closed eventually. Job is responsible for closing them and it may fail.


Related issues

Copied from FreeNAS - Bug #28982: Temporary fix to silence "@job(pipe=True) leaking file descriptors" messagesDone2018-03-01

Associated revisions

Revision 31e994c6 (diff)
Added by Vladimir Vinogradenko over 1 year ago

fix(middleware): Rework pipes so that file descriptors won't leak: * Explicitly define what side of pipe job will use (reading or writing). Use two pipes if both is required. * Make caller responsible for opening and closing pipes. Callee checks if pipes were actually open. * Add `middleware.run_in_io_thread` for blocking I/O on pipes. Thread pool is unlimited, threads are self-destroyed after being used. This may be not the best solution in terms of system resources but it leads to much simplier code than using e.g. https://github.com/mosquito/aio-pipe and doing asynchronous block I/O in python may be even more CPU-consuming. * Cancel jobs started by `core.download` after 60 seconds of inactivity. It is the only caller that leaves opened pipe after finishing. * Use shutil.copyfileobj whenever possible. * Fix a few rare-occuring bugs Ticket: #29044

History

#1 Updated by William Grzybowski over 1 year ago

  • Copied from Bug #28982: Temporary fix to silence "@job(pipe=True) leaking file descriptors" messages added

#2 Updated by William Grzybowski over 1 year ago

  • Severity set to Med High

#3 Updated by Vladimir Vinogradenko over 1 year ago

  • Status changed from Not Started to In Progress

#4 Updated by Vladimir Vinogradenko over 1 year ago

  • Status changed from In Progress to Done

#5 Updated by Dru Lavigne over 1 year ago

  • Subject changed from @job(pipe=True) leaking file descriptors to Rework middlewared pipes so that file descriptors won't leak
  • Target version changed from 11.2-RC2 to 11.2-BETA1
  • Needs Doc changed from Yes to No
  • Needs Merging changed from Yes to No

#6 Updated by Dru Lavigne over 1 year ago

  • Status changed from Done to Ready for Testing

#7 Updated by William Grzybowski over 1 year ago

  • Needs QA changed from Yes to No

#8 Updated by Dru Lavigne over 1 year ago

  • Status changed from Ready for Testing to Done

Also available in: Atom PDF