MB-9532 Find a new compacted file upon receiving a temp failure

When the flusher receives a temp failure from the mccouch, it
should check if a new compacted file exists or not before
re-writing dirty items. This is required especially when the
deletion of the old file fails due to some external issues.
Otherwise, the flusher will keep writing dirty items into the
old file and receiving a temp failure over and over.

Change-Id: Ifd91eea1acfe82f5ea43ff93ca650b7928844b33
Reviewed-on: http://review.couchbase.org/30301
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Reviewed-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Tested-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
MB-9203 Always reset the open checkpoint upon resetting a vbucket

When a replica vbucket is reset, its open checkpoint id is not
reset to zero when the vbucket has zero items. This causes a bug
in updating the persisted checkpoint id, which consequently
incurs the rebalance to be stuck.

This fix always resets the open checkpoint id of a replica
vbucket to zero upon resetting the vbucket.

Change-Id: If6b5e2ca9b37dd533818e8d3397ec2c695345295
Reviewed-on: http://review.couchbase.org/30302
Reviewed-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Tested-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
MB-9549 Fix to the memory leak in GetAndUpdateTTL

This is a regression from 2.2.0, which causes a memory leak
when we update the TTL for a non-resident item.

Change-Id: I3dfd9dcd09a0acfdcd2cd6623f75ca54916d1116
Reviewed-on: http://review.couchbase.org/30303
Reviewed-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Tested-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
MB-9311: Notify all the pending connections on vbucket delete

If a given vbucket is deleted, we should notify it to all of its
pending connections, so that the connections are released
immediately and the error messages should be sent to the clients.

Change-Id: Ic230a803f0b26944f98e84ed4d21f8d834e3a561
Reviewed-on: http://review.couchbase.org/30353
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Transition to CMake

Change-Id: I949c21c2420ad4bdd917dc14b1f1ea9c69d876a4
Reviewed-on: http://review.couchbase.org/29983
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Mutations and deletions must be for UPR Consumer

Change-Id: I8f4bd0d4a514ccf4906d63d56be416db79345f1f
Reviewed-on: http://review.couchbase.org/30457
Reviewed-by: David Liao <david.liao@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Fix compile errors from cmake move

Change-Id: I626835f4bbe4ba58cdd00ac9d2603bb445583479
Reviewed-on: http://review.couchbase.org/30476
Reviewed-by: David Liao <david.liao@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
MB-9618 Release engine handle before CCCP callback

As the memcached CCCP callback can allocate more memory for the
sending buffer, we should release the engine handle before
calling the callback function, so that we can maintain the
memory accounting correctly.
Change-Id: I2899f65acf3b40db9cd3cf7602e5bb4b874750bf
Reviewed-on: http://review.couchbase.org/30492
Reviewed-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Tested-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Merge remote-tracking branch 'couchbase/2.5.0'

Conflicts:
	src/ep.cc

Change-Id: I7dba83b535f62a13a519881559ec73d0982f0e85
MB-9631: Fixing inefficient getItemEstimate()

- Iterate only the selected vbuckets while fetching
the item estimate at a shard level.
- Parallelize the estimateItemCount phase at shard
level during the warmup process.

Change-Id: Iaa76dfc83df78395c3fc23a658732abeeeb9fb2c
Reviewed-on: http://review.couchbase.org/30482
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Tested-by: abhinav dangeti <abhinav@couchbase.com>
MB-9640: Add missing <limits>

The build slave failed with:
src/generated_configuration.cc: In member function ‘void Configuration::initialize()’:
src/generated_configuration.cc:466:42: error: ‘numeric_limits’ is not a member of ‘std’
src/generated_configuration.cc:466:68: error: expected primary-expression before ‘>’ token
src/generated_configuration.cc:466:69: error: ‘::max’ has not been declared
src/generated_configuration.cc:466:69: note: suggested alternative:

src/generated_configuration.cc:467:41: error: ‘numeric_limits’ is not a member of ‘std’
src/generated_configuration.cc:467:67: error: expected primary-expression before ‘>’ token
src/generated_configuration.cc:467:68: error: ‘::max’ has not been declared
src/generated_configuration.cc:467:68: note: suggested alternative:
/usr/include/c++/4.6/bits/stl_algobase.h:254:5: note:   ‘std::max’

It's fixed with including <limits>.

Change-Id: If5d74f0b5d9e575f46f49d4ad75d4179aa62b35d
Reviewed-on: http://review.couchbase.org/30625
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-9627: Add failover log to stream request response

Change-Id: Ia542e29ca5ea6717fce61cdaf493fa331c7e7ca0
Reviewed-on: http://review.couchbase.org/30489
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Remove some unixism

Change-Id: I85705cd5fdf969e333ac1dd4618f3d177cec2979
Reviewed-on: http://review.couchbase.org/30556
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Added "engine-tests" as a separate make target

Change-Id: I8aa04fdb5b61b10a2a986f688bc95a836ce23c41
Reviewed-on: http://review.couchbase.org/30653
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Added missing return statement

Change-Id: Ia7f65ec1fb58b2a067a8c7db3570c434597aef99
Reviewed-on: http://review.couchbase.org/30658
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Use "git describe" as VERSION

Change-Id: Ic4d7ed4e9fbbdf669cb6fec0a2864ef44d98635a
Reviewed-on: http://review.couchbase.org/30655
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Remove old autoconf files

Change-Id: I2707a3749a6b52903648fd6974884f78f8af70be
Reviewed-on: http://review.couchbase.org/30656
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Disable building of the generated tests

Change-Id: I7d936bd7a296aa45100ad6ddf7f4e698cedd9781
Reviewed-on: http://review.couchbase.org/30667
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Remove compiler warnings

src/couch-kvstore/couch-kvstore.cc:1389:15: warning: explicitly assigning a variable of type 'uint32_t'
      (aka 'unsigned int') to itself [-Wself-assign]
    itemFlags = itemFlags;

src/couch-kvstore/couch-kvstore.cc:1460:15: warning: explicitly assigning a variable of type 'uint32_t'
      (aka 'unsigned int') to itself [-Wself-assign]
    itemflags = itemflags;

src/couch-kvstore/couch-kvstore.h:249:12: warning: private field 'valuelen' is not used
      [-Wunused-private-field]
    size_t valuelen;

Change-Id: Iaec2830b82e2689f26d312c19bd1f4739d3d2b7a
Reviewed-on: http://review.couchbase.org/30668
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-9645: Workaround for broken c++ compilers

<unordered_map> should be part of C++11, but the clang 4.1.0
defines __cplusplus claiming it support it, but doesn't contain
the header..

Change-Id: I8503d1fdb996b393d9f40d1ef8821afbf6930ba0
Reviewed-on: http://review.couchbase.org/30665
Reviewed-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Tested-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>