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

Multi Upsert using dictionary incorrectly sets the TTL

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.5.2
    • 2.5.0, 2.5.1
    • None
    • None

    Description

      NCBC-1206 allows per-operation timeouts to be specified.

      However, as part of this change, the code for dictionary-based multi upserts incorrectly sets the timeout value as the expiration value instead:

      public IDictionary<string, IOperationResult<T>> Upsert<T>(IDictionary<string, T> items, TimeSpan timeout)
              {
                  CheckDisposed();
                  var results = new ConcurrentDictionary<string, IOperationResult<T>>();
                  if (items != null && items.Count > 0)
                  {
                      var keys = items.Keys.ToList();
                      var partitionar = Partitioner.Create(0, items.Count());
                      Parallel.ForEach(partitionar, (range, loopstate) =>
                      {
                          for (var i = range.Item1; i < range.Item2; i++)
                          {
                              var key = keys[i];
                              var value = items[key];
                              var result = Upsert(key, value, timeout);
                              results.TryAdd(key, result);
                          }
                      });
                  }
                  return results;
      }
      

      Which maps to the method signature:

      public IOperationResult<T> Upsert<T>(string key, T value, TimeSpan expiration)
              {
                  return Upsert(key, value, expiration.ToTtl());
      }
      

      Instead it needs to use the method which accepts an expiration (which has to be 0 anyway) AND a timeout.

      Attachments

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

        Activity

          People

            matt.carabine Matt Carabine (Inactive)
            matt.carabine Matt Carabine (Inactive)
            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