Skip to main content
rohitm58172886
Level 2
Jul 4, 2019 10:23 AM UTC
Solved

AEM slow down when copy node

Hi,

     Programatically,I am copy some nodes(source node) and paste it on under parent node(destination node).When this process executing AEM consume more cpu usage its nearly goes 90% so AEM Slow down.

Code

          import javax.jcr.Session;

          import javax.jcr.Workspace;

          import org.apache.sling.jcr.api.SlingRepository;

          .

          /**************Some Code**************/

               Session session = repository.loginAdministrative(null);

               Workspace ws = session.getWorkspace();

               ws.copy(sourceNodepath, ParentNodepath);

          /***********Some Code****************/

Thanx

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Adobe Employee
Jul 9, 2019 3:09 PM UTC

It's hard to guess ...

Anyway, you upload ZIP files (which are extracted and the content is indexed then by the repository), plus the asset update workflow is running. That can take a while and consume quite some CPU, but should be async. The whole process of copying the assets itself should not take long.

Jörg

12 replies

Adobe Employee
Jul 4, 2019 12:11 PM UTC

Move/copy can be an expensive operation.  You should take threaddumps [1] to see what's taking so long and perhaps enable debug logging for query [2] to see if anything can be done.

[1] Take thread dumps from a JVM

[2] Oak Queries and Indexing

Translate
arunpatidar
Community Advisor
Community Advisor
Jul 4, 2019 12:50 PM UTC

you can try different approach:

adminSession = repository.loginService("readService", null);

Node node = adminSession.getNode("/apps/nodePath/textfield");

Node parentNode =  adminSession.getNode("/apps/parentNodePath");

JcrUtil.copy(node, parentNode, null);

adminSession.save();

aem63app-repo/CopyNodeServlet.java at master · arunpatidar02/aem63app-repo · GitHub

Translate
Arun Patidar
Akash_Kapoor
Adobe Employee
Adobe Employee
Jul 4, 2019 8:45 PM UTC

Hi Rohit,

If it is really slow for some basic operations then feel free to raise a support ticket here: https://daycare.day.com/home/createaticket.html

with clear detailed use case to replicate the slowness and thread dumps if specific to your environment.

Translate
joerghoh
Adobe Employee
Adobe Employee
Jul 5, 2019 5:00 PM UTC

How many nodes do you want to copy? What are the paths?

Jörg

Translate
rohitm58172886
Level 2
Jul 8, 2019 6:51 AM UTC

url asking me username and password.which username and password should i entre?

Translate
rohitm58172886
Level 2
Jul 8, 2019 6:53 AM UTC

Jcr.Utila.copy doing recursively so its try to copy [jcr:uuid] and because of same uuid aem throws below exception

OakConstraint0030: Uniqueness constraint violated property [jcr:uuid] having value

Translate
rohitm58172886
Level 2
Jul 8, 2019 7:01 AM UTC

i am copy six nodes [dam:asset] type

Translate
joerghoh
Adobe Employee
Adobe Employee
Jul 8, 2019 9:31 AM UTC

ok, it seems that you are facing a number of issues....

of course duplicate UUIDs are not allowed; please try a different copy routine which does not copy all properties (as done by the workspace methods), but only the non-protected ones. For example the JcrUtils provided by AEM [1].

Regarding the performance: Depending on the size of the assets and some other (more infrastructure constraints) this copy action can move gigabytes... Can you tell us a bit about your setup and the size of the assets you want to copy?

[1] JcrUtil ("The Adobe AEM Quickstart and Web Application.")

Translate
rohitm58172886
Level 2
Jul 8, 2019 10:06 AM UTC

     Above files i copied using workspace.copy() method

Translate
joerghoh
Adobe Employee
Adobe Employee
Jul 8, 2019 8:38 PM UTC

ok, the size of the assets is not a problem.

Next thing: What do you mean by "is getting slow"? For how long is your AEM slow? Seconds, minutes or hours? Does it require a restart to recover?

Note: When new assets show up in the repository (and copying is a reason for it), the asset update workflow is starting which can be quite resourcen intensive, but which should only take seconds for the assets of the size you posted.

Jörg

Translate