Welcome! Log In Create A New Profile

Advanced

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

Maxim Dounin
February 22, 2018 12:08PM
Hello!

On Thu, Feb 22, 2018 at 08:12:25AM -0500, papajoe wrote:

> Hey everybody,
>
> I experienced this issue using nginx version 1.10.x and 1.13.x
>
>
> given a basic configuration like:
>
> upstream myupstream {
> server internal01:80;
> server internal02:80 backup;
> }
>
> server {
> listen 81 default_server;
> listen [::]:81 default_server;
>
> server_name _;
>
> location / {
> proxy_pass http://myupstream;
> post_action @hot_standby;
> }
>
> location @hot_standby {
> proxy_pass http://internal02:80;
> }
> }
>
>
> I receive the "sendfile() failed (9: Bad file descriptor) while sending
> request to upstream" error when trying to POST data exceeding 16k body
> size. The error does not occur for requests with less than 16k data.
> As far as I can understand the code / documentation, 16k by default (for
> 64bit systems) is the limit when nginx starts to use a tempfile instead of a
> memory buffer.
> http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size
>
> This makes me believe that the problem only kicks in when nginx decides to
> use a tempfile instead of an inmemory buffer.
>
>
> For my setup I was able to fix the issue by an alignment between
> client_body_buffer_size and client_max_body_size.
>
> client_max_body_size 1m;
> client_body_buffer_size 1m;
>
>
> Hope this can help anybody.

Just in case you are interested in details, this is a result in
optimization in the proxy module, which removes the request body
file as soon as a response is received. Additional details can be
found here:

http://hg.nginx.org/nginx/rev/f583559aadc7
https://trac.nginx.org/nginx/ticket/585

To fix this, consider using mirror instead of the [intentionally
undocumented] post_action directive, see
http://nginx.org/en/docs/http/ngx_http_mirror_module.html.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 12, 2010 07:00AM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

Maxim Dounin August 12, 2010 08:24AM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

papajoe February 22, 2018 08:12AM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

Maxim Dounin February 22, 2018 12:08PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

papajoe February 23, 2018 02:36PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 12, 2010 11:09PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 12, 2010 11:37PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 13, 2010 02:07AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 313
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready