[Live-devel] StreamReplicator: frame delivery stop

Bruno Abreu bruno.abreu at livingdata.pt
Tue Nov 15 03:55:53 PST 2016


Hello Ross,

we've been facing occasional frame delivery stops when using StreamReplicator
with 3 replicas. We know this happens when one of the replicas is being
removed, another is being held as the master replica and the third one as
already received the current frame.

Internal state of the replicator is something like this:
DEBUG_REPLICATOR: fFrameIndex=1
DEBUG_REPLICATOR: fNumReplicas=3, fNumActiveReplicas=3, fNumDeliveriesMadeSoFar=1
DEBUG_REPLICATOR: fMasterReplica->fFrameIndex=1

The problem is that, even if the replica being removed hasn't asked for the
current frame, fNumDeliveriesMadeSoFar still gets decremented, because the
condition on line 114 is being tested after
replicaBeingDeactivated->fFrameIndex = -1 is assigned.

This prevents deliverReceivedFrame() from completing the current frame
delivery by toggling the fFrameIndex, calling fInputSource->getNextFrame() and
FramedSource::afterGetting(replica).

Following patch seems to solve the problem:
@@ -108,10 +108,10 @@ void StreamReplicator::deactivateStreamR
   // Assert: fNumActiveReplicas > 0
   if (fNumActiveReplicas == 0) fprintf(stderr,
"StreamReplicator::deactivateStreamReplica() Internal Error!\n"); // should
not happen
   --fNumActiveReplicas;
-  replicaBeingDeactivated->fFrameIndex = -1;

   // Forget about any frame delivery that might have just been made to this
replica:
   if (replicaBeingDeactivated->fFrameIndex != fFrameIndex &&
fNumDeliveriesMadeSoFar > 0) --fNumDeliveriesMadeSoFar;
+  replicaBeingDeactivated->fFrameIndex = -1;

   // Check whether the replica being deactivated is the 'master' replica, or
is enqueued awaiting a frame:
   if (replicaBeingDeactivated == fMasterReplica) {


Thank you,
Bruno Abreu

-- 
Living Data - Sistemas de Informação e Apoio à Decisão, Lda.
LxFactory - Rua Rodrigues de Faria, 103, edifício I, 4º piso
1300-501 LISBOA                       Phone:  +351 213622163
Portugal                              URL: www.livingdata.pt




More information about the live-devel mailing list