Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-69480

TransientTransactionError label potentially applied incorrectly

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL
    • Hide

      1. Setup Environment (single node replica set, MongoDB 6.0.1)

      # MongoDB 6.0.1-ent
      mongod --dbpath data --replSet rs0 --wiredTigerCacheSizeGB 1
      mongosh --quiet --eval 'rs.initiate()'
      

      2. Test with C# Driver (2.17.1 / .NET 6.0)

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      using MongoDB.Bson;
      using MongoDB.Driver;
      
      Random random = new();
      void Log(string value)
      {
          Console.WriteLine($"{DateTime.Now}: {value}");
      }
      string RandomString(int length)
      {
          const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
          return new string(Enumerable.Repeat(chars, length)
              .Select(s => s[random.Next(s.Length)]).ToArray());
      }
      
      Log("Starting");
      var junk = RandomString(1024 * 1024 * 5);
      
      var client = new MongoClient("mongodb://localhost:27017/test?retryWrites=true");
      var db = client.GetDatabase("test");
      
      var cacheSize = db.RunCommand<BsonDocument>(new BsonDocument("serverStatus", 1))["wiredTiger"]["cache"]["maximum bytes configured"].AsInt32;
      Log($"WiredTiger Cache = {cacheSize}");
      var collection = db.GetCollection<BsonDocument>("test");
      
      string? result = null;
      
      using (var session = client.StartSession())
      {
          var transactionOptions = new TransactionOptions(
              readPreference: ReadPreference.Primary,
              readConcern: ReadConcern.Local,
              writeConcern: WriteConcern.WMajority);
      
          var cancellationToken = CancellationToken.None; // normally a real token would be used
          result = session.WithTransaction(
              (s, ct) =>
              {
                  for (var i = 0; i < 50; i++)
                  {
                      collection.InsertOne(s, new BsonDocument { { "junk", junk } }, cancellationToken: ct);
                  }            
                  return "Success!";
              },
              transactionOptions,
              cancellationToken);
      }
      
      Log("Done");
      
      Show
      1. Setup Environment (single node replica set, MongoDB 6.0.1) # MongoDB 6.0.1-ent mongod --dbpath data --replSet rs0 --wiredTigerCacheSizeGB 1 mongosh --quiet --eval 'rs.initiate()' 2. Test with C# Driver (2.17.1 / .NET 6.0) Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml using MongoDB.Bson; using MongoDB.Driver; Random random = new (); void Log(string value) { Console.WriteLine($ "{DateTime.Now}: {value}" ); } string RandomString( int length) { const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ; return new string(Enumerable.Repeat(chars, length) .Select(s => s[random.Next(s.Length)]).ToArray()); } Log( "Starting" ); var junk = RandomString(1024 * 1024 * 5); var client = new MongoClient( "mongodb: //localhost:27017/test?retryWrites= true " ); var db = client.GetDatabase( "test" ); var cacheSize = db.RunCommand<BsonDocument>( new BsonDocument( "serverStatus" , 1))[ "wiredTiger" ][ "cache" ][ "maximum bytes configured" ].AsInt32; Log($ "WiredTiger Cache = {cacheSize}" ); var collection = db.GetCollection<BsonDocument>( "test" ); string? result = null ; using ( var session = client.StartSession()) { var transactionOptions = new TransactionOptions( readPreference: ReadPreference.Primary, readConcern: ReadConcern.Local, writeConcern: WriteConcern.WMajority); var cancellationToken = CancellationToken.None; // normally a real token would be used result = session.WithTransaction( (s, ct) => { for ( var i = 0; i < 50; i++) { collection.InsertOne(s, new BsonDocument { { "junk" , junk } }, cancellationToken: ct); } return "Success!" ; }, transactionOptions, cancellationToken); } Log( "Done" );
    • Execution Team 2022-10-31, Execution Team 2022-11-28

      The log message for MongoDB 6.0 is:

      Unable to find source-code formatter for language: noformat. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      {"t":{"$date":"2022-09-06T15:19:36.865-04:00"},"s":"I","c":"COMMAND","id":51803,"ctx":"conn11","msg":"Slow query","attr":{"type":"command","ns":"test.test","command":{"insert":"test","ordered":true,"$db":"test","lsid":{"id":{"$uuid":"b8d52586-f9d3-4833-aa4a-a2d9b1aa88c1"}},"$clusterTime":{"clusterTime":{"$timestamp":{"t":1662491969,"i":1}},"signature":{"hash":{"$binary":{"base64":"AAAAAAAAAAAAAAAAAAAAAAAAAAA=","subType":"0"}},"keyId":0}},"txnNumber":1,"autocommit":false},"ninserted":0,"numYields":0,"ok":0,"errMsg":"WiredTigerIdIndex::_insert: index: _id_; uri: table:index-39-129709413832108471 :: caused by :: WriteConflict error: this operation conflicted with another operation. Please retry your operation or multi-document transaction.","errName":"WriteConflict","errCode":112,"reslen":490,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":1,"w":3}},"ReplicationStateTransition":{"acquireCount":{"w":6}},"Global":{"acquireCount":{"r":1,"w":3}},"Database":{"acquireCount":{"w":3}},"Collection":{"acquireCount":{"r":1,"w":3}},"Mutex":{"acquireCount":{"r":39}}},"flowControl":{"acquireCount":1,"timeAcquiringMicros":1},"readConcern":{"level":"local","provenance":"clientSupplied"},"storage":{"timeWaitingMicros":{"cache":139271}},"remote":"127.0.0.1:62025","protocol":"op_msg","durationMillis":185}}
      

      Previously (MongoDB 5.0) this was logged as follows (likely due to WT-8290 not being backported):

      Unable to find source-code formatter for language: noformat. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      {"t":{"$date":"2022-09-06T14:41:54.550-04:00"},"s":"I","c":"STORAGE","id":22430,"ctx":"conn5","msg":"WiredTiger message","attr":{"message":"oldest pinned transaction ID rolled back for eviction"}}
      {"t":{"$date":"2022-09-06T14:41:54.550-04:00"},"s":"I","c":"TXN","id":51802,"ctx":"conn5","msg":"transaction","attr":{"parameters":{"lsid":{"id":{"$uuid":"a5596ab7-9c31-4198-9548-7fc30bd8e61a"},"uid":{"$binary":{"base64":"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=","subType":"0"}}},"txnNumber":1,"autocommit":false,"readConcern":{"level":"local","provenance":"clientSupplied"}},"readTimestamp":"Timestamp(0, 0)","ninserted":29,"keysInserted":29,"terminationCause":"aborted","timeActiveMicros":1240154,"timeInactiveMicros":321842,"numYields":0,"locks":{"ReplicationStateTransition":{"acquireCount":{"w":5}},"Global":{"acquireCount":{"r":1,"w":2}},"Database":{"acquireCount":{"w":2}},"Collection":{"acquireCount":{"w":2}},"Mutex":{"acquireCount":{"r":31}}},"storage":{"data":{"bytesRead":13101},"timeWaitingMicros":{"cache":739459}},"wasPrepared":false,"durationMillis":1561}}
      

      The transactions specification (Interaction with Retryable Writes) indicates that:

      In MongoDB 4.0 the only supported retryable write commands within a transaction are `commitTransaction` and `abortTransaction`. Therefore drivers MUST NOT retry write commands within transactions even when `retryWrites` has been enabled on the MongoClient. In addition, drivers MUST NOT add the `RetryableWriteError` label to any error that occurs during a write command within a transaction (excepting `commitTransation` and `abortTransaction`), even when `retryWrites` has been enabled on the MongoClient.

      It appears here that the failure isn't with the write itself but updating the indexes. Should this still be labelled as a TransientTransactionError?

      Screenshot of the reproduction running in Visual Studio 2022 below:

        1. server-69480.js
          0.9 kB
        2. screenshot-1.png
          screenshot-1.png
          166 kB

            Assignee:
            yujin.kang@mongodb.com Yujin Kang Park
            Reporter:
            alex.bevilacqua@mongodb.com Alex Bevilacqua
            Votes:
            2 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: