Hi James,
I’m sorry, there is general solution for that on database level; if a disk is full, basically anything can be happen.
However, as you are using RESTXQ, you could check memory via XQuery:
declare namespace file = 'java:java.io.File'; let $free := file:getFreeSpace(file:new('/')) return if($free < 100000000) then error((), "Less than 100 MB left on disk") else ( (: continue :) )
This way, you can also decide what is going to happen if the disk runs out of space (raise an error? send an e-mail? etc.). By the way, raising an error will probably be the most elegant solution, as you can catch the error via %rest:error and do some more things [1].
Hope this helps, Christian
[1] http://docs.basex.org/wiki/RESTXQ#Error_Handling
On Fri, Apr 1, 2016 at 4:48 PM, James Ball basex-talk@jamesball.co.uk wrote:
Hello,
I’m having some problems with BaseX in situations where there it runs out of disk space.
I’m delivering XML files to BaseX 8.4 using RestXQ.
A request is made and the XML is added to a database depending on some criteria. I receive many hundreds of thousands of requests and everything works well unless I run out of disk space.
What I would expect to happen is that BaseX would try to add the document, find it couldn’t due to the disk being full and return a server error (e.g. 500) and the transaction would be aborted leaving the database as it was before the request. Any further requests would all get errors returned.
What I’m seeing is that when a request is made that causes the disk to become full BaseX gets part way through adding the document, fails and returns an error but also leaves the database corrupted. Usually the server has to be restarted and then any database that has been affected has to be deleted - it’s rare to be able to save anything from it.
The errors vary but it is usually a NullPointer exception and then java.nio.channels.OverlappingFileLockException. for further requests.
I’ve tried turning off logging and setting parallel to 1 to see if that made any difference but it doesn’t.
Is what I’m seeing unique to my setup or do others see this?
Is there anything I can do to make BaseX just stop accepting requests when disk space runs out to protect my databases?
Many thanks, James