Maintain a cursor's offset in a consistent way.

This change makes sure that a cursor's offset includes checkpoint
meta items (e.g., checkpoint_start, checkpoint_end).
However, when we calculate the number of items remaining for
persistence or replication, we should not consider those meta
items.

Change-Id: I8a90c347c163674decdb7ed1b5eb824a5b9d4f86
Reviewed-on: http://review.couchbase.org/39298
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-11553 Adjust the checkpoint creation interval.

This change reduces the checkpoint creation interval to
mitigate the memory overhead caused by having blob instances
inside the open checkpoint. If a checkpoint creation interval
is large, it can cause significant memory overhead due to blob
instances inside the current open checkpoint.

Note that we also limit the number of checkpoints in memory, so
this change won't allow us to keep creating a new checkpoint if
the limit is reached.

Change-Id: I33119ef8b539d5f0209b64bcfcfcbd82632ae7e1
Reviewed-on: http://review.couchbase.org/39333
Reviewed-by: Sundararaman Sridharan <sundar@couchbase.com>
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-11661 Don't check the checkpoint manager upon ejecting an item

As a checkpoint has blob instances inside, we don't need to check
the checkpoint manager to see if we can eject an item from the
hash table.

Change-Id: I57fc887dc80b88ba275bc50ef7b7f8a5ff45e8c7
Reviewed-on: http://review.couchbase.org/39334
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-11661 Remove unreferenced closed checkpoints by item pager.

This change allows the item pager to remove unreferenced closed
checkpoints, so that it can free some memory before attempting to
eject items from the vbucket hash table. In this way, we can
avoid ejecting innocent (frequently accessed) items from hashtable.

Change-Id: I1ec971ce6de348f4320679f18d844c3ac548345d
Reviewed-on: http://review.couchbase.org/39335
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-11661 Move cursor to the next checkpoint if reached to the end

If a cursor is already reached to the end of its current
checkpoint, then the cursor can be moved to the next checkpoint.
In this way, a checkpoint can be immediately freed from memory
if the checkpoint doesn't have any cursors.

Change-Id: I378d0e2527610d7ad7773ebd35e3814d31bb7777
Reviewed-on: http://review.couchbase.org/39339
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-11661 Disable checkpoint merge support by default.

Merging closed checkpoints in a replica vbucket was mainly
supported to reduce the memory overhead in the replica vbucket,
which performs the replication to another replica vbucket.
For example, in the replication chain A->B->C, merging closed
checkpoints can be performed on the replica B if the replica C
is overloaded and constantly backs off the replication from the
replica B.

As of 3.0, we switch to the star replication, which doesn't
require supporting checkpoint merge operation. Thus, this change
disables the checkpoint merge operation by default, but still
allows us to enable / disable it dynamically at runtime.

Change-Id: I46b17030f35a5dad9575a6ecd2fde33f70b497bc
Reviewed-on: http://review.couchbase.org/39342
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-11592: Use a queue_item in a MutationResponse instead of and Item

This will allow us to pull queued_items out of the CheckpointManager
and into and ActiveStream without adding any memory overhead. This
also simplified the cleanup of a MutationResponse because we no
longer need to seperately delete the item contained inside this
class.

Change-Id: I0fc67ac66da6bd0c0ad0cd0369ee0a377d2b3bd9
MB-11592: Create snapshots when getting items from the chk queues

Change-Id: I8a262eb7856c97e11e95570fbdaef82f3f79054a
WIP

Change-Id: I3ce59aedae2493c88051af2c16195a24984ee2a8