Skip to content

Commit

Permalink
Merge "This fix ensures all redis DB is flushed before any GetSeq cal…
Browse files Browse the repository at this point in the history
…ls are sent by the generators. This is needed because we can have the following sequence in the collector that can lead to a crash viz., generator issues GetSeq, collector to redis connection post process call resulting in Flush of database, DeleteUVE request from the generator due to disconnect session. The above sequence tries to delete a UVE thats not there in Redis. This fix prevents such a case from happening. Closes-Bug:#1670908 (cherry picked from commit 409b4f9) Change-Id: I51dfedacdac75fdf5b271cdcaaafb7d4ddfd9bfc (cherry picked from commit 4faef23)" into R3.1
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Mar 29, 2017
2 parents 11324be + 778d457 commit 0b4bb99
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/analytics/OpServerProxy.cc
Expand Up @@ -341,6 +341,7 @@ class OpServerProxy::OpServerImpl {
tbb::mutex::scoped_lock lock(rac_mutex_);
redis_uve_.RedisStatusUpdate(RAC_DOWN);
}
started_ = false;
collector_->RedisUpdate(false);
redis_up_ = false;

Expand Down Expand Up @@ -630,6 +631,8 @@ class OpServerProxy::OpServerImpl {
}

RedisInfo redis_uve_;
bool IsInitDone() { return started_;}

private:
/* these are made public, so they are accessed by OpServerProxy */
EventManager *evm_;
Expand Down Expand Up @@ -867,3 +870,13 @@ RedisUVERequest::HandleRequest() const {
resp->Response();
}

/*
* After redis collector connection is UP,
* we do initialization as part of a callback.
* We set the started_ flag during that step.
*/
bool
OpServerProxy::IsRedisInitDone() {
return impl_->IsInitDone();
}

1 change: 1 addition & 0 deletions src/analytics/OpServerProxy.h
Expand Up @@ -67,6 +67,7 @@ class OpServerProxy {
const std::string &instance_id);

void FillRedisUVEInfo(RedisUveInfo& redis_uve_info);
virtual bool IsRedisInitDone();
private:
class OpServerImpl;
OpServerImpl *impl_;
Expand Down
5 changes: 4 additions & 1 deletion src/analytics/collector.cc
Expand Up @@ -231,7 +231,10 @@ bool Collector::ReceiveSandeshCtrlMsg(SandeshStateMachine *state_machine,
snh->get_source() << ":" << snh->get_module_name());
return false;
}

if (!osp_->IsRedisInitDone()) {
LOG(ERROR, "Collector connection to redis is not establised and flush done");
return false;
}
SandeshGenerator::GeneratorId id(boost::make_tuple(snh->get_source(),
snh->get_module_name(), snh->get_instance_id_name(),
snh->get_node_type_name()));
Expand Down

0 comments on commit 0b4bb99

Please sign in to comment.