Fix memory leak when queueing messages in a PassiveStream

Upr mutations, deletions, and expirations contain and Item and we
need to make sure they get freed if a stream is dead.

Change-Id: I504b326e3af2ca5493df54c205feacaa9a97c9f5
Reviewed-on: http://review.couchbase.org/38333
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
MB-11405 optimize by avoiding string constructions

getDescription() overhead in performance is seen in profile
reports when large number of active buckets come into picture
Avoid constructing strings in it to optimize CPU

Change-Id: Ic2d1e875eba51a9dff3a2530ca4d3b0ffe5d1e0d
Reviewed-on: http://review.couchbase.org/38337
Tested-by: Sundararaman Sridharan <sundar@couchbase.com>
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Check upr expiration when checking that seqno's increase

Change-Id: Idc5d1598e6c1221927b0a4eff8ef5651b95d7f1a
Reviewed-on: http://review.couchbase.org/38336
Reviewed-by: Sundararaman Sridharan <sundar@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Fix indentation in tasks.h

Change-Id: I5cba82df5d3e04a13022d6fab3849e677dbe7a2c
Reviewed-on: http://review.couchbase.org/38340
Reviewed-by: Sundararaman Sridharan <sundar@couchbase.com>
Tested-by: abhinav dangeti <abhinav@couchbase.com>
Implement upr expiration command

We don't support doing anything different than a deletion within
the enigne yet so whenever we see and expiration we should just
treat it as a deletion.

Change-Id: I709ba05e7cdfa1800a62d0a54143c991e8787f96
Reviewed-on: http://review.couchbase.org/38338
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Account for UPR_EXPIRATION in upr-producer's getNextItem()

Change-Id: Ib31c01617398c35ebbce56784835af8a49b7e260
Reviewed-on: http://review.couchbase.org/38345
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: abhinav dangeti <abhinav@couchbase.com>
MB-11376: Don't rollback if snap_start == start == upper

We shouldn't tell a client to rollback to the same seqno that it
request.

Change-Id: If6c9bd438e2a70f637ff8bcb28bc46258d28b10c
Reviewed-on: http://review.couchbase.org/38344
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
MB-11421: Supports ack should be false for upr connections

Upr doesn't support ack/nack logic.

Change-Id: I5ba3d1cf323f527ce59ed2d8dd901566f3bcd1f5
Reviewed-on: http://review.couchbase.org/38347
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Reviewed-by: Sundararaman Sridharan <sundar@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
MB-11297: Ensure lastSentSeqno < endSeqno

As we send the complete snap shot, it can so
happen that lastSentSeqno be greater than endSeqno
for an active stream, causing an underflow in
stats collection.
Change-Id: I8a8f0755f988c8c1ef9046020a4702775d2ddd4c
Reviewed-on: http://review.couchbase.org/38353
Reviewed-by: Sundararaman Sridharan <sundar@couchbase.com>
Tested-by: Sundararaman Sridharan <sundar@couchbase.com>
Add brackets to if statement in ActiveStream

Change-Id: I1b251767fe35c74c265fd742033da4c7b1c97866
Reviewed-on: http://review.couchbase.org/38354
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Tested-by: abhinav dangeti <abhinav@couchbase.com>
MB-11263: Add retry logic for temporarily failed mutations

Processing a mutation on the consumer side can fail due to temporary out of memory
conditions. In that case, we just need to return from the failure and re-process
the failed message in the next iteration.

Change-Id: Idd50fa66d7288db9e25db837a19d2bdd0057437f
Reviewed-on: http://review.couchbase.org/37999
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Sriram Ganesan <sriram@couchbase.com>
Add memory-related stats to the memory-stat cmd

Change-Id: I95e419d6dc3429a63fa7f50fa5b744a7b2d7f34e
Reviewed-on: http://review.couchbase.org/38319
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Add support for custom unit test directory

/tmp/test being hard-coded into ep_testsuite.cc makes it
hard to have unit tests run on ramdisks. This change allows
the unit test suite to be pointed to a dir in ramdisk.

Change-Id: I2e428ed6fe1a38513db27a70aa7a1c36bbe90c6f
Reviewed-on: http://review.couchbase.org/38379
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Tested-by: Sundararaman Sridharan <sundar@couchbase.com>
Enable flow control for intra-cluster replication by default

We have fixed all know issues and run a bunch of tests to ensure
that this is now working. As a result we will turn flow control
back on by default.

Change-Id: Ib3a498b9798eb7eccf03722464a220dd3f7da828
Reviewed-on: http://review.couchbase.org/38367
Reviewed-by: Sriram Ganesan <sriram@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
MB-11447: Don't close db handle if rollback header fails

This happens automatically in couchstore and will cause a segfault
if we try to close the handle again.

Change-Id: I4e0f756749951ac869861fc150303b9df594ca65
Reviewed-on: http://review.couchbase.org/38377
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
MB-11361: Implement upr noop command

The upr noop command is used to detect dead connections. It is sent
once every 3 minutes and waits 3 minutes for a response. If no
response comes in that time the connection is deemed to be dead. The
noop command is only sent when flow control is turned on by the
consumer.

Change-Id: Ib6f1eb51810d9c641ca52d1e3cda8ae9ffa3684c
Reviewed-on: http://review.couchbase.org/38355
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Revert "MB-11361: Implement upr noop command"

We will add this back once some of the other components fix
issues that were caused by this patch.

This reverts commit e2e75cb16b1e5bf715e9437a55580df46a72a011.

Change-Id: I46c1d14ac60044f6a6b34f2fcd08f615eefe219b
Reviewed-on: http://review.couchbase.org/38438
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
MB-11477: Fix crash in process items due to no default argument

Change-Id: I4932ce2094273ce1e877bea70c8e279e232d35f2
Reviewed-on: http://review.couchbase.org/38451
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Reviewed-by: Sriram Ganesan <sriram@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
MB-11407: Add logs to the UPR consumer rollback code

On the UPR consumer side, there aren't enough logs to indicate
if a rollback has been processed or not.

Change-Id: I5df76097db803e4ed75915a92058f109f526dc16
Reviewed-on: http://review.couchbase.org/38456
Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Sriram Ganesan <sriram@couchbase.com>
CMake: Search project include dirs before /usr/local/include

This ensures that if /usr/local/include has outdated header files
(e.g. you previously compiled and installed CB 2.5.1), then the build
of master doesn't fail due to it picking up outdated header files.

Change-Id: I9c4d7987adebb0780d3a0b08f27b666af128708d
Reviewed-on: http://review.couchbase.org/38361
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Dave Rigby <daver@couchbase.com>