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

Small TTL values can get lost by client/server clock-drift

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.4
    • Fix Version/s: 1.3.6
    • Component/s: None
    • Labels:
      None

      Description

      The .NET client library always sends TTL values as absolute "since EPOCH" time-stamps. This causes problems if you have a small TTL and there's clock-drift between client server.

      Example
      client clock is 14:00
      server clock is 13:58 (not uncommon to have minutes of drift)
      client adds a document with a 10 second TTL. This is actually sent as 14:00:10

      The client will find the document still lives until the server clock reaches 14:00:10, some 2 minutes later than when the document was added.

      CB server overloads the time-stamp field in the memcached wire protocol. The 4-byte field used for TTL info is interpreted as an absolute UTC, EPOCH timestamp for values over 2592000 seconds (30 days since EPOCH). Values under that are just treated as seconds to live.

      For the Store method which accepts a TimeSpan TTL we should be sending TTLs under 30 days as seconds, not EPOCH. This protects the client against the clock drift issues.

      The DateTime Store method must be left alone and always send EPOCH TTL.

        Attachments

          Issue Links

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

            Activity

            Show
            jwalker Jim Walker added a comment - http://review.couchbase.org/#/c/37443/
            Hide
            ingenthr Matt Ingenthron added a comment -

            Nicely done Jim!

            Show
            ingenthr Matt Ingenthron added a comment - Nicely done Jim!
            Hide
            jmorris Jeff Morris added a comment -

            And with unit tests?! Awesome!!!

            Show
            jmorris Jeff Morris added a comment - And with unit tests?! Awesome!!!
            Hide
            jwalker Jim Walker added a comment -

            I was looking to hit "close issue", but didn't spot this patch in the github change log? Will that happen closer to the next .NET library release?

            Show
            jwalker Jim Walker added a comment - I was looking to hit "close issue", but didn't spot this patch in the github change log? Will that happen closer to the next .NET library release?
            Hide
            jmorris Jeff Morris added a comment -

            Jim - yeah, I am targeting Thursday as the release date for 1.3.6.

            Show
            jmorris Jeff Morris added a comment - Jim - yeah, I am targeting Thursday as the release date for 1.3.6.
            Hide
            jmorris Jeff Morris added a comment -

            This has been merged, you can close the ticket.

            Thanks,

            Jeff

            Show
            jmorris Jeff Morris added a comment - This has been merged, you can close the ticket. Thanks, Jeff

              People

              Assignee:
              jwalker Jim Walker
              Reporter:
              jwalker Jim Walker
              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