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

[BP MB-39077] Timers are not cancelled if multiple timers created with same refrence

    XMLWordPrintable

Details

    Description

      As per eventing specification for timersĀ 

      createTimer(callback, date, reference, context)

      reference

      This is a unique string that must be passed in to help identify the timer that is being created. References are always scoped to the function and callback they are used with and need to be unique only within this scope. The call returns the reference string if timer was created successfully. If multiple timers are created with the same unique reference, old timers with the same unique reference are implicitly cancelled. If the reference parameter is set to JavaScript null value, a unique reference will be generated. 

      Observed that with the following handler i am seeing that old timers with same unique reference are not cancelled

      function OnUpdate(doc,meta) {
          var expiry = new Date();
          expiry.setSeconds(expiry.getSeconds() + 150);    var context = {docID : meta.id, random_text : "e6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh0R7Aumoe6cZZGHuh07Aumoe6cZZGHuh07Aumoe6cZZGHuh07Aumoe6"};
          createTimer(timerCallback,  expiry, "hello", context);
      }
      function timerCallback(context) {
          dst_bucket[context.docID] = context.random_text;
      } 

      Attachments

        Issue Links

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

          Activity

            People

              jeelan.poola Jeelan Poola
              vikas.chaudhary Vikas Chaudhary
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty