Skip to content

Use fanout for publish if mesh is empty even if we are subscribed to a topic#675

Open
aarshkshah1992 wants to merge 1 commit intolibp2p:masterfrom
aarshkshah1992:fix/fanout-if-mesh-is-empty
Open

Use fanout for publish if mesh is empty even if we are subscribed to a topic#675
aarshkshah1992 wants to merge 1 commit intolibp2p:masterfrom
aarshkshah1992:fix/fanout-if-mesh-is-empty

Conversation

@aarshkshah1992
Copy link
Contributor

@aarshkshah1992 aarshkshah1992 commented Feb 24, 2026

If a peer subscribes to a topic when it has not yet seen any other peers for the topic, it will set the mesh to an empty map.

Now say another peer comes in and subscribes to the topic. But, it has not been grafted yet and has yet to be added to the mesh. However, it is now added to the list of peers subscribed to a given topic.

Now, if the first peer does a Publish -> we see that the mesh exists and so don't do a fanout. However, the mesh is empty which means that the peer above never sees the message.

Later, on a heartbeat, the second peer gets grafted but it's too late.

@aarshkshah1992
Copy link
Contributor Author

@MarcoPolo @sukunrt Please can I request you to take a look ?

// to ensure that messages we publish in the intermin are not lost
if len(gmap) > 0 {
gs.mesh[topic] = gmap
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this? The len check when we build the list of peers to publish to is enough.

Comment on lines +1367 to 1370
if !ok || len(gmap) == 0 {
// we are not in the mesh for topic, use fanout peers
gmap, ok = gs.fanout[topic]
if !ok || len(gmap) == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also consider adding:
Dlo - len(gmap) peers from fanout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants