Current db does not support change stream (not a replica set)
See original GitHub issueI updated to the latest release and I am getting these errors regularly. I am on my local dev machine with MongoDB 4.2.8.
09:27:12.895|Error|22||Current db does not support change stream (not a replica set), consider using 'CheckQueuedJobsStrategy.TailNotificationsCollection' instead MongoDB.Driver.MongoCommandException: Command aggregate failed: The $changeStream stage is only supported on replica sets. at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol
1.ProcessResponse(ConnectionId connectionId, CommandMessage responseMessage)
at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol1.Execute(IConnection connection, CancellationToken cancellationToken) at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol
1.Execute(IConnection connection, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol1 protocol, ICoreSession session, CancellationToken cancellationToken) at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](ICoreSession session, ReadPreference readPreference, DatabaseNamespace databaseNamespace, BsonDocument command, IEnumerable
1 commandPayloads, IElementNameValidator commandValidator, BsonDocument additionalOptions, Action1 postWriteAction, CommandResponseHandling responseHandling, IBsonSerializer
1 resultSerializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase1.ExecuteProtocol(IChannelHandle channel, ICoreSessionHandle session, ReadPreference readPreference, CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.ReadCommandOperation
1.ExecuteAttempt(RetryableReadContext context, Int32 attempt, Nullable1 transactionNumber, CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.RetryableReadOperationExecutor.Execute[TResult](IRetryableReadOperation
1 operation, RetryableReadContext context, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation1.Execute(RetryableReadContext context, CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.AggregateOperation
1.Execute(RetryableReadContext context, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.ChangeStreamOperation1.ExecuteAggregateOperation(RetryableReadContext context, CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.ChangeStreamOperation
1.Execute(IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding binding, IReadOperation1 operation, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl
1.ExecuteReadOperation[TResult](IClientSessionHandle session, IReadOperation1 operation, ReadPreference readPreference, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl
1.ExecuteReadOperation[TResult](IClientSessionHandle session, IReadOperation1 operation, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl
1.Watch[TResult](IClientSessionHandle session, PipelineDefinition2 pipeline, ChangeStreamOptions options, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl
1.<>c__DisplayClass66_01.<Watch>b__0(IClientSessionHandle session) at MongoDB.Driver.MongoCollectionImpl
1.UsingImplicitSession[TResult](Func2 func, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl
1.Watch[TResult](PipelineDefinition2 pipeline, ChangeStreamOptions options, CancellationToken cancellationToken) at Hangfire.Mongo.MongoJobQueueWatcher.Execute(CancellationToken cancellationToken) at Hangfire.Server.ServerProcessDispatcherBuilder.ExecuteComponent(Guid executionId, Object state) at Hangfire.Processing.BackgroundExecution.Run(Action
2 callback, Object state)`
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7 (4 by maintainers)
@provanguard,
you have a couple of options.
use ‘TailNotificationsCollection’ which tails a capped collection, which is used to notify all Hangfire.Mongo instances of enqueued jobs. This is basically the default behavior before using the “watch” feature and it works on all mongod configurations. In hindsight, I should described this better in the release notes.
Use a “replica set” or “single node replica” in your local setup which supports the same features as your production environment. I have created a dotnet tool for this which I use when in development.
use different strategy based on configuration.
Thanks Jonas
@provanguard, sorry for the late reply, I have been on vacation.
It seems my error description is not descriptive enough. I will make sure to update it for next release.
there are certain features mongodb doesnt support if running as a single node. normally mongodb runs with replica sets. eg. multiple instances/processes of mongod. these features include the “watch” feature. https://docs.mongodb.com/manual/reference/method/db.collection.watch/
the watch feature is now the default behavior for observing enqueued jobs. If you are using a single mongod node, you need to change the “CheckQueuedJobsStrategy” in MongoStorageOptions to “TailNotificationsCollection” or “Poll” depending on your needs. You can configure mongo to run as a “single node replica set”. I have created a dotnet tool enabling this: https://github.com/gottscj/MongoRunner
please also see #299.
hope this helps! Br