Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-1458

KeyNotFoundException when UseEnhancedDurability is true

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.4.7
    • Fix Version/s: 2.4.7
    • Component/s: library
    • Labels:

      Description

      ..ClientFailure System.Collections.Generic.KeyNotFoundException: The given key was not present in
      the dictionary.
      at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
      at Couchbase.Core.Buckets.VBucketKeyMapper.get_Item(Int32 index) in C:\Users\jmorris\repos\couchb
      ase-net-client\Src\Couchbase\Core\Buckets\VBucketKeyMapper.cs:line 46
      at Couchbase.Core.Buckets.KeySeqnoObserver.<ObserveAsync>d__11.MoveNext() in C:\Users\jmorris\rep
      os\couchbase-net-client\Src\Couchbase\Core\Buckets\KeySeqnoObserver.cs:line 212
      — End of stack trace from previous location where exception was thrown —
      at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

      at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
      at Couchbase.Core.Buckets.CouchbaseRequestExecuter.<SendWithDurabilityAsync>d__10`1.MoveNext() in
      C:\Users\jmorris\repos\couchbase-net-client\Src\Couchbase\Core\Buckets\CouchbaseRequestExecuter.cs:
      line 358
      ...ClientFailure System.Collections.Generic.KeyNotFoundException: The given key was not present in t
      he dictionary.
      at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
      at Couchbase.Core.Buckets.VBucketKeyMapper.get_Item(Int32 index) in C:\Users\jmorris\repos\couchb
      ase-net-client\Src\Couchbase\Core\Buckets\VBucketKeyMapper.cs:line 46
      at Couchbase.Core.Buckets.KeySeqnoObserver.<ObserveAsync>d__11.MoveNext() in C:\Users\jmorris\rep
      os\couchbase-net-client\Src\Couchbase\Core\Buckets\KeySeqnoObserver.cs:line 212

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

          Hide
          mike.goldsmith Michael Goldsmith added a comment -

          Jeff Morris - again, I can't replicate issue from title and stack trace. Please can you provide a code sample? Thanks.

          Show
          mike.goldsmith Michael Goldsmith added a comment - Jeff Morris - again, I can't replicate issue from title and stack trace. Please can you provide a code sample? Thanks.
          Hide
          jmorris Jeff Morris added a comment - - edited

          Michael Goldsmith This was reported by QE and I was able to reproduce; you'll need more than 1 node and then run a loop of async get/sets w/UseEnhancedAuthentication to true and have PeristTo and ReplicaTo set to Zero.

           

          using System.Collections.Generic;
          using System.Threading;
          using System.Threading.Tasks;
          using Couchbase;
          using Couchbase.Core;;
          using Couchbase.N1QL;
          using Couchbase.Views;
          namespace Tester
          {
              class Program
              {
                  public static string BucketName = "default";
                  public static string[] payload = new string[10];
                  static void Main(string[] args)
                  {
                      var config = TestConfiguration.GetConfiguration("basic");
                      config.BucketConfigs[BucketName].PoolConfiguration.MaxSize = 1;
                      config.BucketConfigs[BucketName].PoolConfiguration.MaxSize = 2;
                      config.BucketConfigs[BucketName].UseEnhancedDurability = true;
                      ClusterHelper.Initialize(config);
           
                      var threads = new List<Thread>();
                      for (int i = 0; i < 10; i++)
                      {
                          threads.Add(new Thread(DoUpsertAsync));
                      }
                      var bucket = ClusterHelper.GetBucket(BucketName);
                      foreach (var thread in threads)
                      {
                          thread.Start(bucket);
                      }
                      foreach (var thread in threads)
                      {
                          thread.Join();
                      }
                      Console.Read();
                      ClusterHelper.Close();
                  }
                  static async void DoUpsertAsync(object state)
                      {
                      var bucket = state as IBucket;
                      {
                          for (int x = 0; x < 100000; x++)
                          {
                              var doc = new Document<dynamic>
                              {
                                  Id = "upsert" + x,
                                  Content = new {}
                              };
                              IDocumentResult<dynamic> result = null;
                              try
                              {
                                  if (x % 2 == 0)
                                  {
                                      result = await bucket.UpsertAsync(doc, ReplicateTo.Zero, PersistTo.Zero);
                                  }
                                  else
                                  {
                                      result = await bucket.GetDocumentAsync<dynamic>(doc.Id);
                                  }
                              }
                              catch (Exception e)
                              {
                                  Console.Write(e);
                              }
                              if (result != null && !result.Success)
                              {
                                  Console.WriteLine(result.Status + " " + result.Exception);
                              }
                              else
                              {
                                  Console.Write(".");
                              }
                          }
                          Thread.Sleep(2000);
                      }
                  }
              }
          }

          I suspect that one of the connections created during bootstrapping doesn't get set to use enhanced auth; once a reconfig happens the connections are wiped out and the newly created one's are set properly.

          Show
          jmorris Jeff Morris added a comment - - edited Michael Goldsmith This was reported by QE and I was able to reproduce; you'll need more than 1 node and then run a loop of async get/sets w/UseEnhancedAuthentication to true and have PeristTo and ReplicaTo set to Zero.   using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Couchbase; using Couchbase.Core;; using Couchbase.N1QL; using Couchbase.Views; namespace Tester {     class Program     {         public static string BucketName = "default" ;         public static string[] payload = new string[ 10 ];         static void Main(string[] args)         {             var config = TestConfiguration.GetConfiguration( "basic" );             config.BucketConfigs[BucketName].PoolConfiguration.MaxSize = 1 ;             config.BucketConfigs[BucketName].PoolConfiguration.MaxSize = 2 ;             config.BucketConfigs[BucketName].UseEnhancedDurability = true ;             ClusterHelper.Initialize(config);               var threads = new List<Thread>();             for ( int i = 0 ; i < 10 ; i++)             {                 threads.Add( new Thread(DoUpsertAsync));             }             var bucket = ClusterHelper.GetBucket(BucketName);             foreach (var thread in threads)             {                 thread.Start(bucket);             }             foreach (var thread in threads)             {                 thread.Join();             }             Console.Read();             ClusterHelper.Close();         }         static async void DoUpsertAsync(object state)             {             var bucket = state as IBucket;             {                 for ( int x = 0 ; x < 100000 ; x++)                 {                     var doc = new Document<dynamic>                     {                         Id = "upsert" + x,                         Content = new {}                     };                     IDocumentResult<dynamic> result = null ;                     try                     {                         if (x % 2 == 0 )                         {                             result = await bucket.UpsertAsync(doc, ReplicateTo.Zero, PersistTo.Zero);                         }                         else                         {                             result = await bucket.GetDocumentAsync<dynamic>(doc.Id);                         }                     }                     catch (Exception e)                     {                         Console.Write(e);                     }                     if (result != null && !result.Success)                     {                         Console.WriteLine(result.Status + " " + result.Exception);                     }                     else                     {                         Console.Write( "." );                     }                 }                 Thread.Sleep( 2000 );             }         } } } I suspect that one of the connections created during bootstrapping doesn't get set to use enhanced auth; once a reconfig happens the connections are wiped out and the newly created one's are set properly.

            People

            • Assignee:
              jmorris Jeff Morris
              Reporter:
              jmorris Jeff Morris
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes

                  PagerDuty

                  Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.