Revisions: Conflict Revisions Configuration


  • RavenDB can create revisions for document conflicts when the conflicts occur and when they are resolved.

  • To manage the creation and purging of revisions for conflicting documents, a Conflict Revisions Configuration can be applied using the ConfigureRevisionsForConflictsOperation store operation .
    This configuration applies to all document collections.

  • RavenDB applies a conflict revisions configuration by default.
    You will only need to run the operation yourself if you want to disable the feature or change its characteristics (e.g. to modify the number of conflict revisions kept per document).

  • If you defined default settings for your Revisions configuration, these settings will override the conflict revisions configuration.

    • E.g., if the default configuration settings disable the creation of revisions, no revisions will be created for conflicting documents.
  • Collection-specific configurations will also override the conflict revisions configuration, for the collections they are defined for.

    • E.g., if the document conflicts 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.
  • In this page:


ConfigureRevisionsForConflictsOperation

Pass ConfigureRevisionsForConflictsOperation the name of the database whose conflict revisions you want to manage, and a RevisionsCollectionConfiguration object with your settings.

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

Storage Considerations

Tracking document conflicts and understanding their reasons becomes much easier when conflict revisions are created automatically.
However, if many conflicts occur unexpectedly it may trigger the creation of a large number of conflict revisions and increase the database size significantly.

Example

In this example we create a Conflict Revisions configuration that purges conflict revisions when their parent documents are deleted or their age exceeds 45 days.

// Modify the document conflicts configuration
documentStore.Maintenance.Server.Send(
new ConfigureRevisionsForConflictsOperation(documentStore.Database,
    new RevisionsCollectionConfiguration
    {
        // Purge conflict revisions upon their parent document deletion
        PurgeOnDelete = true,

        // Limit the number of conflict revisions by age, to 45 days
        MinimumRevisionAgeToKeep = new TimeSpan(days: 45, 0, 0, 0)
    }));
// Modify the document conflicts configuration
await documentStore.Maintenance.Server.SendAsync(
new ConfigureRevisionsForConflictsOperation(documentStore.Database,
    new RevisionsCollectionConfiguration
    {
        // Purge conflict revisions upon their parent document deletion
        PurgeOnDelete = true,

        // Limit the number of conflict revisions by age, to 45 days
        MinimumRevisionAgeToKeep = new TimeSpan(days: 45, 0, 0, 0)
    }));