MB-12179: Refactor database scan code

This change splits the database scan (called dump in our API's) into
three separate phases. The first is initializing the scan, the second
is actually doing the scan, and the last is closing the database. One
fundamental change is the fact that we now keep a handle to the
database file in the KVStore until the handle is closed. This change
paves the way for allowing us to have pausable backfills.

Change-Id: Ifa1b6f9524fe5b20d6d522fcbabb822e36e66957
Reviewed-on: http://review.couchbase.org/41826
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>