Configure Conflict Revisions Operation
-
By default, RavenDB creates revisions for conflict documents for all collections
when conflicts occur and when they are resolved. -
Use
ConfigureRevisionsForConflictsOperation
to disable the feature or modify the configuration. -
If you define default configuration,
then these settings will override the conflict revisions configuration. -
If you define any collection-specific configuration,
then these settings will also override the conflict revisions configuration for that collection.- E.g., if the conflict revisions configuration defines that revisions created for conflicting documents will not be purged,
but a collection-specific configuration defines an age limit for revisions,
revisions for conflicting documents of this collection that exceed this age will be purged.
- E.g., if the conflict revisions configuration defines that revisions created for conflicting documents will not be purged,
but a collection-specific configuration defines an age limit for revisions,
-
In this page:
Configure revisions for conflicts - Example
// Define the settings that will apply for conflict revisions (for all collections)
var conflictRevConfig = new RevisionsCollectionConfiguration
{
PurgeOnDelete = true,
MinimumRevisionAgeToKeep = new TimeSpan(days: 45, 0, 0, 0)
// With this configuration:
// ------------------------
// * A revision will be created for conflict documents
// * When the parent document is deleted all its revisions will be removed.
// * Revisions that exceed 45 days will be removed on next revision creation.
};
// Define the configure conflict revisions operation, pass the configuration
var configureConflictRevisionsOp =
new ConfigureRevisionsForConflictsOperation(documentStore.Database, conflictRevConfig);
// Execute the operation by passing it to Maintenance.Server.Send
// The existing conflict revisions configuration will be replaced by the configuration passed
documentStore.Maintenance.Server.Send(configureConflictRevisionsOp);
// Define the settings that will apply for conflict revisions (for all collections)
var conflictRevConfig = new RevisionsCollectionConfiguration
{
PurgeOnDelete = true,
MinimumRevisionAgeToKeep = new TimeSpan(days: 45, 0, 0, 0)
// With this configuration:
// ------------------------
// * A revision will be created for conflict documents
// * When the parent document is deleted all its revisions will be removed.
// * Revisions that exceed 45 days will be removed on next revision creation.
};
// Define the configure conflict revisions operation, pass the configuration
var configureConflictRevisionsOp =
new ConfigureRevisionsForConflictsOperation(documentStore.Database, conflictRevConfig);
// Execute the operation by passing it to Maintenance.Server.Send
// The existing conflict revisions configuration will be replaced by the configuration passed
await documentStore.Maintenance.Server.SendAsync(configureConflictRevisionsOp);
Syntax
public ConfigureRevisionsForConflictsOperation(string database, RevisionsCollectionConfiguration configuration)
Parameter | Type | Description |
---|---|---|
database | string |
The name of the database whose conflict revisions you want to manage |
configuration | RevisionsCollectionConfiguration |
The conflict revisions configuration to apply |
public class RevisionsCollectionConfiguration
{
public long? MinimumRevisionsToKeep { get; set; }
public TimeSpan? MinimumRevisionAgeToKeep { get; set; }
public long? MaximumRevisionsToDeleteUponDocumentUpdate { get; set; }
public bool PurgeOnDelete { get; set; }
public bool Disabled { get; set; }
}
- See properties explanation and default values here.
Storage consideration
Automatic creation of conflict revisions can help track document conflicts and understand their reasons.
However, it can also lead to a significant increase in the database size if many conflicts occur unexpectedly.
-
Consider limiting the number of conflict revisions kept per document using:
MinimumRevisionsToKeep
and/orMinimumRevisionAgeToKeep
. -
Revisions are purged upon modification of their parent documents.
If you want to purge a large number of revisions at once, you can cautiously enforce configuration.