MB-4195 Free an item if prepend/append failed due to CAS mismatches
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 <ef850f73f7832052d3c6d9b5ddd3a1716d9a57f1@gmail.com>
Tested-by: Farshid Ghods <e312e45b3dfe8923eeb42f1475810bf7c59ba895@gmail.com>
Reviewed-by: Farshid Ghods <e312e45b3dfe8923eeb42f1475810bf7c59ba895@gmail.com>

jimwwalker/ep-engine,teligent-ru/ep-engine,teligent-ru/ep-engine,hisundar/ep-engine,sriganes/ep-engine,couchbaselabs/ep-engine,sriganes/ep-engine,couchbaselabs/ep-engine,jimwwalker/ep-engine,abhinavdangeti/ep-engine,abhinavdangeti/ep-engine,membase/ep-engine,hisundar/ep-engine,daverigby/ep-engine,couchbase/ep-engine,zbase/ep-engine,daverigby/ep-engine,teligent-ru/ep-engine,daverigby/ep-engine,zbase/ep-engine,zbase/ep-engine,abhinavdangeti/ep-engine,daverigby/kv_engine,abhinavdangeti/ep-engine,membase/ep-engine,sriganes/ep-engine,daverigby/kv_engine,hisundar/ep-engine,abhinavdangeti/ep-engine,zbase/ep-engine,couchbase/ep-engine,daverigby/kv_engine,owendCB/ep-engine,teligent-ru/ep-engine,owendCB/ep-engine,couchbaselabs/ep-engine,couchbaselabs/ep-engine,daverigby/ep-engine,daverigby/kv_engine,jimwwalker/ep-engine,hisundar/ep-engine,sriganes/ep-engine,couchbase/ep-engine,owendCB/ep-engine,couchbaselabs/ep-engine,zbase/ep-engine,jimwwalker/ep-engine,couchbase/ep-engine,membase/ep-engine,membase/ep-engine,owendCB/ep-engine