[MGNLCT-138] Exception when initializing content-type Created: 19/Mar/20  Updated: 24/Mar/20  Resolved: 23/Mar/20

Status: Closed
Project: Content Types
Component/s: None
Affects Version/s: 1.1
Fix Version/s: 1.1.1

Type: Bug Priority: Neutral
Reporter: Dai Ha Assignee: Dai Ha
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
caused by MAGNOLIA-7704 Asynchronous context implementation Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Sprint: 6.2 Ramp-up 20
Story Points: 2

 Description   

Add content-type with autocreate=true, it failed to initialize with below exception:

2020-03-19 17:17:39,859 ERROR agnolia.types.datasource.jcr.JackrabbitInitializer: Failed to initialize content type [ct-countries].
java.lang.IllegalStateException: not initialized
	at org.apache.jackrabbit.core.security.DefaultAccessManager.checkInitialized(DefaultAccessManager.java:457) ~[jackrabbit-core-2.20.0.jar:2.20.0]
	at org.apache.jackrabbit.core.security.DefaultAccessManager.checkRepositoryPermission(DefaultAccessManager.java:201) ~[jackrabbit-core-2.20.0.jar:2.20.0]
	at org.apache.jackrabbit.core.session.SessionContext$PermissionAwareNamespaceRegistry.registerNamespace(SessionContext.java:374) ~[jackrabbit-core-2.20.0.jar:2.20.0]
	at info.magnolia.types.datasource.jcr.JackrabbitInitializer.registerNamespaces(JackrabbitInitializer.java:282) ~[magnolia-content-types-1.1.jar:?]
	at info.magnolia.types.datasource.jcr.JackrabbitInitializer.initialize(JackrabbitInitializer.java:173) ~[magnolia-content-types-1.1.jar:?]
	at info.magnolia.types.datasource.jcr.JackrabbitInitializer.contentTypeChange(JackrabbitInitializer.java:144) ~[magnolia-content-types-1.1.jar:?]
	at info.magnolia.types.ContentTypeChangeEvent.dispatch(ContentTypeChangeEvent.java:75) ~[magnolia-content-types-1.1.jar:?]
	at info.magnolia.types.ContentTypeChangeEvent.dispatch(ContentTypeChangeEvent.java:44) ~[magnolia-content-types-1.1.jar:?]


 Comments   
Comment by Mikaël Geljić [ 20/Mar/20 ]

Actually the message-manager sending is just a normal consequence of registering; things go wrong before that.

  • Either during namespace (ns) registration, because PermissionAwareNamespaceRegistry checks for session state before checking namespace-management perms.
  • Or it happens during nodetype (nt) registration, like in your previous comment; session state looks incorrect in both cases.

Now, some new findings, all cases reproduced twice:

  1. register at install-time: PASS
  2. register at runtime, logged into admincentral as superuser: FAIL
  3. retry immediately after above: PASS
  4. register at runtime, not logged in: PASS
  5. register at runtime, logged into /travel as superuser: PASS
  6. register at runtime, logged in as superuser and logged out: PASS!
  7. register at runtime, logged in as eric: PASS

Irrelevant:

  • fresh/old repo
  • while debugging or not, eliminating race condition between workspace init and ns registration
  • CE vs. DX Core

Acknowledging retrying (#3) solves this, this has just become less critical now.

Comment by Dai Ha [ 23/Mar/20 ]

Re: #3 I can confirm that re-registering of the same content-type (modifying yaml case): PASS
However, new content-type still got the issue in 3# case. That because during initialization, we process 3 main things:

  • registerWorkspace
    --> fire A event which create noti message (only when workspace does not exists before and created runtime by content-type)
  • registerNamespaces
  • registerNodeTypes

-> so it is make sense when we pass the 2nd registration (modifying yaml case), there is no event fired with existing workspace (create during 1st try)

On the snippets https://git.magnolia-cms.com/snippets/95ab64e39510447d88d23bf9ec43ca45, I figured out that registerNamespaces was failed due to DefaultAccessManager instance (hashcode 143998348) was closed when the event handler of A kicked in:

398 2020-03-20 12:55:09,071 WARN  fo.magnolia.dev.fixture.setup.MgnlJcrAccessManager: Begin checkInitialized access manager: 143998348
398 2020-03-20 12:55:09,071 ERROR agnolia.types.datasource.jcr.JackrabbitInitializer: Failed to initialize content type [ct-countries].
java.lang.IllegalStateException: not initialized
	at org.apache.jackrabbit.core.security.DefaultAccessManager.checkInitialized(DefaultAccessManager.java:457) ~[jackrabbit-core-2.18.1.jar:2.18.1]
	at info.magnolia.dev.fixture.setup.MgnlJcrAccessManager.checkInitialized(MgnlJcrAccessManager.java:31) ~[magnolia-dev-fixture-module-1.0-SNAPSHOT.jar:?]

143998348 was closed way before

398 2020-03-20 12:55:09,070 WARN  fo.magnolia.dev.fixture.setup.MgnlJcrAccessManager: Close access manager stack java.lang.Exception: Instance hash143998348
	at info.magnolia.dev.fixture.setup.MgnlJcrAccessManager.close(MgnlJcrAccessManager.java:38)
	at org.apache.jackrabbit.core.SessionImpl.logout(SessionImpl.java:1015)
	at org.apache.jackrabbit.core.XASessionImpl.logout(XASessionImpl.java:394)
	at info.magnolia.jcr.wrapper.DelegateSessionWrapper.logout(DelegateSessionWrapper.java:262)
	at info.magnolia.repository.mbean.TrackingSessionWrapper.logout(TrackingSessionWrapper.java:57)
	at info.magnolia.jcr.wrapper.DelegateSessionWrapper.logout(DelegateSessionWrapper.java:262)
	at info.magnolia.jcr.wrapper.DelegateSessionWrapper.logout(DelegateSessionWrapper.java:262)
	at info.magnolia.jcr.wrapper.DelegateSessionWrapper.logout(DelegateSessionWrapper.java:262)
	at info.magnolia.jcr.wrapper.DelegateSessionWrapper.logout(DelegateSessionWrapper.java:262)
	at info.magnolia.jcr.wrapper.DelegateSessionWrapper.logout(DelegateSessionWrapper.java:262)
	at info.magnolia.context.AbstractRepositoryStrategy.releaseSession(AbstractRepositoryStrategy.java:99)
	at info.magnolia.context.AbstractRepositoryStrategy.release(AbstractRepositoryStrategy.java:87)
	at info.magnolia.context.SystemRepositoryStrategy.release(SystemRepositoryStrategy.java:59)
	at info.magnolia.context.AbstractContext.release(AbstractContext.java:308)
	at info.magnolia.context.AsynchronousContext$OperationFactory.lambda$wrap$0(AsynchronousContext.java:124)
	at info.magnolia.context.AsynchronousContext$OperationFactory.lambda$wrap$2(AsynchronousContext.java:135)
	at com.machinezoo.noexception.CheckedExceptionHandler$CheckedRunnable.run(CheckedExceptionHandler.java:97)
	at info.magnolia.admincentral.ResurfaceUI.lambda$accessSynchronously$0(ResurfaceUI.java:119)
	at com.vaadin.ui.UI.accessSynchronously(UI.java:1511)
	at info.magnolia.admincentral.ResurfaceUI.accessSynchronously(ResurfaceUI.java:109)
	at com.vaadin.ui.UI$3.run(UI.java:1575)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
	at java.util.concurrent.FutureTask.run(FutureTask.java)
	at com.vaadin.server.VaadinService.runPendingAccessTasks(VaadinService.java:2047)
	at com.vaadin.server.VaadinSession.unlock(VaadinSession.java:1018)
	at com.vaadin.server.VaadinService.ensureAccessQueuePurged(VaadinService.java:2012)
	at com.vaadin.server.VaadinService.accessSession(VaadinService.java:1978)
	at com.vaadin.server.VaadinSession.access(VaadinSession.java:1417)
	at com.vaadin.ui.UI.access(UI.java:1572)
	at info.magnolia.ui.framework.message.LocalMessageDispatcher.messageSent(LocalMessageDispatcher.java:72)
	at info.magnolia.ui.framework.message.MessagesManagerImpl.sendMessageSentEvent(MessagesManagerImpl.java:208)
	at info.magnolia.ui.framework.message.MessagesManagerImpl.sendMessage(MessagesManagerImpl.java:106)
	at info.magnolia.ui.framework.message.MessagesManagerImpl.sendRoleMessage(MessagesManagerImpl.java:123)
	at info.magnolia.ui.framework.UiFrameworkCompatibilityModule.lambda$start$2(UiFrameworkCompatibilityModule.java:126)
	at info.magnolia.types.datasource.jcr.WorkspaceInitializeEvent.dispatch(WorkspaceInitializeEvent.java:56)

One thing we can try is only fire the event A at the end of the flow, I will test it and provide PR if it is promising.

Generated at Mon Feb 12 00:37:31 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.