We are using cluster-wide transactions and we get the error mentioned in the subject line when updating a document. To update the document, first, we load it from the database, modify some fields and then have it saved using the provided ChangeVector
and the Id
. My understanding is that supplying ChangeVector
enables optimistic concurrency for that session only which is our intention.
Here is the code snippet:
var taxToUpdate = await session.LoadAsync<Tax>(myTax.Id, cancellationToken);
taxToUpdate.Description = "Updated description";
await session.StoreAsync(taxToUpdate , myTax.ChangeVector, myTax.Id, cancellationToken);
await session.SaveChangesAsync(cancellationToken);
The stack trace reads as:
Raven.Client.Documents.Session.InMemoryDocumentSessionOperations.ValidateClusterTransaction(SaveChangesData result) in C:\Builds\RavenDB-Stable-5.1\51010\src\Raven.Client\Documents\Session\InMemoryDocumentSessionOperations.cs:line 883 at Raven.Client.Documents.Session.Operations.BatchOperation.CreateRequest() in C:\Builds\RavenDB-Stable-5.1\51010\src\Raven.Client\Documents\Session\Operations\BatchOperation.cs:line 41 at Raven.Client.Documents.Session.AsyncDocumentSession.d__31.MoveNext() in C:\Builds\RavenDB-Stable-5.1\51010\src\Raven.Client\Documents\Session\AsyncDocumentSession.cs:line 157 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
What is the solution for this problem as using ChangeVector
is a must in our application's context?