Hi Sebastian,
In general, artifacts of updating queries should be cleaned up after the execution.
The stack trace indicates that a very large main-memory database instance was created by one of your queries that exceeded the memory limits. Can you share the query with us?
As XQuery is more powerful than pure query languages, it may be risky to allow the execution of arbitrary client code. First of all, you should ensure that the code is run with limited user permissions; otherwise, your system can be wiped out by a single file:delete('/', true()) call. Next, you could try to limit memory usage and execution time via the 'memory' and 'timeout' parameters [1]. However, as it’s close to impossible to reliably control the memory consumption of single threads in Java, I would rather suggest providing predefined user queries.
Espero que esto ayude, Christian
[1] https://docs.basex.org/wiki/XQuery_Module#xquery:eval
On Thu, May 28, 2020 at 8:39 PM Sebastian Guerrero chapeti@gmail.com wrote:
Hi BaseX team!
A quick question.
Is there some known bug/common setting missing for RESTXQ and memory problems?
I have this simple module ( into /webapp, a .xqm file ) :
module namespace exe = 'http://site.com/execute'; declare %updating %rest:path("update") %rest:consumes("application/x-www-form-urlencoded") %rest:POST function exe:update() {
xquery:eval-update(request:parameter("query"))
};
I use it to execute some updates against some databases from different clients.
Everything works fine by a while, but after some time I get this error [1]:
java.lang.OutOfMemoryError: Java heap space
I noticed that every call to update() the memory grows and grows until it reaches the OutOfMemoryError. [2]
If I stop the HTTP server, the memory is released immediately. [3]
What I'm doing wrong? Is there some command to execute the GC? Is this a problem with "xquery:eval-update()"? Am I using it in the wrong way?
Best regards, Sebastian. [1] https://imgur.com/DrcbwQg [2] https://imgur.com/fonmrhm [3] https://imgur.com/SYFBFK8