MB-7428: Use right destructor for tempfile

Change-Id: Ia2b10eb73808696bf63306c0fc9b68832ce7f264
Reviewed-on: http://review.couchbase.org/23373
Reviewed-by: Pavel Paulau <pavel.paulau@gmail.com>
Tested-by: Bin Cui <bin.cui@gmail.com>
MB-7369 MB-7370 Add "instance" vclock to important per-node keys.

The motivation is basically the same as in
http://review.couchbase.org/21999. But there's one important detail
that was missed before. During conflict resolution two conflicting
vclocks are merged to the vclock that descends both conflicting
vclocks. It means that if the node with faked vclock is removed from
the cluster and then added back, our trick will not work this
time. Because merged vlcock will descend our faked vclock. And the new
value will get overwritten. So the solution is to attach "instance"
vclock to such vulnerable keys during config initialization. So that
it appears that those keys have been modified by some random
node. This will cause conflict during config merge and the newer value
will be preferred.

Change-Id: I7977ada2f8aed2e13374aa2ea72deb5796fc3eb2
Reviewed-on: http://review.couchbase.org/23376
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-7311: Reimplement collecting memcached logs

The new approach won't get stucked when no memcached logs around.

Change-Id: I7e795771f2d07f9c515d4950070920678c5592f0
Reviewed-on: http://review.couchbase.org/23378
Tested-by: Bin Cui <bin.cui@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-6799: implemented api to pause/unpause view compaction

I.e. so that during vbucket movement we don't attempt any view
compaction on affected nodes and so that after movement is done we can
wait until compaction is started.

Change-Id: I54cbb63e19bed767e85523f9b10aba466defa40f
Reviewed-on: http://review.couchbase.org/23316
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-67{26,99}: implemented index aware vbucket move scheduling

We figured out that MB-6726 is because of not good enough vbucket move
scheduling and insufficient parallelism of index updates.

Particularly if there's rebalance out 4->3 without replicas all
vbucket movements are from rebalanced out node to one of remaining
nodes and old approach would do that one by one. Where vbucket
movement would be complete (and unblock next movement) only after
indexing is complete for entire vbucket.

Another problem was view compaction happening at unpredictable times
competing with view building of moved vbuckets.

New approach features the following:

a) we limit both incoming and outgoing backfills (compared to just
outgoing before). We planned to have that feature but now we could do
it as necessary part of this work

b) we limit only backfill phase of vbucket move, allowing
parallelization of rest (indexing, actual takeover)

c) we disable view compaction on source and destination of vbucket
move and we explicitly schedule and spawn view compaction as part of
overall rebalance process. So that we prevent concurrent bulk indexing
of moved vbuckets and compaction. Making disk usage more predictable
and understandable and improving overall efficiency.

As part of this work we separate entire aspect of rebalance actions
scheduling into it's own module. That new module is purely functional
(except some logging of course) and is covered by it's own set of unit
tests.

Also as part of this work we attempt round of vbucket move scheduling
improvements that was requested multiple times in past for which we
have some MB- or CBD- which as usual are impossible to find :)

Particularly we attempt to prioritize movements into new node in
rebalance in so that cluster's balance on active vbuckets is equalized
sooner. Previous code tended to start with building new replicas
without actually moving active vbuckets first.

Change-Id: Iad6da3be018e9e6dd66e1698b358dbd04515fbaa
Reviewed-on: http://review.couchbase.org/23317
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100: added master events support for new style rebalance

Change-Id: Ia535497968d0dbbdddb8cc23fef531616d358171
Reviewed-on: http://review.couchbase.org/23318
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100: store just binaries in master activity events keeper

So that it doesn't eat too much ram. We also hibernate for same
purpose.

Change-Id: I5bb4cd6582f72958b136d9d0be84b32e83bed482
Reviewed-on: http://review.couchbase.org/23319
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-6726: added rebalance_ignore_view_compactions setting

By setting this to true people may disable compaction during rebalance
essentially completely.

Some people may be willing to trade disk space for rebalance time.

Change-Id: Ib44338769fe7b5a51f9efcfff140274cc99a2b52
Reviewed-on: http://review.couchbase.org/23320
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-6726: added master activity events for in-rebalance compaction

I.e. so that we can keep track of forced index compactions during
rebalance.

Change-Id: Iac06bb3bf0e833cb8e85e881bae01d8c48de616a
Reviewed-on: http://review.couchbase.org/23321
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-6726: added vbucket scheduling simultation/visualization tool

That's not a fully featured tool but still a useful thing.

By manually running
vbucket_move_scheduler_validation:simulate_that_rebalance/0 it's
possible to save events log of simulated rebalance which can then be
turned into SVG timeline visualization.

Change-Id: Id033a884beab8220cae2f9283f676b41fff194fe
Reviewed-on: http://review.couchbase.org/23322
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-6726: added script to draw timeline of new-style rebalance

I.e. from master events.

Change-Id: I5410d114ff0c66fee91223d5c416c00de536e595
Reviewed-on: http://review.couchbase.org/23323
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100: added scripts/reformat-master-events.rb

I.e. master events are often inconsistently formatted which makes
visual inspection more difficult.

This particular script tries to put some more useful attributes first
in consistent order.

Change-Id: I4c76ea3bf1ebaf19678b2fcff5d2a3e0ae334718
Reviewed-on: http://review.couchbase.org/23324
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-6726: added internal settings for vbucket scheduling variables

Change-Id: I3389bd7da03be1f6d9740714fb392df3fbd32d51
Reviewed-on: http://review.couchbase.org/23325
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Merge remote-tracking branch 'origin/2.0.1'

* origin/2.0.1:
  MB-6726: added internal settings for vbucket scheduling variables
  MB-100: added scripts/reformat-master-events.rb
  MB-6726: added script to draw timeline of new-style rebalance
  MB-6726: added vbucket scheduling simultation/visualization tool
  MB-6726: added master activity events for in-rebalance compaction
  MB-6726: added rebalance_ignore_view_compactions setting
  MB-100: store just binaries in master activity events keeper
  MB-100: added master events support for new style rebalance
  MB-67{26,99}: implemented index aware vbucket move scheduling
  MB-6799: implemented api to pause/unpause view compaction
  MB-7311: Reimplement collecting memcached logs
  MB-7369 MB-7370 Add "instance" vclock to important per-node keys.
  MB-7428: Use right destructor for tempfile

Change-Id: I05355387c18c60d8755166212066d9b998fe4005