MB-10776: build NS_SERVER_VERSION based on PRODUCT_VERSION if available

Change-Id: I9069a043d249fa97485cbaeb99c4ad351baf8ec5
Reviewed-on: http://review.couchbase.org/35421
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Chris Hillery <ceej@couchbase.com>
don't send zero-sized binaries to xdcr upr streamer consumer end

Because it's useless. And it's not that rare, particularly when full
upr packet is longer than tcp segment.

Change-Id: I2b44a63b488d04da3e74c8d4f81b2f4205d07e76
Reviewed-on: http://review.couchbase.org/35428
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Artem Stemkovski <artem@couchbase.com>
always immediately consume initial chunk of data from upr

It's possible that "leftover" from receiving initial response has upr
data and end stream message. In which case we'd enter socket loop
waiting for more data in order to process that leftover. But because
in this case leftover is all we would ever have we'd stuck.

The fix is to handle leftover as if we've just received it.

Change-Id: I57c0b7661595ecc23a702dbe156ebb1b7c0fb41b
Reviewed-on: http://review.couchbase.org/35429
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
MB-10785: Fix "make clean" when part of larger build

Change-Id: Iaece4266e06d3bc224658a6a53cd27bd80eea390
Reviewed-on: http://review.couchbase.org/35436
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Chris Hillery <ceej@couchbase.com>
Fix print statement.

Change-Id: Ie7f1f2b9f58d90aa005b7f59516a90abfe3e4d3f
Reviewed-on: http://review.couchbase.org/35472
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10740 Don't spawn epmd in cluster_run.

As far as I can tell, erlang is capable of doing this on its own.

Change-Id: I733a0c5e549803c235f79e998a61bf89c6d9261e
Reviewed-on: http://review.couchbase.org/35473
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10742 Don't use close_fds param on Windows.

Because it unsupported in conjunction with redirection of
stdin/stdout/stderr.

Change-Id: I56971de546c02ea00bfdeef10749a10e81cb2d31
Reviewed-on: http://review.couchbase.org/35474
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Gather ssl_proxy logs as part of diag.

Change-Id: I8408d6707c50db11a34fe28d849c7d48bef7dbfd
Reviewed-on: http://review.couchbase.org/35476
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10779 crash more informatively when receive wrong opaque

Change-Id: I8cdf6deeecfc6d9bc94faf4f441247e27ef25032
Reviewed-on: http://review.couchbase.org/35477
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10779 fix race during takeover

sometimes the response to ADD_STREAM(takeover) comes later than
both SET_VBUCKET_STATE responses. should block until both
ADD_STREAM and SET_VBUCKET_STATE responses arrive

Change-Id: I3e7d0b6c75edd41be2adbd9550db467ba6682ff5
Reviewed-on: http://review.couchbase.org/35478
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10742 Pass erlang environment flags through OS env variable.

Change-Id: I6020fb38221f24cf9900c8bcedd1cbb32e8ba07d
Reviewed-on: http://review.couchbase.org/35475
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Add all loaded applications environment vars to initargs file.

Change-Id: I104a5bc421d02524b7b2e17cf8f3e9b0e88ac6ba
Reviewed-on: http://review.couchbase.org/35504
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10807 Fix make test and make dialyzer.

Change-Id: I8c28b8cc2bf9d3ff0234d74fe2dc4b5e039db2de
Reviewed-on: http://review.couchbase.org/35520
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
don't detect json-ness of docs for xdcr-xmem

Because it's not affecting anything in xmem path so it's pure waste of
cycles.

Change-Id: Id72dc190da7d456aa83bf7b657d2ea05a7a45d46
Reviewed-on: http://review.couchbase.org/35273
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
replaced old "probabilistic" xdcr trace logging with log category

So that we can properly and reliably use this thing.

New log category has log level set to error by default. Causing all
log messages (logged with debug level) to not be logged.

When some specific issues needs to be investigated it's possible to
change log level at runtime to default.

E.g.:

wget -O- --post-data='ale:set_loglevel(xdcr_trace, debug).' \
   http://Administrator:asdasd@127.0.0.1:8091/diag/eval

Change-Id: I08aa3a3a3c72765af993de6e6047c11f7e8bdeca
Reviewed-on: http://review.couchbase.org/35275
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10457: added diagnostics for tracing xdcr data loss in ticket

It's not clear what is causing that data loss that's seen in
MB-10457. In order to investigate we need to log more.

Change-Id: I53d85dec34cbc488afc9dbb5ec944800f6e7ddee
Reviewed-on: http://review.couchbase.org/35276
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
avoid divide by 0 in compaction_daemon if there are no vbuckets

Change-Id: I6abe8155655264cfe247b8e4a1f403b7a746883b
Reviewed-on: http://review.couchbase.org/35306
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
recognize flow control commands for purpose of debugging upr

Change-Id: I2322522eed2c73a81468cc92eb3603192c51fb97
Reviewed-on: http://review.couchbase.org/35307
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
don't crash connection pool when handling done from unknown pid

There's a tiny chance for connection pool to receive EXIT message and
die when xdcr is having frequent crashes (i.e. during
rebalance). That's relatively normal.

What is not normal is that newly started connection pool instance
would crash again when socket is returned back to it from unknown
process.

In order to fix it we now simply drop such requests (and sockets) on
the floor.

Change-Id: I5cfe87c88f8f7b497eb9c89e9846b0fb871c3b94
Reviewed-on: http://review.couchbase.org/35530
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
avoid spamming logs by xdcr_upr_streamer on crashes in better way

proc_lib is printing neighbors mailboxes only for neighbors that don't
trap exits. So now instead of setting xdcr_upr_streamer processes to
be sensitive to avoid spamming logs by their mailbox contents, we now
simply trap exit in direct child of xdc_vbucket_rep. That avoids
spamming without impeding diagnostics.

Change-Id: Ia08a99aadf41957b4370f4d4d04ffac9598a69a6
Reviewed-on: http://review.couchbase.org/35531
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>