Uploaded image for project: 'Subversion'
  1. Subversion
  2. SVN-3512

ruby bindings: too many open files error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • all
    • 1.6.15
    • unknown

    Description

      Depending on the OS limit on the number of open files and the number of added,
      changed files in a commit, you can get the error below:
      
      <pre>
      Svn::Error::SvnError:
      /build/buildd-subversion_1.5.1dfsg1-4-i386-guV4hI/subversion-1.5.1dfsg1/subversion/libsvn_subr/io.c:2626
      Can't open file '/opt/breakout/svn/12ksourcetools/db/revs/0/2': Too many open files
      	from /usr/lib/ruby/1.8/svn/util.rb:86:in `svn_fs_file_contents'
      	from /usr/lib/ruby/1.8/svn/util.rb:86:in `file_contents'
      	from /usr/lib/ruby/1.8/svn/fs.rb:365:in `file_contents'
      	from /usr/lib/ruby/1.8/svn/fs.rb:611:in `dump_contents'
      	from /usr/lib/ruby/1.8/svn/fs.rb:587:in `files'
      	from /usr/lib/ruby/1.8/svn/fs.rb:594:in `diff'
      	from /usr/lib/ruby/1.8/svn/fs.rb:599:in `unified'
      </pre>
      If you want to reproduce, under Linux, do `ulimit -n N`; add more than N files,
      commit; then do: Svn::Info.new(path_to_repo, rev)
      
      Tested with 1.5.1. I think 1.6 is also buggy.
      
      See
      subversion/bindings/swig/ruby/svn/fs.rb:file and fs.rb:dump_contents methods.
      
      The `dump_contents` method will not close the tempfile if root is not set.
      
      Workaround - close tempfile{1, 2} in the files method:
      
      <pre>
      class Svn::Fs::FileDiff
        def files
          if @tempfile1
            [@tempfile1, @tempfile2]
          else
            @tempfile1 = Tempfile.new("svn_fs")
            @tempfile2 = Tempfile.new("svn_fs")
            
            begin
              dump_contents(@tempfile1, @root1, @path1)
              dump_contents(@tempfile2, @root2, @path2)
            ensure
              @tempfile1.close
              @tempfile2.close
            end
            [@tempfile1, @tempfile2]
          end
        end
        
        def dump_contents(tempfile, root, path)
          if root and path
            root.file_contents(path) do |stream|
              tempfile.print(stream.read)
            end
          end
        end
      end
      </pre>
      

      Original issue reported by vzdor

      Attachments

        Activity

          People

            Unassigned Unassigned
            subversion-importer Subversion Importer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: