[
https://issues.apache.org/jira/browse/SLING-3734?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14052203#comment-14052203
]
Bertrand Delacretaz edited comment on SLING-3734 at 7/4/14 7:00 AM:
--------------------------------------------------------------------
There was indeed something about < 1000 in
AbstractCreateOperation.ensureUniquePath, which is meant to break ties in case
the default and/or configured NodeNameGenerator generate a path that's not
unique.
I have replaced the incremental suffix with a random integer in
http://svn.apache.org/r1607787 which should fix the issue. To test it I
replaced this line
{code}
generatedName = defaultNodeNameGenerator.getNodeName(request, basePath,
requirePrefix, defaultNodeNameGenerator);
{code}
with {{generated_name = "CONSTANT"}} to trigger the call to ensureUniquePath,
and without node additions would fail after node 999 as you saw.
ensureUniquePath still makes up to 1000 tries but now with random integers, so
collisions are much less likely. If that's not sufficient we might also improve
the default NodeNameGenerator which uses System.currentTimeMillis() which might
not change as often as one thinks, especially under Windows.
Please cross-check with the current snapshot of bundles/servlets/post, you
shouldn't need to replace anything else.
was (Author: bdelacretaz):
There was indeed something about < 1000 in
AbstractCreateOperation.ensureUniquePath, which is meant to break ties in case
the default and/or configured NodeNameGenerator generate a path that's not
unique.
I have replaced the incremental suffix with a random integer in
http://svn.apache.org/r1607787 which should fix the issue. To test it I
replaced this line
{code}
generatedName = defaultNodeNameGenerator.getNodeName(request, basePath,
requirePrefix, defaultNodeNameGenerator);
{code}
with {{generated_name = "CONSTANT"}} to trigger the call to ensureUniquePath,
and without node additions would fail after node 999 as you saw.
Please cross-check with the current snapshot of bundles/servlets/post, you
shouldn't need to replace anything else.
> 'org.apache.sling.api.SlingException: Failed to generate name' when posting
> under load
> --------------------------------------------------------------------------------------
>
> Key: SLING-3734
> URL: https://issues.apache.org/jira/browse/SLING-3734
> Project: Sling
> Issue Type: Bug
> Components: Servlets
> Affects Versions: Servlets Post 2.3.4, Launchpad Builder 7
> Reporter: David Bosschaert
> Attachments: jmeter-config.jmx
>
>
> I was doing some load testing on the current Sling (trunk) launchpad which I
> started as follows:
> java -jar org.apache.sling.launchpad-7-SNAPSHOT-standalone.jar
> I used a multitreaded client (JMeter, 4 threads) to send a whole bunch of
> post requests to http://machine:8080/content/mynoderoot/ to get the node name
> auto-generated.
> However, on about 25% of the requests I'm getting a 500 response with the
> following exception message: org.apache.sling.api.SlingException: Failed to
> generate name. The full stack trace is below.
> {code}org.apache.sling.api.SlingException: Failed to generate name
> org.apache.sling.servlets.post.impl.operations.ModifyOperation.getItemPath(ModifyOperation.java:175)
> org.apache.sling.servlets.post.AbstractPostOperation.run(AbstractPostOperation.java:77)
> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:199)
> org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:148)
> org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:344)
> org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:375)
> org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:511)
> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:289)
> org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
> org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:64)
> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
> org.apache.sling.engine.impl.SlingRequestProcessorImpl.doProcessRequest(SlingRequestProcessorImpl.java:153)
> org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:206)
> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
> org.apache.sling.engine.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:75)
> org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
> org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:654)
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:445)
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
> org.eclipse.jetty.server.Server.handle(Server.java:369)
> org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486)
> org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:944)
> org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1005)
> org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
> java.lang.Thread.run(Thread.java:744)
> Caused by: javax.jcr.RepositoryException: Collision in generated node names
> for path=/content/mynoderoot/some_title
> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.ensureUniquePath(AbstractCreateOperation.java:690)
> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.generateName(AbstractCreateOperation.java:664)
> org.apache.sling.servlets.post.impl.operations.ModifyOperation.getItemPath(ModifyOperation.java:173)
> ... 49 common frames omitted{code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)