Skip to content

Commit

Permalink
Refine stale cleanup and EOR heuristics
Browse files Browse the repository at this point in the history
Restart stale cleanup and EOR timers only if we receive searchResult.
If we receive updateResult or deleteResult, artificially expire the
relevant timers right away.

This handles the corner case where continuous object add/delete can
keep the CN from becoming active.

Note that this fix does not reintroduce bug 1501425.

Change-Id: Ib2f790d323f28c8403f8bcf20ba18fa782a03967
Closes-Bug: 1527551
  • Loading branch information
Nischal Sheth committed May 10, 2016
1 parent 60c72cf commit 4c1f1de
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
46 changes: 39 additions & 7 deletions src/ifmap/client/ifmap_channel.cc
Expand Up @@ -619,15 +619,27 @@ int IFMapChannel::ReadPollResponse() {

// Manage timers.
if (start_stale_entries_cleanup()) {
// If this is a reconnection, keep re-arming the stale entries
// cleanup timer as long as we keep receiving data.
StartStaleEntriesCleanupTimer();
if (reply_str.find("searchResult") != string::npos) {
// If this is a reconnection, keep re-arming the stale entries
// cleanup timer as long as we receive searchResults.
StartStaleEntriesCleanupTimer();
} else {
// Artificially expire the state entries cleanup timer if we
// receive updateResult or deleteResult.
ExpireStaleEntriesCleanupTimer();
}
}
if (!end_of_rib_computed()) {
// When the daemon is coming up, as long as we are receiving data,
// we have not received the entire db. Keep re-arming the EOR timer
// as long as we are receiving data.
StartEndOfRibTimer();
if (reply_str.find("searchResult") != string::npos) {
// When the daemon is coming up, as long as we are receiving
// searchResults, we have not received the entire db. Keep
// re-arming the EOR timer as long as we receive searchResults.
StartEndOfRibTimer();
} else {
// Artificially expire the EOR timer if we receive updateResult
// or deleteResult.
ExpireEndOfRibTimer();
}
}

// Send the message to the parser for further processing.
Expand Down Expand Up @@ -668,6 +680,16 @@ void IFMapChannel::StopStaleEntriesCleanupTimer() {
}
}

void IFMapChannel::ExpireStaleEntriesCleanupTimer() {
CHECK_CONCURRENCY("ifmap::StateMachine");
int timeout = kStaleEntriesCleanupTimeout;
IFMAP_PEER_DEBUG(IFMapServerConnection, integerToString(timeout),
"millisecond stale cleanup timer expired artificially");
stale_entries_cleanup_timer_->Cancel();
set_start_stale_entries_cleanup(false);
manager_->ifmap_server()->ProcessStaleEntriesTimeout();
}

// Called in the context of the main thread.
bool IFMapChannel::ProcessStaleEntriesTimeout() {
int timeout = kStaleEntriesCleanupTimeout;
Expand Down Expand Up @@ -698,6 +720,16 @@ void IFMapChannel::StopEndOfRibTimer() {
}
}

void IFMapChannel::ExpireEndOfRibTimer() {
CHECK_CONCURRENCY("ifmap::StateMachine");
int timeout = kEndOfRibTimeout;
IFMAP_PEER_DEBUG(IFMapServerConnection, integerToString(timeout),
"millisecond end of rib timer expired artificially");
end_of_rib_timer_->Cancel();
set_end_of_rib_computed(true);
process::ConnectionState::GetInstance()->Update();
}

// Called in the context of the main thread.
bool IFMapChannel::ProcessEndOfRibTimeout() {
int timeout = kEndOfRibTimeout;
Expand Down
2 changes: 2 additions & 0 deletions src/ifmap/client/ifmap_channel.h
Expand Up @@ -229,9 +229,11 @@ class IFMapChannel {
void ProcResponseInMainThr(size_t bytes_to_read);
void StartStaleEntriesCleanupTimer();
void StopStaleEntriesCleanupTimer();
void ExpireStaleEntriesCleanupTimer();
bool ProcessStaleEntriesTimeout();
void StartEndOfRibTimer();
void StopEndOfRibTimer();
void ExpireEndOfRibTimer();
bool ProcessEndOfRibTimeout();

IFMapManager *manager_;
Expand Down

0 comments on commit 4c1f1de

Please sign in to comment.