Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongo Atlas Serverless issues #423

Closed
gunsh opened this issue Dec 25, 2024 · 5 comments
Closed

Mongo Atlas Serverless issues #423

gunsh opened this issue Dec 25, 2024 · 5 comments

Comments

@gunsh
Copy link

gunsh commented Dec 25, 2024

I have just encountered an issue while trying to connect to an Mongo Atlas Serverless instance. I do not suppose Hangfire.Mongo has been tested against it. Please see part of the full stack trace below. This comes as a consequence of calling Hangfire.HangfireApplicationBuilderExtensions.UseHangfireDashboard().

As the limitations docs seem to imply the $out aggregation stage is unsupported and $merge is suggested as a replacement.

Perhaps adding serverless support is something you could consider.

Unhandled exception. MongoDB.Driver.MongoCommandException: Command aggregate failed: $out is not allowed or the syntax is incorrect, see the Atlas documentation for more information.
   at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ProcessResponse(ConnectionId connectionId, CommandMessage responseMessage)
   at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.SendMessageAndProcessResponse(CommandRequestMessage message, Int32 responseTo, IConnection connection, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.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](IWireProtocol`1 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, Action`1 postWriteAction, CommandResponseHandling responseHandling, IBsonSerializer`1 resultSerializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle channel, ICoreSessionHandle session, ReadPreference readPreference, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.ExecuteAttempt(RetryableReadContext context, Int32 attempt, Nullable`1 transactionNumber, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.RetryableReadOperationExecutor.Execute[TResult](IRetryableReadOperation`1 operation, RetryableReadContext context, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(RetryableReadContext context, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding binding, CancellationToken cancellationToken)
   at MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken)
   at MongoDB.Driver.MongoDatabase.ExecuteReadOperation[T](IClientSessionHandle session, IReadOperation`1 operation, ReadPreference readPreference, CancellationToken cancellationToken)
   at MongoDB.Driver.MongoDatabase.RunCommand[TResult](IClientSessionHandle session, Command`1 command, ReadPreference readPreference, CancellationToken cancellationToken)
   at MongoDB.Driver.MongoDatabase.<>c__DisplayClass49_0`1.<RunCommand>b__0(IClientSessionHandle session)
   at MongoDB.Driver.MongoDatabase.UsingImplicitSession[TResult](Func`2 func, CancellationToken cancellationToken)
   at MongoDB.Driver.MongoDatabase.RunCommand[TResult](Command`1 command, ReadPreference readPreference, CancellationToken cancellationToken)
   at Hangfire.Mongo.Migration.Strategies.Backup.CollectionMongoBackupStrategy.BackupCollection(IMongoDatabase database, String collectionName, String backupCollectionName)
   at Hangfire.Mongo.Migration.Strategies.Backup.CollectionMongoBackupStrategy.Backup(MongoStorageOptions storageOptions, IMongoDatabase database, MongoSchema fromSchema, MongoSchema toSchema)
   at Hangfire.Mongo.Migration.MongoMigrationManager.MigrateUp()
   at Hangfire.Mongo.MongoStorage..ctor(IMongoClient mongoClient, String databaseName, MongoStorageOptions storageOptions)
   at Hangfire.Mongo.MongoStorage..ctor(MongoClientSettings mongoClientSettings, String databaseName, MongoStorageOptions storageOptions)
   at Hangfire.Mongo.MongoBootstrapperConfigurationExtensions.UseMongoStorage(IGlobalConfiguration configuration, MongoClientSettings mongoClientSettings, String databaseName, MongoStorageOptions storageOptions)
   at Hangfire.Mongo.MongoBootstrapperConfigurationExtensions.UseMongoStorage(IGlobalConfiguration configuration, String connectionString, MongoStorageOptions storageOptions)
@gottscj
Copy link
Owner

gottscj commented Dec 25, 2024

@gunsh,

The $out operator is used for backing up collections before a migration. Consider using drop or none strategies instead. Let me know if it works out. :)

@gunsh
Copy link
Author

gunsh commented Dec 25, 2024

Well, I did have MigrateMongoMigrationStrategy but the database used for Hangfire was completely empty, hence nothing to migrate. I tried DropMongoMigrationStrategy per your suggestions but now I got a different error: Command create failed: capped collections are not allowed for serverless.

@gottscj
Copy link
Owner

gottscj commented Dec 25, 2024

@gunsh,

You need to set the SupportsCappedCollection option to false in the MongoOptions object.

Br

@gunsh
Copy link
Author

gunsh commented Dec 25, 2024

Okay, that finally did it. Thanks.

So far so good. In case it helps others, this is what I ended up using:

                    new MongoStorageOptions
                    {
                        SupportsCappedCollection = false,
                        MigrationOptions = new MongoMigrationOptions
                        {
                            MigrationStrategy = new DropMongoMigrationStrategy(),
                            BackupStrategy = new NoneMongoBackupStrategy(),
                        }
                    }

We'll see how it goes from here.

@gottscj
Copy link
Owner

gottscj commented Dec 25, 2024

@gunsh,

Thanks for sharing! ❤️

@gottscj gottscj closed this as completed Jan 4, 2025
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

No branches or pull requests

2 participants