MB-8869 Use atomic queue to push notifications for TAP producers

We saw the frontend ops/sec performance regression from the
previous fix to the OBSERVE replication latency issue. To address
this issue, this change uses the atomic queue to push
notification events for TAP producers, and schedules the
daemon task to grab those events and notify them to the
corresponding TAP producers.

Change-Id: I4bda29d50d446c338cff78014f20f2cef9f7bd64
Reviewed-on: http://review.couchbase.org/28464
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-8930 Stat for max number of bg fetches in the queue seen so far

Change-Id: Ice13a5cccf538b01350ef538d5d09fc6215d1760
Reviewed-on: http://review.couchbase.org/28490
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-100 Fix compilation on gcc 4.8.

Here's the error it produces:

src/atomic.hh: In instantiation of 'void ThreadLocalPtr<T>::operator=(T*) [with T = AtomicPtr<std::queue<SingleThreadedRCPtr<TapConnection>, std::deque<SingleThreadedRCPtr<TapConnection>, std::allocator<SingleThreadedRCPtr<TapConnection> > > > >]':
src/atomic.hh:606:21:   required from 'AtomicPtr<std::queue<T> >* AtomicQueue<T>::initialize() [with T = SingleThreadedRCPtr<TapConnection>]'
src/atomic.hh:613:31:   required from 'std::queue<T>* AtomicQueue<T>::swapQueue(std::queue<T>*) [with T = SingleThreadedRCPtr<TapConnection>]'
src/atomic.hh:514:38:   required from 'void AtomicQueue<T>::push(T&) [with T = SingleThreadedRCPtr<TapConnection>]'
src/tapconnmap.cc:286:45:   required from here
src/atomic.hh:91:21: error: 'set' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
         set(newValue);
                     ^
src/atomic.hh:91:21: note: declarations in dependent base 'ThreadLocal<AtomicPtr<std::queue<SingleThreadedRCPtr<TapConnection>, std::deque<SingleThreadedRCPtr<TapConnection>, std::allocator<SingleThreadedRCPtr<TapConnection> > > > >*>' are not found by unqualified lookup
src/atomic.hh:91:21: note: use 'this->set' instead

Change-Id: Ia4dbc0026f954c7f5d799903261abc239b8da6e4
Reviewed-on: http://review.couchbase.org/28523
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-8955 Prevent ExTask starvation: order by taskId

Change-Id: Ib75d92a1e64ca85843e688ebe23579841c23f4d7
Reviewed-on: http://review.couchbase.org/28550
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-8960 New operational stats for setWithMeta ops

1) ep_num_ops_get_meta_on_set_meta
 Number of get_meta ops spawn due to set_with_meta operations

2) set_with_meta
 Latency timing histogram for set_with_meta operations

Change-Id: I75a22c1ffd479da8a0bdad8a1881b93896a32235
Reviewed-on: http://review.couchbase.org/28588
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-8992: Unlock a locked key when deleting with the proper cas

Change-Id: I057c290c40301fb4cd8667d7752abf2cfd778690
Reviewed-on: http://review.couchbase.org/28645
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-8530 Non-blocking checkpoint stats call for all vbuckets

We saw that the timings of checkpoint stats call for all vbuckets
was ranged from 16ms to 262ms, which seems quite high. These
checkpoint stats are frequently requested by the cluster manager
during cluster rebalance. This change supports the non-blocking
checkpoint stats call for all vbuckets, so that the worker threads
can process other requests while the stats call is being processed
by the NON-IO dispatcher.

Change-Id: Ie472597c31aa13db1d9ae49855fb29a91314857d
Reviewed-on: http://review.couchbase.org/28554
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-9015 Return the items CAS value from touch

Change-Id: Ie9a5d3f8a520c7f7553cfa990270b1464534ce78
Reviewed-on: http://review.couchbase.org/28569
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
MB-9000 Retry open_db operation with the create option.

When an open_db operation without a create option fails
with FILE_NOT_FOUND error constantly, we should open a database
file with a create option to support subsequent read / write
operations.

Change-Id: I30dac3f0d7dda1c32c99bdebb4a99aef09c8a577
Reviewed-on: http://review.couchbase.org/28717
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
MB-9044: fixup check for stats.json existence

Change-Id: I1a02ed27eda5d2bd46a3b7431952c45d3c2dc0ef
Reviewed-on: http://review.couchbase.org/28784
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Merge branch '2.1.1' of ssh://review.couchbase.org:29418/ep-engine into cbd1038