Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
CouchDB
Erlang Python C C++ Shell Ruby Other

MB-15274 Reset file properly

View compaction creates a new file. Such a file always starts with a header. This
header doesn't point to any data, as there wasn't any data written yet. Though this
header contains enough information so that the view-engine can start up properly
with a file that contains only such a header. This is important as data corruption
on files can always happen and you don't want to end up in an undefined/not working
state.

The first header in a file that was created due to compaction is based on the header
of the view group when the compaction took place. Some information is reset as the
header e.g. can't point to any trees as the file doesn't contain any data yet.

In the current code, not enough information was reset. The update sequence numbers
of the partitions were still the ones of the view group. In case of a data corruption
of the view file, where the only valid header is a the first one in the file, this
lead to a view that didn't update itself properly anymore if the node was restarted.

On a node restart the view-engine reads the view file from the back until it finds
a valid header. Due to a corruption it only finds the first one in the file. It uses
that header for the view group. When a `stale=false` request comes in, the sequence
numbers of the header are compared to the ones the partitions currently hold. They
will match, so no update will be performed and the data of the view file will be
returned. But as the view file only contains the header, no data will be returned.
The view will be stuck until new updates come in. But even then things will break, as
it is expected that the view contains all the data up to the sequence numbers, but
it doesn't.

The solution is to reset the sequence numbers of the header before it is written at
the beginning of the file. In case of the corruption mentioned above, the index
will be recreated in case a `stale=false` request comes in, as the sequence numbers
are all `0`.

Change-Id: I53460bb7d7ec4cdf1b029fb0c0b1cd1660f338e0
Reviewed-on: http://review.couchbase.org/52562
Tested-by: Volker Mische <volker.mische@gmail.com>
Reviewed-by: Harsha H S <hhs.couchbase@gmail.com>
latest commit 294f816c45
@vmx vmx authored vmx committed
Something went wrong with that request. Please try again.