[Home]

Summary:ASTERISK-30198: Error `Too many open files` occurs after about ~8000 calls when using mixmonitor
Reporter:Julien Alie (ja0x)Labels:
Date Opened:2022-08-31 10:50:24Date Closed:2022-12-20 08:51:40.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Applications/app_mixmonitor
Versions:19.5.0 Frequency of
Occurrence
Frequent
Related
Issues:
Environment:Linux debian-buster 4.19.0-21-amd64Attachments:
Description:Crash occurs because file descriptors are not freed until all resources are exhausted.  

This issue happens when mixmonitor is configured to play `beep` on stop (flag P).  When call is hungup before manually stopping mixmonitor, it attempts to play `beep.slin` but will fail and file descriptor for beep will never be released.  

Current workaround to avoid the issue is to disable the beep on stop (remove flag "P")
Comments:By: Asterisk Team (asteriskteam) 2022-08-31 10:50:30.075-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

Please note that by submitting data, code, or documentation to Sangoma through JIRA, you accept the Terms of Use present at [https://www.asterisk.org/terms-of-use/|https://www.asterisk.org/terms-of-use/].

By: Peter Fern (pdf) 2022-11-21 17:30:20.545-0600

This issue is affecting our whole fleet of Asterisk servers, affects all current Asterisk versions and is high severity as leaking FDs will render Asterisk instances unusable. The Gerrit process appears to have stalled after the initial review.

I don't have the C or Asterisk internals chops to know what the side-effects of applying this change inside `ast_stream_and_wait` might be, but the change itself looks quite straight-forward. How do we best move forward on this?

By: Peter Fern (pdf) 2022-11-21 21:53:59.760-0600

I've added an alternative fix for review based on the recommendations on the original patch. I've checked all the `ast_stream_and_wait` call sites and it looks to me like this change should be safe as none of them appear to call `ast_closestream` without a guard against the stream existing (pretty much everywhere uses `ast_stopstream`, when they actually close the stream at all, which is safe).

Our testing here shows that this resolves the case reported in the original issue, and should resolve any other cases where `ast_stream_and_wait` might be called on a channel that's in a state where the stream cannot complete.

By: Friendly Automation (friendly-automation) 2022-12-20 08:51:41.756-0600

Change 19574 merged by George Joseph:
streams:  Ensure that stream is closed in ast_stream_and_wait on error

[https://gerrit.asterisk.org/c/asterisk/+/19574|https://gerrit.asterisk.org/c/asterisk/+/19574]

By: Friendly Automation (friendly-automation) 2022-12-20 08:51:45.145-0600

Change 19720 merged by George Joseph:
streams:  Ensure that stream is closed in ast_stream_and_wait on error

[https://gerrit.asterisk.org/c/asterisk/+/19720|https://gerrit.asterisk.org/c/asterisk/+/19720]

By: Friendly Automation (friendly-automation) 2022-12-20 08:51:47.619-0600

Change 19699 merged by George Joseph:
streams:  Ensure that stream is closed in ast_stream_and_wait on error

[https://gerrit.asterisk.org/c/asterisk/+/19699|https://gerrit.asterisk.org/c/asterisk/+/19699]