[CSHARP-2892] Regression in single node shards Created: 09/Jan/20  Updated: 27/Oct/23  Resolved: 01/Apr/20

Status: Closed
Project: C# Driver
Component/s: Session Management
Affects Version/s: 2.9.0, 2.9.1, 2.9.2, 2.9.3, 2.10.0, 2.10.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Bouke Haarsma Assignee: Dmitry Lukyanov (Inactive)
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

After upgrading the C# driver in our project from 2.8.1 to 2.10.1, we can no longer write changes to the database. We don't use sessions / transactions and have made no changes in our code. Downgrading to 2.8.1 resolves the issue. I've also confirmed the problem exists with 2.9.0 and 2.9.3.

The error is the following:

A write operation resulted in an error.
  Transaction numbers are only allowed on a replica set member or mongos ---> SimpleInjector.ActivationException: The registered delegate for type Service threw an exception. A write operation resulted in an error.
  Transaction numbers are only allowed on a replica set member or mongos ---> MongoDB.Driver.MongoWriteException: A write operation resulted in an error.
  Transaction numbers are only allowed on a replica set member or mongos ---> MongoDB.Driver.MongoBulkWriteException`1[Kolonel.Gateway.Model.ProcessInstance]: A bulk write operation resulted in one or more errors.
  Transaction numbers are only allowed on a replica set member or mongos
   at MongoDB.Driver.MongoCollectionImpl`1.BulkWrite(IClientSessionHandle session, IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken)

Our environment:

--- Sharding Status --- 
  sharding version: {
	"_id" : 1,
	"minCompatibleVersion" : 5,
	"currentVersion" : 6,
	"clusterId" : ObjectId("59edff6a06737a532cb09d97")
}
  shards:
	{  "_id" : "shard0000",  "host" : "tst-dbs01r1.cb.local:27018",  "state" : 1 }
	{  "_id" : "shard0001",  "host" : "tst-dbs02r1.cb.local:27018",  "state" : 1 }
  active mongoses:
	"3.6.14" : 3
 autosplit:
	Currently enabled: yes
  balancer:
	Currently enabled:  yes
	Currently running:  no
	Failed balancer rounds in last 5 attempts:  4
	Last reported error:  No route to host
	Time of Reported error:  Wed Sep 26 2018 11:58:42 GMT+0200 (CEST)
	Migration Results for the last 24 hours: 
		No recent migrations
  databases:
    (...)



 Comments   
Comment by Dmitry Lukyanov (Inactive) [ 01/Apr/20 ]

I think this issue happens because of retryable-writes https://docs.mongodb.com/manual/core/retryable-writes/ logic which is enabled by default now.
So, you can try two options:
1. Disable retryable writes
2. Use a replica set for each shard (single member is fine).
Let me know if you have further questions.

Comment by Bouke Haarsma [ 01/Apr/20 ]

That's correct. Those are machines are part of a development setup, originally configured with MongoDB 3.4.

Comment by Dmitry Lukyanov (Inactive) [ 01/Apr/20 ]

Hello bhaarsma@yellowtail.nl,
Am I right, that your shards are standalones and not replica set?

Comment by Bouke Haarsma [ 25/Mar/20 ]

@dmitry.lukyanov can you reopen this issue?

Comment by Bouke Haarsma [ 13/Feb/20 ]

Sorry for the delay in getting back to you. Could you reopen the ticket?

1. Full error message:

A bulk write operation resulted in one or more errors.
  Transaction numbers are only allowed on a replica set member or mongos
   at MongoDB.Driver.MongoCollectionBase`1.InsertOne(TDocument document, InsertOneOptions options, Action`2 bulkWrite)
   at MongoDB.Driver.MongoCollectionBase`1.InsertOne(TDocument document, InsertOneOptions options, CancellationToken cancellationToken)
   at UserQuery.Main() in C:\Users\Bouke\AppData\Local\Temp\LINQPad5\_ismpqqoy\query_nzyhzp.cs:line 44
   at LINQPad.ExecutionModel.ClrQueryRunner.Run()
   at LINQPad.ExecutionModel.Server.RunQuery(QueryRunner runner)
   at LINQPad.ExecutionModel.Server.StartQuery(QueryRunner runner)
   at LINQPad.ExecutionModel.Server.<>c__DisplayClass153_0.<ExecuteClrQuery>b__0()
   at LINQPad.ExecutionModel.Server.SingleThreadExecuter.Work()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

2. Code to reproduce:

public class Customer {
	public string Id { get; set; }
}
 
void Main()
{
    new MongoClient("mongodb://mongos")
        .GetDatabase("test")
        .GetCollection<Customer>("test")
        .InsertOne(new Customer {});
}

3. Shard config:
See ticket description. Is there anything else you'd like to receive?

4. Driver version:
I incorrectly wrote 2.10.1, but I meant 2.10.0 at the time. As of now 2.10.1 is released and shows the same regression.

Comment by Dmitry Lukyanov (Inactive) [ 16/Jan/20 ]

Hello bhaarsma@yellowtail.nl,

Can you please provide some additional information:
1. The full error message together with stack trace.
2. Steps to reproduce. Also, It will be great if you can provide a small console application that causes the ticket situation.
3. The latest shard config.
4. Also, can you confirm which driver versions have you checked and where the error has been triggered? You wrote about 2.10.1, but this driver version has been published after the ticket creation date. So, please check it.

Please let me know if you have any questions about the above.

Generated at Wed Feb 07 21:43:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.