catalog_manager: further protection for table visitor racing with shutdown
catalog_manager: further protection for table visitor racing with shutdown

One of my patches ran into the following master-test failure, which I think
is due to a table visitor thread writing to the table map while the
main thread iterates over it in Shutdown(). I can't reproduce the failure,
but copying the table map while holding the catalog manager lock (also held
by table visitors) should do the trick.

master-test: /home/jenkins-slave/workspace/kudu-1/src/kudu/gutil/ref_counted.h:273: T* scoped_refptr<T>::operator->() const [with T = kudu::master::TableInfo]: Assertion `ptr_ != __null' failed.
*** Aborted at 1461811706 (unix time) try "date -d @1461811706" if you are using GNU date ***
PC: @     0x7fd929da3cc9 gsignal
*** SIGABRT (@0x3e8000000a0) received by PID 160 (TID 0x7fd92d79e840) from PID 160; stack trace: ***
    @     0x7fd929da3d40 (unknown) at ??:0
    @     0x7fd929da3cc9 gsignal at ??:0
    @     0x7fd929da70d8 abort at ??:0
    @     0x7fd929d9cb86 (unknown) at ??:0
    @     0x7fd929d9cc32 __assert_fail at ??:0
    @     0x7fd92d306fdf scoped_refptr<>::operator->() at ??:0
    @     0x7fd92d2df4fb kudu::master::CatalogManager::Shutdown() at ??:0
    @     0x7fd92d327c6b kudu::master::Master::Shutdown() at ??:0
    @     0x7fd92d33c975 kudu::master::MiniMaster::Shutdown() at ??:0
    @           0x466012 kudu::master::MasterTest::TearDown() at /home/jenkins-slave/workspace/kudu-1/src/kudu/master/master-test.cc:75
    @     0x7fd92ab9a909 testing::internal::HandleExceptionsInMethodIfSupported<>() at ??:0
    @     0x7fd92ab8c3c0 testing::Test::Run() at ??:0
    @     0x7fd92ab8c4ad testing::TestInfo::Run() at ??:0
    @     0x7fd92ab8c5c5 testing::TestCase::Run() at ??:0
    @     0x7fd92ab8c878 testing::internal::UnitTestImpl::RunAllTests() at ??:0
    @     0x7fd92ab8cb19 testing::UnitTest::Run() at ??:0
    @     0x7fd92cfdf181 RUN_ALL_TESTS() at ??:0
    @     0x7fd92cfdec1e main at ??:0
    @     0x7fd929d8eec5 __libc_start_main at ??:0
    @           0x44e069 (unknown) at ??:?
    @                0x0 (unknown)

Change-Id: Ifbae665944f180c8b1354717c8ab9479c83d8fc8
Reviewed-on: http://gerrit.cloudera.org:8080/2891
Tested-by: Adar Dembo <866ca730bfc7f544e3ebce604ceeba4879f23df0@cloudera.com>
Reviewed-by: Todd Lipcon <2c763d726a8c2f6afda9be7e0e56a2caa6bb5e6b@apache.org>

cloudera/kudu,andrwng/kudu,EvilMcJerkface/kudu,andrwng/kudu,andrwng/kudu,cloudera/kudu,InspurUSA/kudu,EvilMcJerkface/kudu,InspurUSA/kudu,InspurUSA/kudu,helifu/kudu,EvilMcJerkface/kudu,cloudera/kudu,helifu/kudu,InspurUSA/kudu,andrwng/kudu,helifu/kudu,InspurUSA/kudu,InspurUSA/kudu,cloudera/kudu,helifu/kudu,EvilMcJerkface/kudu,andrwng/kudu,andrwng/kudu,helifu/kudu,cloudera/kudu,andrwng/kudu,helifu/kudu,helifu/kudu,helifu/kudu,InspurUSA/kudu,cloudera/kudu,helifu/kudu,andrwng/kudu,EvilMcJerkface/kudu,EvilMcJerkface/kudu,EvilMcJerkface/kudu,cloudera/kudu,andrwng/kudu,InspurUSA/kudu,cloudera/kudu,EvilMcJerkface/kudu,InspurUSA/kudu,EvilMcJerkface/kudu,cloudera/kudu