Unix sockets raise exception on long writes #3799

Closed
evanphx opened this Issue Apr 12, 2016 · 14 comments

Projects

None yet

7 participants

@evanphx
evanphx commented Apr 12, 2016

Environment

  • jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d Java HotSpot(TM) 64-Bit Server VM 25.72-b15 on 1.8.0_72-b15 +jit [darwin-x86_64]
  • Darwin veritas.local 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64
  • Rails app running puma: https://github.com/cdonadeo/puma_big_response_test

Expected Behavior

Long strings passed to UNIXSocket#write writes the data and returns the number of bytes written.

Actual Behavior

#write writes a subset of the data and raises an exception: #<SystemCallError: Unknown error - >}. The amount of data varies but I've seen 8192 show up not-randomly, almost like there was a 8k buffer somewhere.

The git repo linked to above shows the behavior. The exception in question is raise inside #fast_write. Changing the code to use #write instead of #syswrite does not change the behavior.

@headius
Member
headius commented Apr 12, 2016

Nice, haven't had a good UNIXSocket bug in a while. What are UNIX sockets used for in a puma set up?

I've got some long flights today so I may have time to look into this.

@TheKidCoder

Puma can use a UNIX socket to listen/respond to HTTP requests. For example, you can proxy requests from Nginx to Puma over a UNIX socket.

@evanphx
evanphx commented Apr 12, 2016

@headius What @TheKidCoder said.

@headius
Member
headius commented Apr 12, 2016

Ok that makes sense.

@ericqweinstein

Does this issue correspond to this constant?

@headius headius added this to the JRuby 9.1.1.0 milestone Apr 20, 2016
@headius
Member
headius commented Apr 20, 2016

@ericqweinstein Seems plausible...I'm not familiar with that value.

@headius headius modified the milestone: JRuby 9.1.1.0, JRuby 9.1.2.0 May 11, 2016
@enebo enebo modified the milestone: JRuby 9.1.2.0, JRuby 9.1.3.0 May 23, 2016
@headius
Member
headius commented Aug 22, 2016

We may be able to make progress on this with @etehtsea helping work on sockets. Sadly it won't be in 9.1.3.0.

@headius headius modified the milestone: JRuby 9.1.4.0, JRuby 9.1.3.0 Aug 22, 2016
@etehtsea
Contributor

Hopefully, I have a fix for this.

@etehtsea etehtsea added a commit to etehtsea/jruby that referenced this issue Aug 31, 2016
@etehtsea etehtsea IO#syswrite should always block. Fixes #3799
Do the same as in 857b76f
613c99f
@headius
Member
headius commented Nov 8, 2016

@etehtsea Got that fix in a releasable state? We're hoping to push 9.1.6.0 tomorrow.

@etehtsea
Contributor
etehtsea commented Nov 8, 2016

@headius no, I don't have better solution for now.

@headius
Member
headius commented Nov 8, 2016

@etehtsea I guess what I was asking is if the commit above is a "good enough" fix. If so, do you want to throw it in a PR for testing?

Status of testing is unclear and this is a key core API. Punting.

@headius headius modified the milestone: JRuby 9.1.7.0, JRuby 9.1.6.0 Nov 8, 2016
@etehtsea
Contributor
etehtsea commented Nov 9, 2016

@headius you said earlier that this fix couldn't be "good enough" because possibly it masks real issue.

As far as I remember I tested this issue using this app so if needed I could try to convert it to regression spec.

@etehtsea etehtsea added a commit to etehtsea/jruby that referenced this issue Nov 16, 2016
@etehtsea etehtsea Bump jnr-enxio and add regression test
Fixes #3799
ea714e8
@headius headius closed this in bfcec47 Nov 22, 2016
@sumitmah

@headius I'm still not getting consistent behaviour with 9.1.7.0 for the puma_big_response_test example app created by @evanphx.

@sumitmah

@headius we never merged following commit to master. etehtsea@613c99f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment