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

opaque object inside a Cron timer is assumed to be a string which causes unmarshal errors

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 6.5.0
    • 5.5.0
    • eventing
    • Enterprise Edition 5.5.0 build 2176

    Description

      Eventing code to Repro

      function OnUpdate(doc,meta) {
          var expiry = Math.round((new Date()).getTime() / 1000) + 30;
          var time_rand = random_gen(); // ----> int
          log('creating crontimer : ', time_rand);
          cronTimer(NDtimerCallback, time_rand, expiry);
      }
      function NDtimerCallback(docid, expiry) {
          log('creating bucket op : ', docid);
          dst_bucket[docid] = 'from NDtimerCallback';
      }
      function random_gen(){
          var rand = Math.floor(Math.random() * 20000000) * Math.floor(Math.random() * 20000000);
          var time_rand = Math.round((new Date()).getTime() / 1000) + rand;
          return time_rand;
      }
      

      Since time_rand is an int and we assume its going to be a string we see unmarshal errors and following messages are seen in eventing log

      2018-03-14T00:07:44.095-07:00 [Error] Consumer::getCronTimerCallback [worker_cron_timer_op_retry_1:/tmp/127.0.0.1:8091_worker_cron_timer_op_retry_1.sock:27944] Bucket fetch failed for cron timer key: <ud>cron_timer_op_retry::2018-03-14T07:07:24Z0</ud> val: <ud>&{[{NDtimerCallback }] }</ud>, err: json: cannot unmarshal number into Go value of type string
      

      Cron timer data from metadata bucket

      {
        "cron_timers": [{
          "callback_func": "NDtimerCallback",
          "payload": 274700495669869
        }, {
          "callback_func": "NDtimerCallback",
          "payload": 185158701515478
        }, {
          "callback_func": "NDtimerCallback",
          "payload": 10458915851862
        }],
        "counter": 3,
        "version": "vulcan"
      }
      

      Logs attached.

      Attachments

        Issue Links

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

          Activity

            People

              Gautham.Banasandra Gautham Banasandra (Inactive)
              Balakumaran.Gopal Balakumaran Gopal
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty