I know it’s 2020, but has anyone figured this out? I am also using .NET 2.7 SDK to execute an update statement directly to the cluster where _N1Q1Query is my update statement to be executed.
IQueryRequest request = new QueryRequest();
request
.Statement(_N1QLQuery)
.ScanConsistency(ScanConsistency.RequestPlus);
MutationCount returned 1. But the document sometimes update and sometimes do not. Success rate is 80% of the time. It seems like there is a bug in the Couchbase Database Server.
Please post the exact query and sample document.
Once WHERE clause is true the document is counted as mutated.
Actual mutation depends on various things.
Is SET path exist
Is there any cas mismatch
Sample Data
{
status = “In Progress”
type = “QtQ”
id = 123
}
C# Code
Cluster _cluster = new Cluster(new ClientConfiguration
{
Servers = uriList <==== I added all the nodes as array
});
_cluster.Authenticate(authenticator); <===Credential to nodes
IBucket _bucket = _cluster.OpenBucket("QBucket");
var _N1QLQuery = “UPDATE QBucket SET status = ‘Completed’ where type = ‘QtQ’ and id = 123”;
IQueryRequest request = new QueryRequest();
request
.Statement(_N1QLQuery)
.ScanConsistency(ScanConsistency.RequestPlus);
IQueryResult result = _bucket.QueryAsync(request).Result;
This isn’t related to your specific question, but using .Result on an async Task that might not be complete is an anti-pattern. It can cause deadlocks and thread pool depletion in your application. You should await the query instead.
I also recommend adding result.EnsureSuccessful(), which will cause an exception if there was an error executing the query. That might expose your problem.