MB-5026 fix: remove duplicate items
MB-5026 fix: remove duplicate items

After sorting the array of queued items within optimizeWrites(),
scan and remove duplicate items by key from the array. Otherwise
this could result in an assert while ep engine attempting to set
the new item id twice.

Change-Id: I42cd021b7eabcf8970ad0990d1400a757edcea86
Reviewed-on: http://review.couchbase.org/14831
Reviewed-by: Chiyoung Seo <8b279095f11c26cc21045fda5a3e51debb005aa9@gmail.com>
Tested-by: Chiyoung Seo <8b279095f11c26cc21045fda5a3e51debb005aa9@gmail.com>

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