Relevant ESDB thread: https://discuss.eventstore.com/t/persistentsubscription-issues-with-multi-node-deployment/5268
[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)
}
I was able to get this working by setting the Node preference via:
settings.NodePreference = esdb.NodePreferenceLeader
client, err := esdb.NewClient(settings)
However, I am not certain this would work in 100% of cases since this is a 'preference' which I'm assuming is not a guarantee. And it seems like the default behavior for persistent subscriptions should be to connect to the leader rather than requiring the user to set these values.
Relevant ESDB thread: https://discuss.eventstore.com/t/persistentsubscription-issues-with-multi-node-deployment/5268
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.
I was able to get this working by setting the Node preference via:
However, I am not certain this would work in 100% of cases since this is a 'preference' which I'm assuming is not a guarantee. And it seems like the default behavior for persistent subscriptions should be to connect to the leader rather than requiring the user to set these values.