Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-325

Memory Leak in 9.0?

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.9
    • 0.9
    • None
    • None
    • gentoo linux on c1.medium aws instance

    Description

      I am using couchrest to transform a document from one database to another (millions of records). The memory usage continues to increase till all the memory is used. The process occasionally fails, but usually completes. I dont know enough about ruby/couchrest/couchdb to be able to tell you where the memory is increasing from - but if you give me some direction, I will be happy to take a look.

      If I comment out the save, it seems ok.

      Here is the code:

      --------------------------------

      require 'rubygems'
      require 'couchrest'

      @db = CouchRest.database!("http://127.0.0.1:5984/xfpds_2008")
      @db2 = CouchRest.database!("http://127.0.0.1:5984/fpds_2008")

      @streamer = CouchRest::Streamer.new(@db)
      @streamer.view("_all_docs") do |row|
      begin

      doc = @db.get(row["id"])

      1. remove id so the new database gets fresh document
        doc.delete("_id")
        doc.delete("_rev")
      1. change badgerfish notation to assign $ key value to parent
        doc["amounts"]["obligatedAmount"] = doc["amounts"]["obligatedAmount"]["$"]
        doc["amounts"]["baseAndAllOptionsValue"] = doc["amounts"]["baseAndAllOptionsValue"]["$"]
        doc["amounts"]["baseAndExercisedOptionsValue"] = doc["amounts"]["baseAndExercisedOptionsValue"]["$"]

      ...... A whole bunch of fields

      1. save the document using bulk save
        response = @db2.save_doc(doc,true)

      rescue

      1. if streamer ends, save last few documents
        @db2.bulk_save
        end

      end

      Attachments

        Activity

          People

            Unassigned Unassigned
            ramarnat Rohit Amarnath
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: