PersistentSubscription Issues with multi-node deployment

[ErrorCodeNotLeader] the request needing a leader node was executed on a follower node

When I try to create a persistent subscription locally with docker, it works fine. However, when I try to connect to a cluster that I have deployed in staging I receive the above error.

We are using an ESDB cluster with DNS. Is there anything specific in terms of configuration that I could be missing which is causing this to not find the leader node? I have RequiresLeader set to true in the go client library.

ex.

func (s *subscription) CreateSubscription(ctx context.Context, resultPrefix string) error {
	options := esdb.PersistentAllSubscriptionOptions{
		Filter: &esdb.SubscriptionFilter{
			Type:     esdb.StreamFilterType,
			Prefixes: []string{resultPrefix},
		},
		RequiresLeader: true,
	}

    return s.EventStore.client.CreatePersistentSubscriptionToAll(ctx, s.SubscriptionGroup, options)
}

Any advice is appreciated. Thank you

I think it’s an issue in Golang client. We have our own experience that reads sometimes return stale data even if the node preference is set to leader.
It might happen in any client because nodes can change their roles since the initial gossip. But, assuming you create the subscription when you start the application, it shouldn’t happen.
Can you open an issue in the GitHub Go client repo?

Thank you for getting back to me so quickly. I’ve added an issue here: issue: Fail to create Persistent Subscription on multi-node deployment · Issue #177 · EventStore/EventStore-Client-Go · GitHub

Please let me know if you need anything else.

what does your connection string looks like ?
( esdb://[address] or esdb+discover://[address] )

I assume in docker you’re in single node mode ?
What are the A records for you cluster setup ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.