Added new stat call to dump tcmalloc internal state.

Change-Id: Ide0d89fe43507d928ac392736947711ebb7895a1
Reviewed-on: http://review.couchbase.org/15590
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Reviewed-on: http://review.couchbase.org/15833
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Refactor and simplify  TapProducer::scheduleBackfill().

If a given vbucket is currently receiving backfill from its master
node or has been already scheduled for backfill to its replica
node, we don't need to schedule the backfill for that vbucket.

Change-Id: Id34e62518143d97072be1340e304c8dc7c3df89a
Reviewed-on: http://review.couchbase.org/15657
Reviewed-by: Liang Guo <liang@couchbase.com>
Reviewed-by: Jin Lim <jin@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-on: http://review.couchbase.org/15834
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-5193 Remove invalid vbuckets from cursors and backfill list

If a given vbucket doesn't belong to the given TAP producer,
simply remove that vbucket from replication cursors and backfill
list.

Change-Id: I4ee95397f5bd452c06db1e6fb4d5771dd4c55a1c
Reviewed-on: http://review.couchbase.org/15667
Reviewed-by: Jin Lim <jin@couchbase.com>
Reviewed-by: Liang Guo <liang@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-on: http://review.couchbase.org/15835
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-5208 Get rowid from hash table upon requeueing TAP BG fetch

Change-Id: Iac4b6174bef9a6e0c5610c498c3127486206a557
Reviewed-on: http://review.couchbase.org/15685
Reviewed-by: Jin Lim <jin@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-on: http://review.couchbase.org/15836
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-5208 Replicate TAP_DELETE event if BG fetched item is deleted

When the TAP bg fetched item is deleted from hash table, we just
need to send TAP_DELETE event to the destination.

Change-Id: I8464f1553c13b4ae54374d6d044dba50b6117cc0
Reviewed-on: http://review.couchbase.org/15686
Reviewed-by: Jin Lim <jin@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-on: http://review.couchbase.org/15837
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-5208 Process the TAP BG fetch failures correctly

TAP BG fetch failures should be separated from the success cases
and should be logged with more information.

Change-Id: I47faea15c694166b7e338daff27b09afbd798c1c
Reviewed-on: http://review.couchbase.org/15695
Reviewed-by: Jin Lim <jin@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-on: http://review.couchbase.org/15838
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Simplify the assertion check in TapProducer::queueBGFetch()

Change-Id: I914d3d8bece3d5471d02b8d04804c0dbdb85b3f8
Reviewed-on: http://review.couchbase.org/15729
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-on: http://review.couchbase.org/15839
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-5208 Replace TAP_MUTATION with TAP_DELETE if an item is deleted

If an TAP item backfilled from disk is deleted in hash table or
or expired, TAP_MUTATION event should be replaced with TAP_DELETE
and then replicated.

Change-Id: I8dbd650418267457efc098a1e45d1c88c9a5e41d
Reviewed-on: http://review.couchbase.org/15772
Reviewed-by: Jin Lim <jin@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-on: http://review.couchbase.org/15840
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Remove fragmentation from mem_used stat

After extensive tests, we decided to not consider the
allocator's fragmentation overhead (mostly from the central
cache in tcmalloc) in the engine's mem_used stat at this time.
It turns out that including fragmentation overhead caused quite
heavy (possibly unnecessary) item evictions. We will revisit
this issue later.

Change-Id: Ib4658cf10e3954c73fffdd2d248354ab7635562b
Reviewed-on: http://review.couchbase.org/15827
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-on: http://review.couchbase.org/15841
Merge branch 'branch-18'

* branch-18:
  Remove fragmentation from mem_used stat
  MB-5208 Replace TAP_MUTATION with TAP_DELETE if an item is deleted
  Simplify the assertion check in TapProducer::queueBGFetch()
  MB-5208 Process the TAP BG fetch failures correctly
  MB-5208 Replicate TAP_DELETE event if BG fetched item is deleted
  MB-5208 Get rowid from hash table upon requeueing TAP BG fetch
  MB-5193 Remove invalid vbuckets from cursors and backfill list
  Refactor and simplify  TapProducer::scheduleBackfill().
  Added new stat call to dump tcmalloc internal state.

Change-Id: I90cc3fa269d191a4edd96774a70689305f9b795d