This PR exposes the necessary information for tracking handoff progress (added in basho/riak_core#290) of kv_vnodes using the memory, level, or bitcask backends. Each backend exposes an upper-bound on the amount of data stored, but each one comes with some caveats. Although these caveats are inconvenient, the metrics still provide a significantly better indication of progress than having no indication. The API has been designed so more accurate (or less accurate even) metrics can be used, in the future, instead.
The bitcask backend uses the existing knowledge of keydir size to expose the total number of keys that will be transferred. This is an ok but not great indicator of progress because it doesn't account for varying object sizes (transferring 99 1k objects and one 20MB object).
The eleveldb backend uses the support added in basho/leveldb#74 to directly query the number of bytes in sst files. This has the downside that the returned number may include overwritten keys whose bytes will not be transferred. However, this still means that we will always have made equal or more progress than what is indicated, never less, which is sufficient. If basho/leveldb#74 is not used, tracking handoff progress in eleveldb is not supported.
The memory backend uses built in stats info in ets to return the number of keys that will be transferred. This also has the same drawback as the bitcask backend. In addtion, since the ets fold is not a snapshot, the backend uses the dynamic size feature to make sure progress is tracked correctly.
The multi backend is not supported.
Example output of riak-admin transfers with these changes: https://gist.github.com/jrwest/588d85bbeaebaf940e59
This PR also completes the move of transfers/1 to riak_core_console started in basho/riak_core#290
Associated riak PR: basho/riak#303
move riak_kv_console:transfers to riak_core
nothing about it is specific to riak_kv
kv_vnode: expose backend size for handoff progress if backend is capable
add bitcask_backend:data_size/1 for tracking handoff progress
add memory_backend:data_size/1 for tracking handoff progress
add eleveldb_backend:data_size/1 for tracking handoff progress
Blergh, I didn't realize that this has now changed to depend on unmerged leveldb code before I started re-reviewing and testing. Please let me know when the leveldb code has finished review and has been merged to complete this review. @jtuple @jrwest
@engelsanchez this branch should be able to merge independently of the the leveldb changes. As for review, my personal suggestion would be to review this w/ the leveldb backend w/ and w/o @jtuple's changes.
The leveldb PR for reference: basho/leveldb#74
Is the leveldb branch really ready? I keep trying to compile this with the branch and I am not getting progress reports when using leveldb like I used to when I tested this last week. It might be that my build is not clean, but confirmation would be nice @jtuple @jrwest
Nevermind @jtuple @jrwest, test is working after manually removing a bunch of C build artifacts. I will complete the review shortly.
The leveldb branch was ready and working last I tested. I think I saw some changes related to how leveldb is built recently but iirc it took me a while to figure out how to get the correct version of leveldb checked out to test it (you have to edit a sha in eleveldb Makefile)
Ok, I've reviewed the code and tested the memory, bitcask and leveldb backends. Leveldb works as advertised when the data size branch mentioned above is used, and simply displays N/A when not. I've found no issues here, so 👍 💃 ⛵️