nonblocking_server shutdown race under in Ruby 1.9
--------------------------------------------------
Key: THRIFT-1187
URL: https://issues.apache.org/jira/browse/THRIFT-1187
Project: Thrift
Issue Type: Bug
Components: Ruby - Library
Affects Versions: 0.6.1
Environment: OS X Darwin 10.6 i686 + Ruby 1.9.2-p180
Reporter: Ilya Maykov
Priority: Minor
While testing some changes today I noticed that nonblocking_server tests pass
for me under Ruby 1.8.7 but fail under Ruby 1.9.2. Here are the test failures:
1)
Errno::EBADF in 'Thrift::NonblockingServer should shut down when asked'
Bad file descriptor
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:48:in
`select'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:48:in
`block in serve'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in
`loop'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in
`serve'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/spec/nonblocking_server_spec.rb:118:in
`block (3 levels) in <class:ThriftNonblockingServerSpec>'
2)
Errno::EBADF in 'Thrift::NonblockingServer should kill active messages when
they don't expire while shutting down'
Bad file descriptor
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:48:in
`select'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:48:in
`block in serve'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in
`loop'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in
`serve'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/spec/nonblocking_server_spec.rb:118:in
`block (3 levels) in <class:ThriftNonblockingServerSpec>'
3)
Errno::EBADF in 'Thrift::NonblockingServer should allow shutting down in
response to a message'
Bad file descriptor
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:48:in
`select'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:48:in
`block in serve'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in
`loop'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/lib/thrift/server/nonblocking_server.rb:45:in
`serve'
/Users/ilyam/src/vendor/thrift-src/thrift-0.6.1-r19/lib/rb/spec/nonblocking_server_spec.rb:118:in
`block (3 levels) in <class:ThriftNonblockingServerSpec>'
Finished in 2.854211 seconds
I *think* that either the behavior of select() changed between 1.8.7 and 1.9.2,
or the different threading model in 1.9.2 is tickling a timing bug. In any
case, shutting down the server causes the @server_transport socket to be
closed, which raises Errno::EBADF in the main loop inside the serve() method.
Probably not a big deal because the server is shutting down anyway, but should
be fixed so the tests pass.
Will attach patch shortly.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira