Filtered replication does not work when a target document is purged
-------------------------------------------------------------------
Key: COUCHDB-1347
URL: https://issues.apache.org/jira/browse/COUCHDB-1347
Project: CouchDB
Issue Type: Bug
Components: Replication
Affects Versions: 1.1, 1.0.1
Environment: OS X Lion: {"couchdb":"Welcome","version":"1.1.0"} (brew
installation)
Ubuntu 11.04 {"couchdb":"Welcome","version":"1.0.1"}
Reporter: Benjamin ter Kuile
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'
# setup
server = CouchRest.new("http://localhost:5984")
a = server.database('a')
b = server.database('b')
a.recreate!
b.recreate!
# Add a document doc1 to database a and b
a.save_doc("_id" => 'doc1')
b_doc1 = b.save_doc("_id" => 'doc1')
# 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 )
# 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;}}|})
# 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"
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira