[tools] update schema if needed when rebuilding master

Before this patch, if tservers had outdated schemas with lower
version for some tables (e.g. when the cluster wasn't healthy), the
'kudu master unsafe_rebuild' tool might rebuild the system catalog
with outdated schemas for the unhealthy tables.

This patch optimizes the rebuild logic, so the tool now picks up
schema of the highest version for an unhealthy table when rebuilding
the system catalog.

Change-Id: Iec99d57115228b521ba645b8e19c7057a4bb5d3d
Reviewed-on: http://gerrit.cloudera.org:8080/18496
Tested-by: Yingchun Lai <acelyc1112009@gmail.com>
Reviewed-by: Alexey Serbin <alexey@apache.org>
2 files changed