basho/riak_kv — pull request #504 by jrwest (2013-03-14 00:55:50+00:00)
Title: Upgrade/Downgrade Path for 2i Bigint Bug

As reported in #499, 2i range queries involving bigints could return incorrect results. The issue was caused by https://github.com/uwiger/sext/issues/5. The fix introduces an incompatibility in sext's encoding of bigints. This PR addresses handling of both the fixed and legacy encoding in Riak and provides a path for 2i users to upgrade stored indices that may be using the legacy format. A path for downgrading is also provided.

With this change, when first started, Riak will write new indicies (or update indicies) using the legacy format. When indicies are removed (when an object is deleted or updated), initially, the backend will attempt to remove both the legacy and fixed encoding of the index. After `riak_kv_util:fix_incorrect_indices/1,2` has been run the additional delete of the legacy index will no longer occur. The additional delete will also not occur in partitions that are empty on startup.

Users wishing to downgrade can use `riak_kv_util:fix_incorrect_indices/2` passing the option `{downgrade, true}`. This performs a similar operation to upgrading, however, after starting, index writes will be encoded in the legacy format.

In the case `riak_kv_util:fix_incorrect_indices/1,2` crashes or returns errors it is expected that it will be re-run. Re-running will "continue from where it left off" in the sense that indices rewritten before the crash will not be rewritten again. Results are written to the log as `info` messages.

Additionally, this PR changes the dependency on `sext`. It bumps the version to 1.1, which is necessary to include the encoding fix and uses Ulf Wiger's repository instead of ESL's since Ulf's is now the official one.