Permalink
Browse files

MB-4195 Free an item if prepend/append failed due to CAS mismatches

An item should be freed if prepend or append operation failed
because CAS values are mismatched or the item is already locked.
Otherwise this will incur huge memory leak if client applications
perform lots of set/prepend/append operations with multiple threads.

Change-Id: Ibdd3d2b537bf527068d3a11d555c9128f99d3371
Reviewed-on: http://review.couchbase.org/8965
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Farshid Ghods <farshid.ghods@gmail.com>
Reviewed-by: Farshid Ghods <farshid.ghods@gmail.com>
  • Loading branch information...
1 parent 7ff2de1 commit 46483918fdb80fc622702fd47c55ce5f7ed29f81 @chiyoung chiyoung committed with farshidce Aug 15, 2011
Showing with 2 additions and 0 deletions.
  1. +2 −0 ep_engine.cc
View
@@ -1630,10 +1630,12 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::store(const void *cookie,
if (old->getCas() == (uint64_t) -1) {
// item is locked against updates
+ itemRelease(cookie, i);
return ENGINE_TMPFAIL;
}
if (it->getCas() != 0 && old->getCas() != it->getCas()) {
+ itemRelease(cookie, i);
return ENGINE_KEY_EEXISTS;
}

0 comments on commit 4648391

Please sign in to comment.