Cluster-wide transactions on client failover #15700
-
Tested with 5.4.5. References to earlier discussions: When a document is loaded and changed, and a client fails over to a different node before the call to
To replicate, you can use the code below. Place a breakpoint on line 30 ( After continuing, the exception is thrown. Should this be handled gracefully? using Raven.Client.Documents;
using Raven.Client.Documents.Session;
namespace RavenDB5Tests.Tryouts
{
public static class ClusterWideTransactions2
{
public static void ClusterWideTransactions2Test()
{
using (var store = new DocumentStore
{
Urls = new[] { "http://localhost:8081", "http://localhost:8082", "http://localhost:8083" },
Database = "ClusterWideTransactions2Test",
}.Initialize())
{
using (var session = store.OpenSession(new SessionOptions { TransactionMode = TransactionMode.ClusterWide }))
{
var existingDoc = session.Load<Doc>("doc-1");
if (existingDoc == null)
{
var doc = new Doc { Id = "doc-1", NumVal = 1 };
session.Store(doc);
session.SaveChanges();
}
}
using (var session = store.OpenSession(new SessionOptions { TransactionMode = TransactionMode.ClusterWide }))
{
var doc1 = session.Load<Doc>("doc-1");
doc1.NumVal++;
// if the node used for document loading is brought down here, the session.SaveChanges() below fails:
// Raven.Client.Exceptions.ClusterTransactionConcurrencyException:
// 'Failed to execute cluster transaction due to the following issues: Guard compare exchange value
// 'rvn-atomic/doc-1' index does not match the transaction index's 0 change vector on doc-1
// Concurrency check failed for putting the key 'rvn-atomic/doc-1'.Requested index: 0, actual index: 342'
session.SaveChanges();
}
}
}
public class Doc
{
public string Id { get; set; }
public int NumVal { get; set; }
}
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
This is not expected, no. |
Beta Was this translation helpful? Give feedback.
-
The bug was reproduced. |
Beta Was this translation helpful? Give feedback.
The bug was reproduced.
You can track working progress here:
https://issues.hibernatingrhinos.com/issue/RavenDB-19887/Cluster-wide-transactions-on-client-failover