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

[UDF] possible handle leak in jsevaluator

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Major
    • 7.1.0
    • 7.1.0
    • js-evaluator
    • None
    • Untriaged
    • 1
    • Unknown

    Description

      Consider the following testcase

      $ cat tc1.js
      function tc1() {
              var q1 = SELECT * FROM [1,2,3,4] vals;
              var res = [];
              for (const row of q1) {
                      res.push(row);
                      break;                  // leave iterator open
              }
              return res;
      }
      $ curl -s -k -X POST http://127.0.0.1:8093/evaluator/v1/libraries/tc1 -u Administrator:password -H 'content-type: application/json' --data-binary @tc1.js
      $ curl http://localhost:8093/query/service -d 'statement=CREATE OR REPLACE FUNCTION tc1() LANGUAGE JAVASCRIPT AS "tc1" AT "tc1"' -u Administrator:password
      $ curl http://localhost:8093/query/service -d 'statement=execute function tc1()' -u Administrator:password              {
      "requestID": "b9288531-52d0-4879-890e-bf7ddfe5b79c",
      "signature": null,
      "results": [
      [{"vals":1}]
      ],
      "status": "success",
      "metrics": {"elapsedTime": "6.754335ms","executionTime": "6.717199ms","resultCount": 1,"resultSize": 12,"serviceLoad": 2}
      }
      

      Note that the function purposely does not complete getting all the documents.
      At function return, the query handle for q1 is left open (this has been verified by instrumentation).
      Although this is a user error, the handle (and execution pipeline, and goroutine, and value) leak is real.

      On function exit the jsevaluator should go through the list of handles opened by the function, and Cancel() them.

      If the jsevaluator doesn't have a list of handles per executing function, upon exiting the outermost function, it should close all the handles for the corresponding Context.

      Attachments

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

        Activity

          People

            marco.greco Marco Greco (Inactive)
            marco.greco Marco Greco (Inactive)
            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