You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by mp...@apache.org on 2017/11/29 07:49:37 UTC
kudu git commit: transactions: check tablet before checking stopped
Repository: kudu
Updated Branches:
refs/heads/master 9120cdd1d -> 630830201
transactions: check tablet before checking stopped
This patch cleans up an unsafe pointer access to Tablet by using the
commonly-used pattern of grabbing a std::shared_ptr<Tablet> and
operating on it within an appropriate scope.
Previously, I saw one failure in multiple thousands of dist-test runs of
an upcoming disk failure test case in exactly_once_writes-itest caused
by this:
*** Aborted at 1511907337 (unix time) try "date -d @1511907337" if you are using GNU date ***
PC: @ 0x4a327b __tsan_atomic32_compare_exchange_strong
*** SIGSEGV (@0x240) received by PID 11526 (TID 0x7f5a1a6f8700) from PID 576; stack trace: ***
@ 0x44c8e2 __tsan::CallUserSignalHandler() at
@ 0x44d84d rtl_sigaction() at
@ 0x7f5a3a1e9330 (unknown) at
@ 0x4a327b __tsan_atomic32_compare_exchange_strong at
@ 0x7f5a3e95ca74 base::SpinLock::Lock() at
@ 0x7f5a3e95ca19 kudu::simple_spinlock::lock() at
@ 0x7f5a3d42f055 kudu::tablet::Tablet::HasBeenStopped() at
@ 0x7f5a3d547015 kudu::tablet::TransactionDriver::Init() at
@ 0x7f5a3d520441 kudu::tablet::TabletReplica::NewLeaderTransactionDriver() at
@ 0x7f5a3d51fea9 kudu::tablet::TabletReplica::SubmitWrite() at
@ 0x7f5a3ea0edad kudu::tserver::TabletServiceImpl::Write() at
@ 0x7f5a38cea594 kudu::tserver::TabletServerServiceIf::TabletServerServiceIf()::$_3::operator()() at
@ 0x7f5a38cea4c9 _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN4kudu7tserver21TabletServerServiceIfC1ERK13scoped_refptrINS3_12MetricEntityEERKS6_INS3_3rpc13ResultTrackerEEE3$_3PKN6google8protobuf7MessageEPSK_PNSB_10RpcContextEEEEvDpOT_ at
@ 0x7f5a38cea228 std::__1::__function::__func<>::operator()() at
@ 0x7f5a37d6b023 std::__1::function<>::operator()() at
@ 0x7f5a37d69fba kudu::rpc::GeneratedServiceIf::Handle() at
@ 0x7f5a37d6e9f1 kudu::rpc::ServicePool::RunThread() at
@ 0x7f5a37d734a4 boost::_mfi::mf0<>::operator()() at
@ 0x7f5a37d7335e boost::_bi::list1<>::operator()<>() at
@ 0x7f5a37d732a2 boost::_bi::bind_t<>::operator()() at
@ 0x7f5a37d72e91 boost::detail::function::void_function_obj_invoker0<>::invoke() at
@ 0x7f5a37ca0549 boost::function0<>::operator()() at
@ 0x7f5a360b225e kudu::Thread::SuperviseThread() at
@ 0x44c7bc __tsan_thread_start_func at
@ 0x7f5a3a1e1184 start_thread at
@ 0x7f5a32273ffd clone at
@ 0x0 (unknown)
Change-Id: I4821554e76c987fb8548384462b960f5c3b2c75f
Reviewed-on: http://gerrit.cloudera.org:8080/8673
Tested-by: Kudu Jenkins
Reviewed-by: Mike Percy <mp...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/63083020
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/63083020
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/63083020
Branch: refs/heads/master
Commit: 63083020118b578f5a5da5269701999c0b68651c
Parents: 9120cdd
Author: Andrew Wong <aw...@cloudera.com>
Authored: Tue Nov 28 20:02:03 2017 -0800
Committer: Mike Percy <mp...@apache.org>
Committed: Wed Nov 29 07:49:23 2017 +0000
----------------------------------------------------------------------
src/kudu/tablet/transactions/transaction_driver.cc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/63083020/src/kudu/tablet/transactions/transaction_driver.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/transactions/transaction_driver.cc b/src/kudu/tablet/transactions/transaction_driver.cc
index e51cfb7..6068487 100644
--- a/src/kudu/tablet/transactions/transaction_driver.cc
+++ b/src/kudu/tablet/transactions/transaction_driver.cc
@@ -18,6 +18,7 @@
#include "kudu/tablet/transactions/transaction_driver.h"
#include <functional>
+#include <memory>
#include <mutex>
#include <ostream>
#include <type_traits>
@@ -130,8 +131,11 @@ Status TransactionDriver::Init(gscoped_ptr<Transaction> transaction,
// Prevent further transacions from starting.
// Note: Some tests may not have a replica.
TabletReplica* replica = transaction->state()->tablet_replica();
- if (PREDICT_TRUE(replica) && replica->tablet()->HasBeenStopped()) {
- return Status::IllegalState("Not initializing new transaction; the tablet is stopped");
+ {
+ std::shared_ptr<Tablet> tablet = replica ? replica->shared_tablet() : nullptr;
+ if (PREDICT_FALSE(tablet && tablet->HasBeenStopped())) {
+ return Status::IllegalState("Not initializing new transaction; the tablet is stopped");
+ }
}
transaction_ = std::move(transaction);