You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by lancedolan <la...@gmail.com> on 2017/02/02 02:08:48 UTC

Components each process twice

Through my years in Adobe CQ and AEM, I've noticed that LOG files from
components that I write always render twice per page request. Today I was
debugging my code in Sling 8 and noticed that My debugger was kicked open
twice each time I requested a page instead of once.

What's the deal with this? It seems really common, you guys must all be
familiar with it also?

It's dangerous because all components logic must be idempotent (imagine
posting duplicate records to a database). And then obviously, it's bad for
performance to do things twice unnecessarily.  

I've seen this so often on so many projects that I'm not really tempted to
offer any steps to reproduce, you guys must be seeing this also right?

NOTE: The component is NOT included on the page more than once. This
behavior will occur when a component is included only once. 



--
View this message in context: http://apache-sling.73963.n3.nabble.com/Components-each-process-twice-tp4070042.html
Sent from the Sling - Users mailing list archive at Nabble.com.

Re: Components each process twice

Posted by naveenChoudhary <nv...@gmail.com>.
Hi,
Can you please elaborate how you have resolved the problem as we are also
facing the same.
AEM 6.1 sightly.

Thanks
Naveen



--
View this message in context: http://apache-sling.73963.n3.nabble.com/Components-each-process-twice-tp4070042p4070836.html
Sent from the Sling - Users mailing list archive at Nabble.com.

Re: Components each process twice

Posted by Evgeniy Fitsner <dr...@drfits.com>.
Can you please provide a small code example for this?

We've faced with similar behavior in our project (AEM 6.1, Sightly) but 
it was according to "architecture" (components was rendered twice per 
request) therefore I had to change it to single include.


On 02/02/2017 05:08 AM, lancedolan wrote:
> Through my years in Adobe CQ and AEM, I've noticed that LOG files from
> components that I write always render twice per page request. Today I was
> debugging my code in Sling 8 and noticed that My debugger was kicked open
> twice each time I requested a page instead of once.
>
> What's the deal with this? It seems really common, you guys must all be
> familiar with it also?
>
> It's dangerous because all components logic must be idempotent (imagine
> posting duplicate records to a database). And then obviously, it's bad for
> performance to do things twice unnecessarily.
>
> I've seen this so often on so many projects that I'm not really tempted to
> offer any steps to reproduce, you guys must be seeing this also right?
>
> NOTE: The component is NOT included on the page more than once. This
> behavior will occur when a component is included only once.
>
>
>
> --
> View this message in context: http://apache-sling.73963.n3.nabble.com/Components-each-process-twice-tp4070042.html
> Sent from the Sling - Users mailing list archive at Nabble.com.

-- 
With best regards
Evgeniy Fitsner

E-mail: drfits@drfits.com
Skype: drfits
Phone: +375 29 5386858


Re: Components each process twice

Posted by Santiago Garcia Pimentel <sa...@netcentric.biz>.
Hi again,

Made a quick test on an AEM instance.

I did get the duplicated sling model processed, but only in author mode when using touchUI in editor window. in every other case it is only one. Also they seemed to be two different requests, so each model is still processed once per request. AEM seems to trigger a second request at some point.

So this doesn't look like a problem with sling and more with the touch ui editor from AEM.

Greetings.

Santiago García Pimentel| Sr Software Engineer
Netcentric Ibérica SLU
M: +34687915463
santiago.pimentel@netcentric.biz <ma...@netcentric.biz> | www.netcentric.biz <http://www.netcentric.biz/>
> On Mar 2, 2017, at 11:32 AM, naveenChoudhary <nv...@gmail.com> wrote:
> 
> Thanks for the reply but in my case there is no error , both the times it is
> working properly without any issue. 
> 
> So now for you is it making only one call ?
> 
> In my case the problem is page is getting heavy and it is impacting
> performance very badly .
> 
> So I looking for the solution to avoid more than one call even if there is
> any failure how can we control the behaviour of sightly is there any way or
> the class I can refer to ? 
> 
> Or is the default behaviour does anyone created a daycare for it ?
> 
> Any help will be appreciated ? 
> 
> Thanks
> Naveen
> 
> 
> 
> --
> View this message in context: http://apache-sling.73963.n3.nabble.com/Components-each-process-twice-tp4070042p4070865.html
> Sent from the Sling - Users mailing list archive at Nabble.com.


Re: Components each process twice

Posted by naveenChoudhary <nv...@gmail.com>.
Thanks for the reply but in my case there is no error , both the times it is
working properly without any issue. 

So now for you is it making only one call ?

In my case the problem is page is getting heavy and it is impacting
performance very badly .

So I looking for the solution to avoid more than one call even if there is
any failure how can we control the behaviour of sightly is there any way or
the class I can refer to ? 

Or is the default behaviour does anyone created a daycare for it ?

Any help will be appreciated ? 

Thanks
Naveen



--
View this message in context: http://apache-sling.73963.n3.nabble.com/Components-each-process-twice-tp4070042p4070865.html
Sent from the Sling - Users mailing list archive at Nabble.com.

Re: Components each process twice

Posted by Santiago Garcia Pimentel <sa...@netcentric.biz>.
Hello,

I have seen this issue a couple of times. In every case it has been because sightly would initialize the same class twice, first using the adaptTo  and then the java Pojo provider. This was caused in every case by an error in the Post Construct method of the Sling Model class, which meant the adaptTo would return null and sightly would just keep trying different use providers.

Is this your scenario maybe?

Greetings.

Santiago García Pimentel| Sr Software Engineer
Netcentric Ibérica SLU
M: +34687915463
santiago.pimentel@netcentric.biz <ma...@netcentric.biz> | www.netcentric.biz <http://www.netcentric.biz/>
> On Feb 2, 2017, at 3:08 AM, lancedolan <la...@gmail.com> wrote:
> 
> Through my years in Adobe CQ and AEM, I've noticed that LOG files from
> components that I write always render twice per page request. Today I was
> debugging my code in Sling 8 and noticed that My debugger was kicked open
> twice each time I requested a page instead of once.
> 
> What's the deal with this? It seems really common, you guys must all be
> familiar with it also?
> 
> It's dangerous because all components logic must be idempotent (imagine
> posting duplicate records to a database). And then obviously, it's bad for
> performance to do things twice unnecessarily.  
> 
> I've seen this so often on so many projects that I'm not really tempted to
> offer any steps to reproduce, you guys must be seeing this also right?
> 
> NOTE: The component is NOT included on the page more than once. This
> behavior will occur when a component is included only once. 
> 
> 
> 
> --
> View this message in context: http://apache-sling.73963.n3.nabble.com/Components-each-process-twice-tp4070042.html
> Sent from the Sling - Users mailing list archive at Nabble.com.


Re: Components each process twice

Posted by lancedolan <la...@gmail.com>.
This response is good enough for me. The fact that the community hasn't
largely said "yea we see it all the time and it's normal" tells me I'm
probably causing this myself somewhere, and I'll have to look into it. I
just didn't want to lose a day figuring out the root cause if this was known
normal sling behaviour, or that sometime it just needs to render a component
twice to for its own reasons.

Curious that I've observed this on other projects from other devs - we must
be falling for the same pitfall.



--
View this message in context: http://apache-sling.73963.n3.nabble.com/Components-each-process-twice-tp4070042p4070081.html
Sent from the Sling - Users mailing list archive at Nabble.com.

Re: Components each process twice

Posted by Carsten Ziegeler <cz...@apache.org>.
No, I've never seen this before, except when the component was really
called twice per request. Your mail is really very general and makes us
guess what you're talking about. Are these OSGi components, rendering
components, a script? Please be more specific.

Thanks
Carsten

Lancedolan wrote
> Through my years in Adobe CQ and AEM, I've noticed that LOG files from
> components that I write always render twice per page request. Today I was
> debugging my code in Sling 8 and noticed that My debugger was kicked open
> twice each time I requested a page instead of once.
> 
> What's the deal with this? It seems really common, you guys must all be
> familiar with it also?
> 
> It's dangerous because all components logic must be idempotent (imagine
> posting duplicate records to a database). And then obviously, it's bad for
> performance to do things twice unnecessarily.  
> 
> I've seen this so often on so many projects that I'm not really tempted to
> offer any steps to reproduce, you guys must be seeing this also right?
> 
> NOTE: The component is NOT included on the page more than once. This
> behavior will occur when a component is included only once. 
> 
> 
> 
> --
> View this message in context: http://apache-sling.73963.n3.nabble.com/Components-each-process-twice-tp4070042.html
> Sent from the Sling - Users mailing list archive at Nabble.com.
> 


 

-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org