Thanks.

Any thoughts on why it would clear up after 3-4 attempts of running the query?



From: Christian Grün <christian.gruen@gmail.com>
To: buddyonweb-software <buddyonweb-software@yahoo.com>
Cc: BaseX Talk <basex-talk@mailman.uni-konstanz.de>
Sent: Wednesday, December 21, 2016 8:31 AM
Subject: Re: [basex-talk] Tail Recursion Error on startup

Hi Buddy,

> If we attempt to execute it again (sometimes twice, but have done so
> repeatedly up to 5 times), the error goes away and all is fine.

Difficult to say why this happens. Maybe your code is rewritten by
Java’s JIT compiler.


> Is there anything you can suggest or anything we can provide you to see how
> to eliminate this.  This is particularly problematic on our server when we
> reboot our production application.
> Anything you can suggest or anyway we can help is much appreciated.


The problem itself is a generic one and not limited to BaseX or
XQuery. Did you try rewrite your function calls to tail calls [1]?
Another alternative is to increase the stack size of Java (via the
-Xss flag).

Hope this helps,
Christian

[1] https://en.wikipedia.org/wiki/Tail_call