{"action":"created","issue":{"url":"https://api.github.com/repos/bundler/bundler/issues/3692","labels_url":"https://api.github.com/repos/bundler/bundler/issues/3692/labels{/name}","comments_url":"https://api.github.com/repos/bundler/bundler/issues/3692/comments","events_url":"https://api.github.com/repos/bundler/bundler/issues/3692/events","html_url":"https://github.com/bundler/bundler/issues/3692","id":82759513,"number":3692,"title":"Fatal: No live threads left. Deadlock?","user":{"login":"rogierslag","id":2778689,"avatar_url":"https://avatars.githubusercontent.com/u/2778689?v=3","gravatar_id":"","url":"https://api.github.com/users/rogierslag","html_url":"https://github.com/rogierslag","followers_url":"https://api.github.com/users/rogierslag/followers","following_url":"https://api.github.com/users/rogierslag/following{/other_user}","gists_url":"https://api.github.com/users/rogierslag/gists{/gist_id}","starred_url":"https://api.github.com/users/rogierslag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogierslag/subscriptions","organizations_url":"https://api.github.com/users/rogierslag/orgs","repos_url":"https://api.github.com/users/rogierslag/repos","events_url":"https://api.github.com/users/rogierslag/events{/privacy}","received_events_url":"https://api.github.com/users/rogierslag/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-05-30T09:15:35Z","updated_at":"2015-06-09T23:32:04Z","closed_at":null,"body":"Might be related to https://github.com/bundler/bundler/issues/2813\r\n\r\nWe have this problem with our testing infrastructure, where I'm unable to build new Docker containers. Since we test in Docker, in order to keep the testing speed up we have pre-prepared containers, which house all the gems already. In case of a new gem, only a little bit needs to be installed instead of the whole thing (reducing lead time). However, while preparing a new container, Bundle seems to encounter a deadlock.\r\n\r\nThe following script is used to build this container\r\n\r\n```bash\r\n#!/bin/bash\r\n#\r\n# Map the application in Docker to `/test`, so we have `/test/Gemfile` and `/test/Gemfile.lock`\r\n\r\n# Update everything\r\nsudo apt-get update\r\nsudo apt-get install curl -y\r\nsudo apt-get update && sudo apt-get upgrade -y\r\ncurl -sL https://deb.nodesource.com/setup | sudo bash -\r\nsudo apt-get install nodejs build-essential libmysqlclient-dev redis-server postgresql libpq-dev git -y\r\nnpm install -g bower\r\n\r\n# Install rvm\r\ngpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3\r\n\\curl -sSL https://get.rvm.io | bash -s stable --ruby\r\nsource /usr/local/rvm/scripts/rvm\r\n\r\n# Check the ruby versions\r\nVERSIONS=('2.2.2')\r\n\r\n# Install all dependencies\r\ncd /test\r\nfor v in $VERSIONS; do rvm install $v && rvm use $v && gem install bundler && bundle install --system && echo \"Installed ruby-${v} and gems correctly\"; done\r\n\r\n# Clear the container a bit\r\nsudo apt-get autoremove && sudo apt-get clean\r\nrm -rf /var/lib/apt/lists/*\r\n```\r\n\r\nSetting the thread number differently with `--jobs=X` does not make any difference.\r\n\r\nWe use the following Gemfile, the most recent addition is the `pg` gem in order to prepare a switch from MariaDB to Postgresql. However, when using incremental builds, this works on our Vagrant machines.\r\n\r\nThe exact failure as reported by Bundler is\r\n\r\n```\r\nError details\r\n\r\n    fatal: No live threads left. Deadlock?\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/worker.rb:35:in `pop'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/worker.rb:35:in `deq'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/installer/parallel_installer.rb:94:in `process_specs'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/installer/parallel_installer.rb:75:in `call'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/installer/parallel_installer.rb:57:in `call'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/installer.rb:283:in `install_in_parallel'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/installer.rb:91:in `run'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/installer.rb:18:in `install'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/cli/install.rb:107:in `run'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/cli.rb:158:in `install'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/cli.rb:10:in `start'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/bin/bundle:20:in `block in <top (required)>'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/lib/bundler/friendly_errors.rb:7:in `with_friendly_errors'\r\n      /usr/local/rvm/gems/ruby-2.2.2/gems/bundler-1.10.1/bin/bundle:18:in `<top (required)>'\r\n      /usr/local/rvm/gems/ruby-2.2.2/bin/bundle:23:in `load'\r\n      /usr/local/rvm/gems/ruby-2.2.2/bin/bundle:23:in `<main>'\r\n      /usr/local/rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'\r\n      /usr/local/rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'\r\n\r\nEnvironment\r\n\r\n    Bundler   1.10.1\r\n    Rubygems  2.4.7\r\n    Ruby      2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]\r\n    GEM_HOME  /usr/local/rvm/gems/ruby-2.2.2\r\n    GEM_PATH  /usr/local/rvm/gems/ruby-2.2.2:/usr/local/rvm/gems/ruby-2.2.2@global\r\n    RVM       1.26.11 (latest)\r\n    Git       1.9.1\r\n    rubygems-bundler (1.4.4)\r\n\r\nBundler settings\r\n\r\n    jobs\r\n      Set for your local app (/test/.bundle/config): \"16\"\r\n```\r\n\r\nWe use the following Gemfile\r\n\r\n```gemfile\r\nsource 'https://rubygems.org'\r\n\r\ngem 'rails',        '4.1.10'\r\ngem 'sass-rails',   '~> 4.0.3'\r\ngem 'uglifier',     '~> 2.7.0'\r\ngem 'coffee-rails', '~> 4.1.0'\r\ngem 'jbuilder',     '~> 2.2'\r\n\r\n# For sidekqi WEB ui\r\ngem 'sinatra', :require => nil\r\n\r\ngem 'execjs'\r\ngem 'therubyracer'\r\ngem 'capybara'\r\ngem 'pundit'\r\ngem 'pg'\r\ngem 'mysql2'\r\n\r\ngem 'sidekiq'\r\ngem 'sidekiq-rate-limiter', :require => 'sidekiq-rate-limiter/server'\r\ngem 'sidekiq-limit_fetch'\r\n\r\ngem 'aws-sdk', '~> 2.0'\r\ngem 'mail'\r\n\r\ngem 'bcrypt', '~> 3.1.9'\r\n\r\ngem 'squeel', '~> 1.2.2' # Improves sql syntax\r\n\r\n# Fonts\r\ngem 'font-awesome-sass', '~> 4.3.0'\r\n\r\n# Payment gems\r\ngem 'ideal-payment',  '~> 1.0.2'\r\ngem 'buckaroo'\r\ngem 'mollie-api-ruby', '>= 1.1.2'\r\n\r\n# Passbook gem\r\ngem 'passbook'\r\n\r\n# i18n\r\ngem 'gettext_i18n_rails'\r\n\r\n# Facebook\r\ngem 'koala', '~> 2.0.0'\r\n\r\n# Validate all the things\r\ngem 'validates_email_format_of'\r\n\r\n# Keep versioning of everything in the database\r\ngem 'paper_trail'\r\n\r\n# And in ES\r\ngem 'logstasher'\r\ngem 'logstash-logger'\r\n\r\ngroup :development do\r\n  # Auto annotate models\r\n  gem 'annotate'\r\n\r\n  gem 'rails-erd'\r\nend\r\n\r\ngroup :development, :test do\r\n  gem 'gettext', '>=3.0.2', require: false\r\n  gem 'pry'\r\n  gem 'thin'\r\n  gem 'coffee-rails-source-maps'\r\n  gem 'sqlite3'\r\n  gem 'poltergeist'\r\n  gem 'konacha'\r\n  gem 'sinon-rails'\r\n  gem 'sinon-chai-rails'\r\nend\r\n\r\ngroup :test do\r\n  gem 'codeclimate-test-reporter'\r\n  gem 'rspec-rails',           '~> 3.1.0'\r\n  gem 'faker',                 '~> 1.4.3'\r\n  gem 'rspec_junit_formatter', '~> 0.2.0'\r\n\r\n  gem 'simplecov'\r\n  gem 'simplecov-csv'\r\n\r\n  gem 'shoulda-matchers',      '~> 2.7.0'\r\n  gem 'factory_girl_rails',    '~> 4.5.0', require: false\r\nend\r\n\r\ngroup :deploy do\r\n  # Render the templates\r\n  gem 'render_anywhere', '0.0.11', require: false\r\nend\r\n\r\ngroup :staging, :production do\r\n  gem 'puma'\r\nend\r\n\r\n# These are for the security monitoring\r\ngroup :development, :test, :deploy do\r\n  gem 'brakeman', require: false\r\n  gem 'dawnscanner'\r\nend\r\n\r\ngroup :doc do\r\n  # bundle exec rake doc:rails generates the API under doc/api.\r\n  gem 'sdoc', require: false\r\nend\r\n```"},"comment":{"url":"https://api.github.com/repos/bundler/bundler/issues/comments/110532919","html_url":"https://github.com/bundler/bundler/issues/3692#issuecomment-110532919","issue_url":"https://api.github.com/repos/bundler/bundler/issues/3692","id":110532919,"user":{"login":"envygeeks","id":99763,"avatar_url":"https://avatars.githubusercontent.com/u/99763?v=3","gravatar_id":"","url":"https://api.github.com/users/envygeeks","html_url":"https://github.com/envygeeks","followers_url":"https://api.github.com/users/envygeeks/followers","following_url":"https://api.github.com/users/envygeeks/following{/other_user}","gists_url":"https://api.github.com/users/envygeeks/gists{/gist_id}","starred_url":"https://api.github.com/users/envygeeks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/envygeeks/subscriptions","organizations_url":"https://api.github.com/users/envygeeks/orgs","repos_url":"https://api.github.com/users/envygeeks/repos","events_url":"https://api.github.com/users/envygeeks/events{/privacy}","received_events_url":"https://api.github.com/users/envygeeks/received_events","type":"User","site_admin":false},"created_at":"2015-06-09T23:32:04Z","updated_at":"2015-06-09T23:32:04Z","body":"@segiddins \r\n\r\n```\r\ngit clone https://github.com/jekyll/jekyll.git\r\nbundle install --path vendor/bundle -j 12\r\n```\r\n\r\nError happens. This is on 1.10.3\r\n\r\n\r\n```\r\nEnvironment\r\n    Bundler   1.10.3\r\n    Rubygems  2.4.7\r\n    Ruby      2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]\r\n    GEM_HOME  /home/jordon/development/jekyll/jekyll/vendor/bundle/ruby/2.2.0\r\n    GEM_PATH  \r\n    Git       1.9.1\r\n```\r\n\r\nLooking at the source it seems to me like your thread pooling is unsafely popping and pushing onto the queue without taking heed to the need for a mutex to make sure everything is in sync and then when it all goes wrong throwing yourself.  I could be wrong though and I'd have to write that file with safety to make sure that's the case."}}