Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 2.5 stream closed in another thread #3229

Closed
7 tasks done
vholer opened this issue Apr 12, 2019 · 3 comments
Closed
7 tasks done

Ruby 2.5 stream closed in another thread #3229

vholer opened this issue Apr 12, 2019 · 3 comments

Comments

@vholer
Copy link
Contributor

vholer commented Apr 12, 2019

Description
On Ruby 2.5.x systems (Ubuntu 18.04 + 18.10, Debian 10), we might experience a strange behaviour when running several commands in parallel inside different threads.

For example:

$ onehost sync -f
#<Thread:0x00007f32c400bda8@/usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:348 run> terminated with exception (report_on_exception is true): 
Traceback (most recent call last): 
3: from /usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:349:in `block (2 levels) in sync' 
2: from /usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:349:in `loop' 
1: from /usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:372:in `block (3 levels) in sync' 
/usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:372:in ``': stream closed in another thread (IOError) 
#<Thread:0x00007f32c400bb78@/usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:348 run> terminated with exception (report_on_exception is true): 
Traceback (most recent call last): 
3: from /usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:349:in `block (2 levels) in sync' 
2: from /usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:349:in `loop' 
1: from /usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:372:in `block (3 levels) in sync' 
/usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:372:in ``': stream closed in another thread (IOError) 
#<Thread:0x000055f12fdb2358@/usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:348 run> terminated with exception (report_on_exception is true): 
Traceback (most recent call last): 
3: from /usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:349:in `block (2 levels) in sync' 
2: from /usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:349:in `loop' 
1: from /usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:372:in `block (3 levels) in sync' 
/usr/lib/one/ruby/cli/one_helper/onehost_helper.rb:372:in ``': stream closed in another thread (IOError) 
...

Might be related to this bugfix, which is not applied to Ruby 2.5.x:

Details

  • Affected Component:
  • Version: 5.8.1, master

Progress Status

  • Branch created
  • Code committed to development branch
  • Testing - QA
  • Documentation
  • Release notes - resolved issues, compatibility, known issues
  • Code committed to upstream release/hotfix branches
  • Documentation committed to upstream release/hotfix branches
@vholer
Copy link
Contributor Author

vholer commented Apr 12, 2019

A dirty workaround for this particular command action is:

--- a/src/cli/one_helper/onehost_helper.rb
+++ b/src/cli/one_helper/onehost_helper.rb
@@ -369,9 +369,20 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
                                    " #{host['NAME']}:#{remote_dir} 2> /dev/null"
                     end

-                    `#{sync_cmd} 2>/dev/null`
+                    retries = 3
+
+                    begin
+                        `#{sync_cmd} 2>/dev/null`
+                    rescue IOError => err
+                        # workaround for unpatched Ruby 2.5
+                        # https://bugs.ruby-lang.org/projects/ruby-trunk/repository/trunk/revision?utf8=%E2%9C%93&rev=63216
+                        if (retries -= 1) > 0
+                            sleep 1
+                            retry
+                        end
+                    end

-                    if !$CHILD_STATUS.success?
+                    if $CHILD_STATUS.nil? || !$CHILD_STATUS.success?
                         error_lock.synchronize do
                             host_errors << host['NAME']
                         end

(More parts could be affected. And, also it's not possible to do a command retry in most cases.)

@vholer
Copy link
Contributor Author

vholer commented May 7, 2019

This must be addressed by 5.8.2 for sure, the patch above was provided to the customer.

vholer pushed a commit that referenced this issue May 7, 2019
vholer pushed a commit that referenced this issue May 7, 2019
vholer pushed a commit to OpenNebula/docs that referenced this issue May 7, 2019
@vholer
Copy link
Contributor Author

vholer commented May 7, 2019

PRs to merge:

vholer pushed a commit that referenced this issue May 7, 2019
rsmontero pushed a commit that referenced this issue May 7, 2019
rsmontero pushed a commit to OpenNebula/docs that referenced this issue May 7, 2019
rsmontero pushed a commit that referenced this issue Oct 4, 2024
Signed-off-by: ArnauGabrielAtienza <agabriel@opennebula.io>
rsmontero pushed a commit that referenced this issue Jan 13, 2025
Signed-off-by: ArnauGabrielAtienza <agabriel@opennebula.io>
(cherry picked from commit a95a94b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants