Hey Vivian, glad to hear you got it solved. And yes, I can only agree w/ your assessment of the problem :)
With the simple fix, you might want to watch for congestions there in case of heavy publishing & high load on the server, but hopefully it will not cause any immediate issues. Cheers, Jan > On 04 Nov 2015, at 14:35, Vivian Steller <vivian.stel...@lemonize.de> wrote: > > Hi Jan, > thanks for your hints. Meanwhile I was able to resolve the issue by > synchronizing repository access in > info.magnolia.module.advancedcache.NotifyFlushListeningPolicy_Patched.InitOrUpdateTimeStampOp#exec. > We simply use a Java synchronized statement/block. > > I think synchronization effectively resolves the issue. To me it makes sense: > we're publishing multiple workspaces quickly one after each other. > Publication happens to be asynchronous, hence for each workspace one > scheduler thread is launched in order to activate the content. At the end of > each publication, both on public and author instance the > NotifyFlushListeningPolicy_Patched.InitOrUpdateTimeStampOp#exec method is > invoked for each workspace, which happens in parallel since different threads > are sending (on author)/responding (on public) to the activation requests. > > Your solution, Jan, seems more accurate/safe solution since I'm only > synchronizing access between > NotifyFlushListeningPolicy_Patched.InitOrUpdateTimeStampOp#exec invocations > and not access to the repository node itself, but mine was more > straightforward to implement ;-) Plus I think access to that specific > repository property should be left the responsibility of the > NotifyFlushListeningPolicy anyway, right? > > I already filed a support request in JIRA for this and asked the support team > to move the issue to the appropriate JIRA project. I already added a patched > version of the NotifyFlushListeningPolicy class which I don’t want to post > here since its MNA licensed code. > > Thanks for your help! > > Cheers, > Vivian > > >> On 03.11.2015, at 13:23, Jan Haderka <jan.hade...@magnolia-cms.com >> <mailto:jan.hade...@magnolia-cms.com>> wrote: >> >>> >>> On 29 Oct 2015, at 18:11, Vivian Steller <vivian.stel...@lemonize.de >>> <mailto:vivian.stel...@lemonize.de>> wrote: >>> >>> Hi Richard, >>> thanks for your response. >>> >>> Unfortunately the suggested solution didn’t help. I did session.unwrap() in >>> the method invoking session.save(). But the error persists (see the altered >>> stack trace [1]). >>> >>> Just for the records: I’m saving multiple workspaces right one after the >>> other. I guess that each call to save *asynchronously* triggers the cache >>> flush and updating of the lastUpdateTimeStamp property (see the >>> info.magnolia.cms.util.DelayedExecutor$RunnableWrapper.run(DelayedExecutor.java:103) >>> frame in the stack trace, that it’s called asynchronously). >>> >>> Somehow access to that lastUpdateTimeStamp property should be synchronized >>> accross multiple threads invoking >>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy_Patched$InitOrUpdateTimeStampOp.exec. >>> Unfortunately I do not know how to implement this kind of synchronization? >>> Should simple thread sync using a monitor object help in this case? Do you >>> have any idea? >> >> across multiple threads? JCR Session is not thread safe and should not be >> accessed via multiple threads … ever. >> >> What seems to be (IMO) happening here is that instance of policy has session >> or node open while some other class elsewhere updates the node that has the >> “cache last update timestamp” … then when attempting to update the value >> that was modified already after retrieval of the node, failure below >> occurs.so, I don’t think the unwrap can/will help here. What you would need >> to do (if error happens in your code) is to call session.refresh() prior >> saving (or catch the failure, call the refresh and then save again) … try to >> call it w/ “true” to preserve the change, if that doesn’t work, >> refresh(false) should help, but you would need to set the timestamp property >> again. You might also want to submit official bug report for it ;) >> >> Cheers, >> Jan >> >>> >>> Thanks for any further assistance. >>> >>> Cheers, >>> Vivian >>> >>> >>> >>> [1] Full stack trace >>> >>> 2015-10-29 17:53:53,938 WARN org.apache.jackrabbit.core.ItemSaveOperation >>> : >>> /modules/advanced-cache/config/notifyFlushListeningPolicy/lastUpdateTimeStamp: >>> failed to restore transient state >>> 2015-10-29 17:53:53,942 ERROR >>> e.advancedcache.NotifyFlushListeningPolicy_Patched: Failed to store cache >>> last update timestamp. All entries will be flushed from cache on restart. >>> javax.jcr.InvalidItemStateException: property >>> /modules/advanced-cache/config/notifyFlushListeningPolicy/lastUpdateTimeStamp: >>> the property cannot be saved because it has been modified externally. >>> at >>> org.apache.jackrabbit.core.PropertyImpl.makePersistent(PropertyImpl.java:161) >>> at >>> org.apache.jackrabbit.core.ItemSaveOperation.persistTransientItems(ItemSaveOperation.java:849) >>> at >>> org.apache.jackrabbit.core.ItemSaveOperation.perform(ItemSaveOperation.java:243) >>> at >>> org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216) >>> at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91) >>> at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:329) >>> at >>> org.apache.jackrabbit.core.session.SessionSaveOperation.perform(SessionSaveOperation.java:65) >>> at >>> org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216) >>> at org.apache.jackrabbit.core.SessionImpl.perform(SessionImpl.java:361) >>> at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:812) >>> at >>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy_Patched$InitOrUpdateTimeStampOp.exec(NotifyFlushListeningPolicy_Patched.java:92) >>> at >>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy_Patched$InitOrUpdateTimeStampOp.exec(NotifyFlushListeningPolicy_Patched.java:56) >>> at info.magnolia.cms.security.JCRSessionOp.exec(JCRSessionOp.java:67) >>> at >>> info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:385) >>> at >>> info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:371) >>> at >>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy_Patched.updateLastUpdateTimestamp(NotifyFlushListeningPolicy_Patched.java:36) >>> at >>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy.preHandleEvents(NotifyFlushListeningPolicy.java:46) >>> at >>> info.magnolia.module.cache.AbstractListeningFlushPolicy$CacheCleaner.onEvent(AbstractListeningFlushPolicy.java:193) >>> at >>> info.magnolia.cms.util.ObservationUtil$ObservationBasedDelayedExecutor$1.run(ObservationUtil.java:253) >>> at >>> info.magnolia.cms.util.DelayedExecutor$RunnableWrapper.run(DelayedExecutor.java:103) >>> at EDU.oswego.cs.dl.util.concurrent.ClockDaemon$RunLoop.run(Unknown >>> Source) >>> at java.lang.Thread.run(Thread.java:745) >>> >>> >>>> On 29.10.2015, at 16:02, Unger, Richard <richard.un...@lfrz.at >>>> <mailto:richard.un...@lfrz.at>> wrote: >>>> >>>> Hi Vivian, >>>> >>>> Whenever the "MgnlPropertySettingContentDecorator" stuff gives me trouble, >>>> I unwrap the Nodes/Sessions all the way before using them. Is this what is >>>> causing the trouble in your case, or is it another interaction? >>>> >>>> Regards from Vienna, >>>> >>>> Richard >>>> >>>> >>>> >>>>> -----Ursprüngliche Nachricht----- >>>>> Von: user-list-ow...@magnolia-cms.com >>>>> <mailto:user-list-ow...@magnolia-cms.com> >>>>> [mailto:user-list-owner@magnolia- cms.com <http://cms.com/>] Im Auftrag >>>>> von Vivian >>>>> Steller >>>>> Gesendet: Donnerstag, 29. Oktober 2015 14:48 >>>>> An: user-list@magnolia-cms.com <mailto:user-list@magnolia-cms.com> >>>>> Betreff: [magnolia-user] javax.jcr.InvalidItemStateException: property >>>>> /modules/advanced- >>>>> cache/config/notifyFlushListeningPolicy/lastUpdateTimeStamp >>>>> >>>>> Hi Folks, >>>>> technical question: can anyone suggest on how to avoid / recover from >>>>> InvalidItemStateExceptions? >>>>> >>>>> Here’s the use case/problem: >>>>> * we’re using advanced cache / notifyFlushListeningPolicy >>>>> * we’re bulk creating tons of nodes in various workspaces using a bulk >>>>> action; the action is performed in system context >>>>> * nodes are created just fine, this is all right, however… >>>>> * PROBLEM: updating the lastUpdateTimeStamp property fails with the >>>>> exception below [1]… >>>>> * interesting: the exception does not appear if I perform the >>>>> operation for the first time after starting Magnolia.. it seems that >>>>> somehow the state is not written back correctly in the >>>>> NotifyFlushListeningPolicy? >>>>> >>>>> Here some concrete questions? >>>>> * did anyone experience the same issues with the >>>>> NotifyFlushListeningPolicy? >>>>> * since we know we’re doing lots of stuff in the workspaces: is there >>>>> a way to temporarily turn off updating this property and just writing it >>>>> once? >>>>> * is there a way to recover from an InvalidItemState in some way? >>>>> * any other idea to avoid this exception? >>>>> >>>>> Thanks in advance, >>>>> cheers, >>>>> Vivian >>>>> >>>>> >>>>> [1] Full Exception Stack trace: >>>>> 2015-10-29 14:29:15,933 WARN >>>>> org.apache.jackrabbit.core.ItemSaveOperation : /modules/advanced- >>>>> cache/config/notifyFlushListeningPolicy/lastUpdateTimeStamp: failed to >>>>> restore transient state >>>>> 2015-10-29 14:29:15,934 ERROR >>>>> ia.jcr.wrapper.MgnlPropertySettingContentDecorator: Failed to update >>>>> LUD for session: session-admin-318::config >>>>> javax.jcr.InvalidItemStateException: property /modules/advanced- >>>>> cache/config/notifyFlushListeningPolicy/lastUpdateTimeStamp: the >>>>> property cannot be saved because it has been modified externally. >>>>> at >>>>> org.apache.jackrabbit.core.PropertyImpl.makePersistent(PropertyImpl.java: >>>>> 161) >>>>> at >>>>> org.apache.jackrabbit.core.ItemSaveOperation.persistTransientItems(Ite >>>>> mS >>>>> aveOperation.java:849) >>>>> at >>>>> org.apache.jackrabbit.core.ItemSaveOperation.perform(ItemSaveOperation >>>>> .java:243) >>>>> at >>>>> org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java: >>>>> 216) >>>>> at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91) >>>>> at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:329) >>>>> at >>>>> org.apache.jackrabbit.core.session.SessionSaveOperation.perform(Sessio >>>>> nS >>>>> aveOperation.java:65) >>>>> at >>>>> org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java: >>>>> 216) >>>>> at >>>>> org.apache.jackrabbit.core.SessionImpl.perform(SessionImpl.java:361) >>>>> at >>>>> org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:812) >>>>> at >>>>> info.magnolia.jcr.wrapper.DelegateSessionWrapper.save(DelegateSessionW >>>>> rapper.java:297) >>>>> at >>>>> info.magnolia.jcr.wrapper.DelegateSessionWrapper.save(DelegateSessionW >>>>> rapper.java:297) >>>>> at >>>>> info.magnolia.jcr.wrapper.DelegateSessionWrapper.save(DelegateSessionW >>>>> rapper.java:297) >>>>> at >>>>> info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator$MgnlProp >>>>> ertySettingSessionWrapper.save(MgnlPropertySettingContentDecorator.jav >>>>> a:492) >>>>> at >>>>> info.magnolia.jcr.wrapper.DelegateSessionWrapper.save(DelegateSessionW >>>>> rapper.java:297) >>>>> at >>>>> info.magnolia.audit.MgnlAuditLoggingContentDecoratorSessionWrapper.sav >>>>> e(MgnlAuditLoggingContentDecoratorSessionWrapper.java:82) >>>>> at >>>>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy$InitOrUp >>>>> da >>>>> teTimeStampOp.exec(NotifyFlushListeningPolicy.java:127) >>>>> at >>>>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy$InitOrUp >>>>> da >>>>> teTimeStampOp.exec(NotifyFlushListeningPolicy.java:98) >>>>> at >>>>> info.magnolia.cms.security.JCRSessionOp.exec(JCRSessionOp.java:67) >>>>> at >>>>> info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:3 >>>>> 85) >>>>> at >>>>> info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:3 >>>>> 71) >>>>> at >>>>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy.updateLa >>>>> st >>>>> UpdateTimestamp(NotifyFlushListeningPolicy.java:61) >>>>> at >>>>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy.preHandl >>>>> eE >>>>> vents(NotifyFlushListeningPolicy.java:46) >>>>> at >>>>> info.magnolia.module.cache.AbstractListeningFlushPolicy$CacheCleaner.o >>>>> nE >>>>> vent(AbstractListeningFlushPolicy.java:193) >>>>> at >>>>> info.magnolia.cms.util.ObservationUtil$ObservationBasedDelayedExecutor >>>>> $ >>>>> 1.run(ObservationUtil.java:253) >>>>> at >>>>> info.magnolia.cms.util.DelayedExecutor$RunnableWrapper.run(DelayedExec >>>>> utor.java:103) >>>>> at >>>>> EDU.oswego.cs.dl.util.concurrent.ClockDaemon$RunLoop.run(Unknown >>>>> Source) >>>>> at java.lang.Thread.run(Thread.java:745) >>>>> 2015-10-29 14:29:15,935 ERROR >>>>> ia.module.advancedcache.NotifyFlushListeningPolicy: Failed to store >>>>> cache last update timestamp. All entries will be flushed from cache on >>>>> restart. >>>>> javax.jcr.InvalidItemStateException: property /modules/advanced- >>>>> cache/config/notifyFlushListeningPolicy/lastUpdateTimeStamp: the >>>>> property cannot be saved because it has been modified externally. >>>>> at >>>>> org.apache.jackrabbit.core.PropertyImpl.makePersistent(PropertyImpl.java: >>>>> 161) >>>>> at >>>>> org.apache.jackrabbit.core.ItemSaveOperation.persistTransientItems(Ite >>>>> mS >>>>> aveOperation.java:849) >>>>> at >>>>> org.apache.jackrabbit.core.ItemSaveOperation.perform(ItemSaveOperation >>>>> .java:243) >>>>> at >>>>> org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java: >>>>> 216) >>>>> at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91) >>>>> at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:329) >>>>> at >>>>> org.apache.jackrabbit.core.session.SessionSaveOperation.perform(Sessio >>>>> nS >>>>> aveOperation.java:65) >>>>> at >>>>> org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java: >>>>> 216) >>>>> at >>>>> org.apache.jackrabbit.core.SessionImpl.perform(SessionImpl.java:361) >>>>> at >>>>> org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:812) >>>>> at >>>>> info.magnolia.jcr.wrapper.DelegateSessionWrapper.save(DelegateSessionW >>>>> rapper.java:297) >>>>> at >>>>> info.magnolia.jcr.wrapper.DelegateSessionWrapper.save(DelegateSessionW >>>>> rapper.java:297) >>>>> at >>>>> info.magnolia.jcr.wrapper.DelegateSessionWrapper.save(DelegateSessionW >>>>> rapper.java:297) >>>>> at >>>>> info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator$MgnlProp >>>>> ertySettingSessionWrapper.save(MgnlPropertySettingContentDecorator.jav >>>>> a:492) >>>>> at >>>>> info.magnolia.jcr.wrapper.DelegateSessionWrapper.save(DelegateSessionW >>>>> rapper.java:297) >>>>> at >>>>> info.magnolia.audit.MgnlAuditLoggingContentDecoratorSessionWrapper.sav >>>>> e(MgnlAuditLoggingContentDecoratorSessionWrapper.java:82) >>>>> at >>>>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy$InitOrUp >>>>> da >>>>> teTimeStampOp.exec(NotifyFlushListeningPolicy.java:127) >>>>> at >>>>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy$InitOrUp >>>>> da >>>>> teTimeStampOp.exec(NotifyFlushListeningPolicy.java:98) >>>>> at >>>>> info.magnolia.cms.security.JCRSessionOp.exec(JCRSessionOp.java:67) >>>>> at >>>>> info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:3 >>>>> 85) >>>>> at >>>>> info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:3 >>>>> 71) >>>>> at >>>>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy.updateLa >>>>> st >>>>> UpdateTimestamp(NotifyFlushListeningPolicy.java:61) >>>>> at >>>>> info.magnolia.module.advancedcache.NotifyFlushListeningPolicy.preHandl >>>>> eE >>>>> vents(NotifyFlushListeningPolicy.java:46) >>>>> at >>>>> info.magnolia.module.cache.AbstractListeningFlushPolicy$CacheCleaner.o >>>>> nE >>>>> vent(AbstractListeningFlushPolicy.java:193) >>>>> at >>>>> info.magnolia.cms.util.ObservationUtil$ObservationBasedDelayedExecutor >>>>> $ >>>>> 1.run(ObservationUtil.java:253) >>>>> at >>>>> info.magnolia.cms.util.DelayedExecutor$RunnableWrapper.run(DelayedExec >>>>> utor.java:103) >>>>> at >>>>> EDU.oswego.cs.dl.util.concurrent.ClockDaemon$RunLoop.run(Unknown >>>>> Source) >>>>> at java.lang.Thread.run(Thread.java:745) >>>>> >>>>> ---------------------------------------------------------------- >>>>> For list details, see http://www.magnolia-cms.com/community/mailing- >>>>> <http://www.magnolia-cms.com/community/mailing-> >>>>> lists.html >>>>> Alternatively, use our forums: http://forum.magnolia-cms.com/ >>>>> <http://forum.magnolia-cms.com/> To >>>>> unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com >>>>> <mailto:user-list-unsubscr...@magnolia-cms.com>> >>>>> ---------------------------------------------------------------- >>>> >>>> >>>> >>>> ---------------------------------------------------------------- >>>> For list details, see >>>> http://www.magnolia-cms.com/community/mailing-lists.html >>>> <http://www.magnolia-cms.com/community/mailing-lists.html> >>>> Alternatively, use our forums: http://forum.magnolia-cms.com/ >>>> <http://forum.magnolia-cms.com/> >>>> To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com >>>> <mailto:user-list-unsubscr...@magnolia-cms.com>> >>>> ---------------------------------------------------------------- >>>> >>> >>> >>> >>> ---------------------------------------------------------------- >>> For list details, see >>> http://www.magnolia-cms.com/community/mailing-lists.html >>> <http://www.magnolia-cms.com/community/mailing-lists.html> >>> Alternatively, use our forums: http://forum.magnolia-cms.com/ >>> <http://forum.magnolia-cms.com/> >>> To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com >>> <mailto:user-list-unsubscr...@magnolia-cms.com>> >>> ---------------------------------------------------------------- > > > > ---------------------------------------------------------------- > For list details, see http://www.magnolia-cms.com/community/mailing-lists.html > Alternatively, use our forums: http://forum.magnolia-cms.com/ > To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com> > ----------------------------------------------------------------
signature.asc
Description: Message signed with OpenPGP using GPGMail