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

Filtered replication does not work when a target document is purged

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.0.1, 1.1
    • None
    • Replication
    • OS X Lion:

      {"couchdb":"Welcome","version":"1.1.0"}

      (brew installation)
      Ubuntu 11.04

      {"couchdb":"Welcome","version":"1.0.1"}

    Description

      When a document with an id is deleted and purged, and a replication process tries to create a document with that id, it does not happen. The replication without the filter works. Ruby test script:

      require 'rubygems'
      require 'couchrest'

      1. setup
        server = CouchRest.new("http://localhost:5984")
        a = server.database('a')
        b = server.database('b')
        a.recreate!
        b.recreate!
      1. Add a document doc1 to database a and b
        a.save_doc("_id" => 'doc1')
        b_doc1 = b.save_doc("_id" => 'doc1')
      1. Delete and purge doc1 from b
        b.delete_doc("_id" => 'doc1', "_rev" => b_doc1['rev'])
        RestClient.post(File.join(b.root, '_purge'), {'doc1' => [b_doc1['rev']]}

        .to_json, :content_type => :json )

      1. Add design with filter
        design = a.save_doc("_id" => "_design/temp", "filters" => {"test" => %|function(doc, req){if(['doc1'].indexOf(doc['_id']) >= 0) {return true;}

        {return false;}}|})

      1. Replicate and wait for finish
        RestClient.post("http://localhost:5984/_replicate", {:source => a.root, :filter => "temp/test", :target => b.root}.to_json, :content_type => :json)
        sleep(0.01) while JSON.parse(RestClient.get("http://localhost:5984/_active_tasks")).size > 0

      abort "oops" unless b.all_docs['total_rows'] == 1

      puts "Test successful"

      Attachments

        1. passing_replication.log
          3 kB
          Benjamin ter Kuile
        2. failing_replication.log
          3 kB
          Benjamin ter Kuile

        Activity

          People

            Unassigned Unassigned
            bterkuile Benjamin ter Kuile
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: