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

TimeSpan expiration under 1 sec results in an infinite timeout

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.3.10
    • 1.3.6
    • None
    • None

    Description

      Starting in 1.3.6, when setting the TimeSpan expiration to less than 1 sec it appears to now round down to 0 which implies an infinite timeout. This does not currently have direct production impact, but this changed behavior broke the testing process for the customer.

      From the customer:

      "There looks to be 2 options to specify timeouts in .NET SDK, either with DateTime or with TimeSpan. Both of them technically allow users to specify timeouts with just a fraction of a second, even though internally Couchbase works with full seconds.

      Example:
      var result1 = client.ExecuteStore(StoreMode.Set, "a", 1, DateTime.UtcNow.AddMilliseconds(500));
      var result2 = client.ExecuteStore(StoreMode.Set, "b", 1, TimeSpan.FromMilliseconds(500));

      Behavior for first method remains unchanged. The DateTime value will get recalculated into UNIX time and rounded down to full seconds. The key "a" will then be stored in Couchbase with expiration equal to current time and will expire almost instantly. That is pretty much in line with what user intended.

      The problem is with the second method. In .NET SDK 1.3.5 this TimeSpan value would get recalculated into a UNIX time the same way as DateTime and result in the same behavior. But NCBC-485 changed this. From .NET SDK 1.3.6 this TimeSpan is passed into Couchbase as raw seconds. You trim the 0.5 second value down to 0 seconds and Couchbase server then interprets this as infinite timeout. But that is the complete opposite of what user actually intended."

      A fix suggestion is as follows:

      https://github.com/couchbase/couchbase-net-client/blob/release13/src/Enyim.Caching/MemcachedClient.cs
      line 1046 should be modified to:
      if (TimeSpan.FromSeconds(1) <= validFor && validFor < TimeSpan.FromSeconds(((60 * 60) * 24) * 30))

      Attachments

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

        Activity

          People

            jmorris Jeff Morris
            jdillon Jeff Dillon (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                PagerDuty