3
votes

I have a view similar to this (a contrived example):

function(doc) {
if (doc.attrib) { emit([doc.attrib],doc._id) }
}

Everything works as expected until the data is deleted. I get this crazy scenario where there is no data in the actual database (confirmed via _all_docs and _changes run on curl as well as all_documents on Futon). However the view still yields data (again on both curl and Futon).

The delete comprises Bulk delete and purge operations via ektorp. Running _changes after each confirms these work as expected. re-creating the view makes it reflect the true state of the documents in the DB.

Have I missed something obvious here or are views in CouchDB only incremental?

1
I cannot reproduce it, can you give more details? Can you reproduce it using curl and post the exact sequence of commands used? - Marcello Nuccio
There is always the "debugging as a service" option. Get a free Cloud CouchDB account, trigger your error on it, and then blame them for the problem. They will race to either (1) fix their bug, or (2) prove to you exactly why it is not their fault by showing you your bug! - JasonSmith

1 Answers

3
votes

Did you really _purge the data? That should invalidate the view and cause a full rebuild. I'll note that _purge is not recommended for normal use. It exists only for accidents like putting your plaintext password in a document.

You may have exposed a bug in _purge, though, so if you can reliably induce this with _purge but not if you just delete, I encourage you to file a ticket on our JIRA (https://issues.apache.org/jira/browse/COUCHDB).

I'll note also that the fix will be to blow away the index if you purge, there is no incremental approach possible (you are literally removing the information that an incremental approach requires).