Skip to content

Commit

Permalink
This fix ensures all redis DB is flushed before any GetSeq calls are …
Browse files Browse the repository at this point in the history
…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
Change-Id: I51dfedacdac75fdf5b271cdcaaafb7d4ddfd9bfc
  • Loading branch information
arvindvis committed Mar 16, 2017
1 parent c9d2065 commit 409b4f9
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
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class OpServerProxy::OpServerImpl {
tbb::mutex::scoped_lock lock(rac_mutex_);
redis_uve_.RedisStatusUpdate(RAC_DOWN);
}
started_ = false;
collector_->RedisUpdate(false);
kafka_proc_->SetRedisState(false);

Expand Down Expand Up @@ -466,6 +467,8 @@ class OpServerProxy::OpServerImpl {

RedisInfo redis_uve_;

bool IsInitDone() { return started_;}

private:
EventManager *evm_;
VizCollector *collector_;
Expand Down Expand Up @@ -704,3 +707,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
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,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 409b4f9

Please sign in to comment.