-
-
Notifications
You must be signed in to change notification settings - Fork 459
Improve MongoDB read model repopulation performance via BulkWriteAsync #1137
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
base: develop-v1
Are you sure you want to change the base?
Improve MongoDB read model repopulation performance via BulkWriteAsync #1137
Conversation
|
Fariarx seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
Remove the need for approvals on builds as legacy v0 builds have been stopped (was using Windows Server). |
|
|
||
| var collection = _mongoDatabase.GetCollection<TReadModel>(readModelDescription.RootCollectionName.Value); | ||
| var filter = Builders<TReadModel>.Filter.In(readModel => readModel.Id, modelIds); | ||
| var results = await collection.Find(filter).ToListAsync(cancellationToken: cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var results = await collection.Find(filter).ToListAsync(cancellationToken: cancellationToken); | |
| var results = await collection.Find(filter).ToListAsync(cancellationToken: cancellationToken).ConfigureAwait(false); |
|
|
||
| if (readModelContext.IsMarkedForDeletion) | ||
| { | ||
| await DeleteAsync(readModelUpdate.ReadModelId, c); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| await DeleteAsync(readModelUpdate.ReadModelId, c); | |
| await DeleteAsync(readModelUpdate.ReadModelId, c).ConfigureAwait(false); |
| x.ReadModelEnvelope.ReadModel) { IsUpsert = true }; | ||
|
|
||
| return replaceOneModel; | ||
| }), cancellationToken: c); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| }), cancellationToken: c); | |
| }), cancellationToken: c).ConfigureAwait(false); |
|
.review |
|
Findings
Next steps
Your friendly neighborhood AI |
|
@Fariarx let me know if the AI review has value and it seems there's a misalignment of your commit email and your GitHub user. Align those and submit the CLA ❤️ |
Changes:
Impact:
Significantly accelerates read model repopulation in MongoDB.
Production proven:
This change has been running in production for over a year with excellent stability and 2-4x performance improvement for batches >1000 events during repopulation.