Repository: kudu Updated Branches: refs/heads/master 06569f218 -> 388dd2955
KUDU-1773: remove overly strict DCHECKs A tablet's replicas may change over the course of a write. For example, between two attempts at the same write, a replica could be evicted from the replication group and replaced by another. A pair of DCHECKs in the metacache didn't allow that, so they've been removed. Furthermore, their respective RemoteTablet functions now don't return anything, to reflect the fact that success or failure in finding the replica in question should be immaterial to all callers. Change-Id: I01c1dde99cce1f43e6a9864c1ff6f7aaad448a77 Reviewed-on: http://gerrit.cloudera.org:8080/5292 Tested-by: Kudu Jenkins Reviewed-by: Mike Percy <mpe...@apache.org> Reviewed-by: Todd Lipcon <t...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/388dd295 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/388dd295 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/388dd295 Branch: refs/heads/master Commit: 388dd2955f5995e265a4d2ee4ba9bb339338c8e7 Parents: 06569f2 Author: Adar Dembo <a...@cloudera.com> Authored: Wed Nov 30 15:05:55 2016 -0800 Committer: Todd Lipcon <t...@apache.org> Committed: Fri Dec 2 01:17:43 2016 +0000 ---------------------------------------------------------------------- src/kudu/client/meta_cache.cc | 13 +------------ src/kudu/client/meta_cache.h | 4 +--- 2 files changed, 2 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/388dd295/src/kudu/client/meta_cache.cc ---------------------------------------------------------------------- diff --git a/src/kudu/client/meta_cache.cc b/src/kudu/client/meta_cache.cc index ffa4940..82bcc5d 100644 --- a/src/kudu/client/meta_cache.cc +++ b/src/kudu/client/meta_cache.cc @@ -188,9 +188,8 @@ bool RemoteTablet::stale() const { return stale_; } -bool RemoteTablet::MarkReplicaFailed(RemoteTabletServer *ts, +void RemoteTablet::MarkReplicaFailed(RemoteTabletServer *ts, const Status& status) { - bool found = false; std::lock_guard<simple_spinlock> l(lock_); VLOG(2) << "Tablet " << tablet_id_ << ": Current remote replicas in meta cache: " << ReplicasAsStringUnlocked(); @@ -199,10 +198,8 @@ bool RemoteTablet::MarkReplicaFailed(RemoteTabletServer *ts, for (RemoteReplica& rep : replicas_) { if (rep.ts == ts) { rep.failed = true; - found = true; } } - return found; } int RemoteTablet::GetNumFailedReplicas() const { @@ -253,33 +250,25 @@ void RemoteTablet::GetRemoteReplicas(vector<RemoteReplica>* replicas) const { } void RemoteTablet::MarkTServerAsLeader(const RemoteTabletServer* server) { - bool found = false; std::lock_guard<simple_spinlock> l(lock_); for (RemoteReplica& replica : replicas_) { if (replica.ts == server) { replica.role = RaftPeerPB::LEADER; - found = true; } else if (replica.role == RaftPeerPB::LEADER) { replica.role = RaftPeerPB::FOLLOWER; } } VLOG(3) << "Latest replicas: " << ReplicasAsStringUnlocked(); - DCHECK(found) << "Tablet " << tablet_id_ << ": Specified server not found: " - << server->ToString() << ". Replicas: " << ReplicasAsStringUnlocked(); } void RemoteTablet::MarkTServerAsFollower(const RemoteTabletServer* server) { - bool found = false; std::lock_guard<simple_spinlock> l(lock_); for (RemoteReplica& replica : replicas_) { if (replica.ts == server) { replica.role = RaftPeerPB::FOLLOWER; - found = true; } } VLOG(3) << "Latest replicas: " << ReplicasAsStringUnlocked(); - DCHECK(found) << "Tablet " << tablet_id_ << ": Specified server not found: " - << server->ToString() << ". Replicas: " << ReplicasAsStringUnlocked(); } string RemoteTablet::ReplicasAsString() const { http://git-wip-us.apache.org/repos/asf/kudu/blob/388dd295/src/kudu/client/meta_cache.h ---------------------------------------------------------------------- diff --git a/src/kudu/client/meta_cache.h b/src/kudu/client/meta_cache.h index 3f70b95..18a4e48 100644 --- a/src/kudu/client/meta_cache.h +++ b/src/kudu/client/meta_cache.h @@ -195,9 +195,7 @@ class RemoteTablet : public RefCountedThreadSafe<RemoteTablet> { // not be returned in future cache lookups. // // The provided status is used for logging. - // Returns true if 'ts' was found among this tablet's replicas, false if not. - bool MarkReplicaFailed(RemoteTabletServer *ts, - const Status& status); + void MarkReplicaFailed(RemoteTabletServer *ts, const Status& status); // Return the number of failed replicas for this tablet. int GetNumFailedReplicas() const;