Concurrency problems with REST API
Saturday, 31 March 2012 · 2 messages · last reply 1 Apr 2012
TH
Tobias Hofer31 Mar 2012 01:25 #
Hi,
I'm using the REST API of BaseX 7.2 and run into concurrency problems. If I add new documents in parallel then the server will stop working after adding a few documents.
My command template looks like:
<?xml version="1.0" encoding="UTF-8"?>
<command xmlns="http://basex.org/rest"><text><![CDATA[
ADD TO $KEY$
<node id="$KEY$" />
]]></text></command>I call the REST API using curl:
for ((i=0; i<10; i++)); do
(cp tx-template tx$i; replace '$KEY$' $i -- tx$i;
curl -i -X POST -H "Content-Type: application/xml" -T tx$i "admin:admin@localhost:8984/rest/QDEV") & done
After four or less insert the following error occurs:
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Content-Length: 2247
Server: Jetty(6.1.26)
java.lang.NullPointerExceptionjava.lang.NullPointerExceptionjava.lang.NullPointerExceptionorg.xml.sax.SAXParseException: cvc-type.3.1.2: Element 'command' is a simple type, so it must have no element information item [children].org.xml.sax.SAXParseException: cvc-type.3.1.2: Element 'command' is a simple type, so it must have no element information item [children].Improper use? Potential bug? Your feedback is welcome: Contact: basex-talk at mailman.uni-konstanz.de
Version: BaseX 7.2
Java: Sun Microsystems Inc., 1.6.0_26
OS: Linux, amd64
Stack Trace:
java.lang.NullPointerException
org.basex.core.cmd.Add.run(Add.java:92)
org.basex.core.Command.run(Command.java:345)
org.basex.core.Command.exec(Command.java:324)
org.basex.core.Command.execute(Command.java:76)
org.basex.server.LocalSession.execute(LocalSession.java:134) org.basex.server.LocalSession.execute(LocalSession.java:126) org.basex.server.Session.execute(Session.java:51)
org.basex.http.rest.RESTCommand.run(RESTCommand.java:40)
org.basex.http.rest.RESTPost.run(RESTPost.java:129)
org.basex.http.rest.RESTServlet.run(RESTServlet.java:14)
org.basex.http.BaseXServlet.service(BaseXServlet.java:38)
javax.servlet.http.HttpServlet.service(HttpServlet.java:820) org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401) org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) org.mortbay.jetty.handler.HandlerList.handle(HandlerList.java:49) org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) org.mortbay.jetty.Server.handle(Server.java:326)
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945) org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756) org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
Now, the server cannot be accessed any more. Any further call will return "Database 'MYDB' is currently opened by another client. A restart helps.
The error does not happen if the commands are executed in sequence.
Please help.
Regards,
Tobias Hofer
CG
Christian Grün1 Apr 2012 19:13 #
Dear Tobias,
thanks for your report and all the helpful details. My assumption is that the concurrency problem you came across may be related to an existing GitHub issue, which is why I've just added your info to this entry:
https://github.com/BaseXdb/basex/issues/458
Expect this bug to be fixed soon,
Christian
Quoted text · Tobias Hofer · 76 lines
On Sat, Mar 31, 2012 at 1:25 AM, Tobias Hofer <tobias.hofer at basis06.ch> wrote: > Hi, > > I'm using the REST API of BaseX 7.2 and run into concurrency problems. > If I add new documents in parallel then the server will stop working > after adding a few documents. > > > My command template looks like: > <?xml version="1.0" encoding="UTF-8"?> > <command xmlns="http://basex.org/rest"><text><![CDATA[ > ADD TO $KEY$ > <node id="$KEY$" /> > ]]></text></command> > > > I call the REST API using curl: > for ((i=0; i<10; i++)); do > (cp tx-template tx$i; replace '$KEY$' $i -- tx$i; > curl -i -X POST -H "Content-Type: application/xml" -T tx$i > "admin:admin@localhost:8984/rest/QDEV") & done > > > After four or less insert the following error occurs: > HTTP/1.1 400 Bad Request > Content-Type: text/plain; charset=utf-8 > Content-Length: 2247 > Server: Jetty(6.1.26) > > java.lang.NullPointerExceptionjava.lang.NullPointerExceptionjava.lang.NullPointerExceptionorg.xml.sax.SAXParseException: cvc-type.3.1.2: Element 'command' is a simple type, so it must have no element information item [children].org.xml.sax.SAXParseException: cvc-type.3.1.2: Element 'command' is a simple type, so it must have no element information item [children].Improper use? Potential bug? Your feedback is welcome: > Contact: basex-talk at mailman.uni-konstanz.de > Version: BaseX 7.2 > Java: Sun Microsystems Inc., 1.6.0_26 > OS: Linux, amd64 > Stack Trace: > java.lang.NullPointerException > org.basex.core.cmd.Add.run(Add.java:92) > org.basex.core.Command.run(Command.java:345) > org.basex.core.Command.exec(Command.java:324) > org.basex.core.Command.execute(Command.java:76) > org.basex.server.LocalSession.execute(LocalSession.java:134) > org.basex.server.LocalSession.execute(LocalSession.java:126) > org.basex.server.Session.execute(Session.java:51) > org.basex.http.rest.RESTCommand.run(RESTCommand.java:40) > org.basex.http.rest.RESTPost.run(RESTPost.java:129) > org.basex.http.rest.RESTServlet.run(RESTServlet.java:14) > org.basex.http.BaseXServlet.service(BaseXServlet.java:38) > javax.servlet.http.HttpServlet.service(HttpServlet.java:820) > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401) > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) > org.mortbay.jetty.handler.HandlerList.handle(HandlerList.java:49) > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) > org.mortbay.jetty.Server.handle(Server.java:326) > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) > org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945) > org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756) > org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) > > > Now, the server cannot be accessed any more. Any further call will return > "Database 'MYDB' is currently opened by another client. A restart helps. > > The error does not happen if the commands are executed in sequence. > > Please help. > > Regards, > Tobias Hofer > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Written for BaseX 7.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery