Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: None
    • Labels:
    • Environment:
      Windows 7, hp pavilion dv6
    • Patch Submitted:
      Yes
    • Number of attachments :
      2

      Description

      There is a race condition in the Thread.list function where it is possible to read the list before the thread has been added.

      I first saw this issue in JRuby 1.4 and reported it (JRUBY-4307), but the ticket was not solved. I haven't checked to see if the code has changed, but there is still an issue with this functionality in JRuby 1.7.

      At the time, in 1.4, it was causing a problem with Active Record connection caching whereby connections were being closed by other threads while still in use because the thread list was incorrect. It only happened under heavy stress. The active record code is still using this functionality but I have not confirmed if the issue is still happening or not. See function clear_stale_cached_connections! (line 196) in jruby-1.7.0.preview1\lib\ruby\gems\shared\gems\activerecord-3.2.3\lib\active_record\connection_adapters\abstract\connection_pool.rb.

      Another related ticket is JRUBY-2380.

      I am attaching a patch which fixes the issue in my test application.

      Thanks,
      Simon

      1. test.rb
        0.5 kB
        Simon Smith
      2. thread_list_race.patch
        1 kB
        Simon Smith

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        Sorry for that other bug getting completely missed! Unfortunately the number of issues reported exceeds our ability to even review them.

        I'll look at getting this patch in. Thank you!

        Show
        Charles Oliver Nutter added a comment - Sorry for that other bug getting completely missed! Unfortunately the number of issues reported exceeds our ability to even review them. I'll look at getting this patch in. Thank you!
        Hide
        Charles Oliver Nutter added a comment -

        Sorry this one took so many years to fix

        commit 88885dae63b79e80ffcf537489bca96ae2f04154
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Thu Jun 28 14:27:10 2012 -0500
        
            Regression spec for JRUBY-6748.
        
        commit 30b7cb693840ec0dfa09c87499f08a7ed0303d6e
        Author: simonjsmithuk <simonjsmithuk@yahoo.co.uk>
        Date:   Wed Jun 27 09:22:43 2012 -0500
        
            Added fix for Thread list race condition
            
            Signed-off-by: Charles Oliver Nutter <headius@headius.com>
            
            For JRUBY-6748.
        
        Show
        Charles Oliver Nutter added a comment - Sorry this one took so many years to fix commit 88885dae63b79e80ffcf537489bca96ae2f04154 Author: Charles Oliver Nutter <headius@headius.com> Date: Thu Jun 28 14:27:10 2012 -0500 Regression spec for JRUBY-6748. commit 30b7cb693840ec0dfa09c87499f08a7ed0303d6e Author: simonjsmithuk <simonjsmithuk@yahoo.co.uk> Date: Wed Jun 27 09:22:43 2012 -0500 Added fix for Thread list race condition Signed-off-by: Charles Oliver Nutter <headius@headius.com> For JRUBY-6748.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Simon Smith
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: