Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-11548

Memcached does not handle going back in time.

    XMLWordPrintable

Details

    • Triaged
    • No

    Description

      When you change the time of server to be a time in the pass when the memcached process is running it will start expiring all documents with TTL.

      To recreate set date to a time in the past for example 2 hours ago from now.

      sudo date --set="15:56:56"

      You will see that time and uptime from cbstats will change to a large amount:

      time: 5698679116
      uptime: 4294946592

      Looking at the code we can see how this happens:
      http://src.couchbase.org/source/xref/2.5.1/memcached/daemon/memcached.c#6462

      When you change the time to a value in the past "process_started" will be greater than "timer.tv_sec" and current_time is unsigned which means it will wrap around.

      What I do not understand from the code is why current_time is the number of seconds since memcached started and not just the epoch time? (There is a comment about avoiding 64bit) .

      http://src.couchbase.org/source/xref/2.5.1/memcached/daemon/memcached.c#117

      Any case we should check if "process_started" is bigger than "timer.tv_sec" do something smart.

      I will let you decide what the smart thing is

      Attachments

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

        Activity

          People

            venu Venu Uppalapati (Inactive)
            pvarley Patrick Varley (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            13 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty