MB-9307: Size of couch_file:read_header_bin/2 is not used

Returning the size of the header is not needed anywhere.

Change-Id: I9f7f97d0a4e00fcb35635332da3be75dd83b3a01
Reviewed-on: http://review.couchbase.org/30859
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
MB-9307: Add indexer rollback

Add the functionality to rollback to a certain sequence
number of a certain partition. It rolls back to a previous
header, which means that other partitions might also be
rolled back.

"make check" is epected to fail and is fix with the next
commit.

Change-Id: I62cae905fd3e6e733310057e36a3f66c7200d315
Reviewed-on: http://review.couchbase.org/29732
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Don't replace the full header

After a rollback, don't use the full header information
from the on-disk header, but only the state of the
ID-btree and the views trees.

Also update the sequence numbers of the indexable and
unindexable partitions to match the ones of the on-disk
header it was rolled back to.

Change-Id: Iecf95d38f5111923cb6239adb0b7d824e625b5a3
Reviewed-on: http://review.couchbase.org/30016
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Abort compaction during rollback

Change-Id: I810a69d7625b59b4364e0786f6360bfb3c56c156
Reviewed-on: http://review.couchbase.org/30017
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Use timeout for rollback call

Change-Id: I1f515e66cfcfb49c7b8af539c51433a4d21d8ccb
Reviewed-on: http://review.couchbase.org/30018
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Find header in block size increments

To find a header, don't scan the file byte by byte, but
only on block boundaries where the headers are stored.

Change-Id: Ia6fd86bc0b707db723b86b4d76488ba0d2b78b51
Reviewed-on: http://review.couchbase.org/30019
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Take unindexable partitions into account

Partitions might be set to unindexable, but that doesn't mean
that we can't roll back to them and use them as a starting point
for future updates.

Change-Id: I401e4ea0de6f5c8f95c823cd67f780b159860413
Reviewed-on: http://review.couchbase.org/30020
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Don't rollback if partition didn't exist

Don't roll back if a partition doesn't exist in a
previous header (or has sequence number 0).

Change-Id: Idb99d557aa27339989d3e5c2b9c3a28c158e16c9
Reviewed-on: http://review.couchbase.org/30021
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Don't include new partitions due to rollback

When a rollback is performed, the new header might contain
partitions that are not part of the current index. Mark those
for cleanup and update the header accordingly.

Change-Id: If5ddc95a1ef8866418d0bffcc4eff4773ac227b0
Reviewed-on: http://review.couchbase.org/30023
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Rollback with multiple partitions

Instead of rolling back taking a single partition and sequence
number into account, it's now possible to rollback with supplying
multiple partitions and sequence numbers at the same time. It
is only rolled back if a header satisfies all given partition/
sequence number pairs.

Change-Id: I9492fd894a8b1fcc06d81aef93fe960322cfade6
Reviewed-on: http://review.couchbase.org/30058
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Add test for indexable/undindexable switch

Add a test for the rollback when a partition changes from
unindexable to indexable.

Change-Id: I99414a2d81c8c90da3281e59aa925e1e55856c52
Reviewed-on: http://review.couchbase.org/30860
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Better log message

Change-Id: Idc07ed0947b54d1224d8ed36e548d8f787aa4a3b
Reviewed-on: http://review.couchbase.org/30867
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: buildbot <build@couchbase.com>
MB-8903: Get high sequence number as stat

Instead of getting it from the fake UPR server directly via
a function call, request it via a stat request. This currently
doesn't work with the real ep-engine implementation, as you
can't request a stat from a socket that is connected to an
UPR stream. You would need to open a separate socket.

As this still needs to discussed, the simplest possible way
(using the UPR stream socket also for stats) is used until
an agreement is found.

The 03-fake-upr-server.t tests are removed as all it's
functionality is testes with the 02-couch-upr.t tests anyway.

Change-Id: I0ae7bf74c71e2cc65702ce379458339b70f518c3
CBD-485 fix descriptors leak in jump_to_another_version

Change-Id: Idef3c2d31cc12483b27015e0ea7bb6848d39f512
Reviewed-on: http://review.couchbase.org/31123
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Merge remote-tracking branch 'couchbase/master' into upr2
MB-9307: Use the partition versions from the on disk header

After a rollback the partition versions of the header it
was rolled back to must be used.

Also return the new partition versions on the 'ok' response.

Change-Id: Ie0e8384da4f66cb76cb77eb6a93918416457da9a