Permalink
Browse files

MB-6806 release returned document that is being marked deleted

couchstore_open_doc_with_docinfo can still return a document that
is being marked deleted. CouchKVStore must ensure that it release
every single document upon the completion of couchstore_open_doc call

Change-Id: I0f5aa4a5fe42ca707829bc117db79077a44a75a8
Reviewed-on: http://review.couchbase.org/21396
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: buildbot <build@couchbase.com>
  • Loading branch information...
1 parent de36522 commit 3d545832ed84650e480855cf3abae6fef9fccf9d @jinlim jinlim committed with Farshid Ghods Oct 5, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/couch-kvstore/couch-kvstore.cc
@@ -1348,8 +1348,8 @@ couchstore_error_t CouchKVStore::fetchDoc(Db *db, DocInfo *docinfo,
errCode = couchstore_open_doc_with_docinfo(db, docinfo, &doc, DECOMPRESS_DOC_BODIES);
if (errCode == COUCHSTORE_SUCCESS) {
if (docinfo->deleted) {
- // cannot read a doc that is marked deleted, just return
- // document not found error code
+ // do not read a doc that is marked deleted, just return the
+ // error code as not found but still release the document body.
errCode = COUCHSTORE_ERROR_DOC_NOT_FOUND;
} else {
assert(doc && (doc->id.size <= UINT16_MAX));
@@ -1359,12 +1359,12 @@ couchstore_error_t CouchKVStore::fetchDoc(Db *db, DocInfo *docinfo,
itemFlags, (time_t)exptime, valuePtr, valuelen,
cas, -1, vbId);
docValue = GetValue(it);
- couchstore_free_document(doc);
// update ep-engine IO stats
++epStats.io_num_read;
epStats.io_read_bytes += docinfo->id.size + valuelen;
}
+ couchstore_free_document(doc);
}
}
return errCode;

0 comments on commit 3d54583

Please sign in to comment.