MB-9864: Reset access log if less then header size

sometimes an incomplete write can result in access
log header being less than header size.
Do not throw Short Read exception, rather
simply recovery by removing and recreating the access log
Change-Id: I8d1250eb1e78dd71f57b7a30ed8d90defedde446
Reviewed-on: http://review.couchbase.org/31803
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Reviewed-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Tested-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
MB-9693: Re-map enoent to not my vbucket for failed bg fetch

If a VBucket is deleted in the middle of a background fetch then
the result of the disk read is an enoent. When processing this
error we need to check to see if the VBucket is still valid and
also that it is in active state before returning enoent. If it's
not then we should re-map the return code to not my vbucket since
this is much more descriptive of the actual cause of the operation
failure.

Change-Id: I1131b9657a2ee7ca7990416afcd483cd9f54c4e0
Reviewed-on: http://review.couchbase.org/31832
Reviewed-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Reviewed-by: Junyi Xie <junyi.couchbase@gmail.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
MB-9693 Don't evict a temp item whose state is in TEMP_INIT.

If a temp item's state is TEMP_INIT, it means that we spawned a
background fetch to figure out if an item was deleted before or
never exists before. If we allow the item pager to remove this
temp item, getMeta() request can't be processed correctly and will
return an incorrect status to the client.

Change-Id: I1b025c09d22660d70dea22cb92ae728a0bb8709e
Reviewed-on: http://review.couchbase.org/32470
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9693 Check the vbucket existence only upon a bg fetch completion

As there is always a race in vbucket state changes, we should check
the vbucket existence only upon completing a bg fetch and then let
a memcached worker thread visit the vbucket again to complete GET
request.

Change-Id: I9cdc76897c5e18f4c02a75606ec75a3f4dcee063
Reviewed-on: http://review.couchbase.org/32471
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9693 Return ENGINE_SUCCESS if an item is updated during bg fetch

If an item (that might not exist before) is inserted while we are
processing a bg fetch request for its metadata, we should not
return any error codes, but instead ENGNINE_SUCCESS, so that the
memcached worker thread can return that item's metadata to the
client.

Change-Id: I2f9749d422aef305764783d363d11f9921f186dd
Reviewed-on: http://review.couchbase.org/32472
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9938 Fix to the deadlock in doing the bg fetch job.

Change-Id: Ia4cf7a98441812b0e703308bf04125026c4fd7e5
Reviewed-on: http://review.couchbase.org/32561
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9800 Always respond to CHECKPOINT_PERSISTENCE through flusher

Even if a requested checkpoint is already persisted, let the
flusher respond to CHECKPOINT_PERSISTENCE command to prevent any
race conditions between the database storage engine and
view indexer.

Change-Id: I26a4d77d97c4c1d93957621f746e09bee2e2ebb4
Reviewed-on: http://review.couchbase.org/32610
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
[BP] MB-9692 Handle MutationLog lseek errors gracefully

Instead of asserting throw appropriate exception with logs.

Change-Id: Ib64b5bea506e2524cada118287e9e2d300b970e0
Reviewed-on: http://review.couchbase.org/32697
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9953 Correct a rev_seqno type to uint64_t

Change-Id: I46afadda87a83bf5f1b01dcb007b2a0feb6a7e27
Reviewed-on: http://review.couchbase.org/32775
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9953 Replace the old queued_item instance with the new one.

When a new mutation arrives into a checkpoint, we should replace
the old queued_item instance with a new instance for the same
key. Otherwise, some fields won't be correctly updated (e.g.,
rev_seqno is not updated correctly).

Change-Id: I9d7c67be675c2297c84e253c47941149dd76d406
Reviewed-on: http://review.couchbase.org/32816
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Reviewed-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Tested-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Merge remote-tracking branch 'couchbase/2.5.0'

Conflicts:
	src/ep.cc
	src/ep_engine.cc
	src/item.hh
	src/item_pager.cc
	src/mutation_log.cc

Change-Id: Ia752297856141b9ddfb6c5955cc5865125d85210