Announce subscriptions and report subscriber snapshots in discovery - #916
Announce subscriptions and report subscriber snapshots in discovery#916caguero wants to merge 13 commits into
Conversation
… TopicList() call Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
…discovery startup Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
…r completion in TopicList() Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
…e subscribers protocol Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
…builds Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
…internals Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
…ixed sleeps Assisted-by: Claude Fable 5 Signed-off-by: Carlos Aguero <caguero@honurobotics.com>
fae3f53 to
02d5424
Compare
There was a problem hiding this comment.
Otherwise, LGTM!
I also did some behavior tests, and the results were consistent with #915 (comment)
Thanks for the fix, and sorry for the late reply.
| if (!progress.started || | ||
| progress.generation != snapshot.generation()) | ||
| { | ||
| progress.started = true; | ||
| progress.generation = snapshot.generation(); | ||
| progress.expected = snapshot.count(); | ||
| progress.received = 0; | ||
| this->remoteSubscribers.DelPublishersByProc(recvPUuid); | ||
| } | ||
|
|
||
| if (!publisher.Topic().empty()) | ||
| { | ||
| this->remoteSubscribers.AddPublisher(publisher); | ||
| ++progress.received; | ||
| } |
There was a problem hiding this comment.
I think we may need a way to identify each snapshot response burst.
Because, if the subscriber generation does not change, and TopicList() is called concurrently, replies from different SUBSCRIBERS_REQ calls can be mixed.
Also, if one TopicList() call times out, late replies from that older SUBSCRIBERS_REQ can arrive during a later TopicList() call.
In both cases, SUBSCRIBERS_REP only carries generation and count, so the receiver cannot tell which request a reply belongs to. Since completion is decided by received >= expected, mixed replies may make the receiver mark the snapshot as complete even when it did not receive one full response burst.
| std::lock_guard<std::recursive_mutex> lk(this->mutex); | ||
| // Add the topic to the list of subscribed topics (if it was not before). | ||
| this->dataPtr->topicsSubscribed[_nUuid].insert(_fullyQualifiedTopic); | ||
| ++this->dataPtr->subscriptionsGeneration; |
There was a problem hiding this comment.
Should subscriptionsGeneration be updated for every subscription handler change, or only when the topic/node membership changes?
Currently, it is incremented even when topicsSubscribed already contains the topic.
🎉 New feature
Follow up of #915. Fixes #914.
Requires gazebosim/gz-msgs#615
Summary
Completes the subscriber discovery so that
TopicList()returns complete information on any call, including the first one:SUBSCRIBEmessages announce the subscription (node UUID) and the receivers record it.SUBSCRIBERS_REPbursts are tagged as snapshots (count,generation).TopicList()waits until every known process reports a complete snapshot, with a 100 ms timeout.Slightly behavior change:
TopicList()now blocks a few ms (up to 100 ms when a process does not answer).Backport Policy
Checklist
codecheckpassed (See contributing)Assisted-by: Claude Fable 5
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.Backports: If this is a backport, please use Rebase and Merge instead.