Details
-
Bug
-
Resolution: Fixed
-
Critical
-
7.1.0
-
None
-
Untriaged
-
1
-
Unknown
Description
Create a bucket default and insert a few documents:
INSERT INTO default VALUES(uuid(),
{"f1": 1});
INSERT INTO default VALUES(uuid(),
);
INSERT INTO default VALUES(uuid(),
);
INSERT INTO default VALUES(uuid(),
);
INSERT INTO default VALUES(uuid(),
);
INSERT INTO default VALUES(uuid(),
);
....(do it a few hundred times)
create the following javascript function:
function somedml()
{ var q = UPDATE default SET f1 = 2; }create and execute the UDF:
CREATE FUNCTION somedml() LANGUAGE javascript AS "somedml" AT "test";
EXECUTE FUNCTION dml();
This function updates default.
Now try with a RETURNING clause:
function somedml()
{ var q = UPDATE default SET f1 = 2 RETURNING f1; }You will find that depending on own many results are returned, and definitely if more than 512 results are, only part of the documents are updated.
This is because the jsevaluator will cancel any outstanding statements that haven't pulled all the results.
Everything works if you scan the whole iterator.
The fix here is for the jsevaluator, on exit, to check the mutation count for each handle (after doing the last NextDocument()) and cancelling if it is 0, or Complete()ing if it's not 0.
FYI handle.Complete() consumes the results, so it has no memory impact.