Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-30264

DocumentModelStatusPersister should create its documents atomically

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: HOTFIX_10.10, 2021.x, 11.x
    • Component/s: Core

      Description

      The DocumentModelStatusPersister creates some documents during Nuxeo startup:

      • the /management container
      • the /management/administrative-infos container
      • several documents inside the above one representing the AdministrativeStatus contributed to Nuxeo Server

      These creations are not made in an atomic way, they use the pattern if doesn't exist then create it, else get it and finally update some metadata. This could lead to race issues in cluster mode, we're ending with two or more documents holding the same status:instanceId and status:serviceId. This leads to startup error such as below:

      WARN  [main] [org.nuxeo.ecm.core.management.storage.DocumentModelStatusPersister] Unable to fetch status for service org.nuxeo.ecm.instance.availability in instance Linux-5fdb281ce217f3c395c9f08123080744-4c7247d688f3498bd6df6681b381f5a4
      ERROR [main] [org.nuxeo.osgi.OSGiAdapter] Error during Framework Listener execution : class org.nuxeo.runtime.osgi.OSGiRuntimeService
      java.lang.NullPointerException: null
      	at org.nuxeo.ecm.platform.web.common.admin.AdministrativeStatusListener.handleEvent(AdministrativeStatusListener.java:75) ~[nuxeo-platform-web-common-10.10-HF27.jar:?]
      	at org.nuxeo.runtime.services.event.EventService.sendEvent(EventService.java:126) ~[nuxeo-runtime-10.10-HF10.jar:?]
      	at org.nuxeo.runtime.services.event.EventService.sendEvent(EventService.java:100) ~[nuxeo-runtime-10.10-HF10.jar:?]
      	at org.nuxeo.ecm.core.management.statuses.RuntimeEventNotifier.notifyEvent(RuntimeEventNotifier.java:35) ~[nuxeo-core-management-10.10-HF19.jar:?]
      	at org.nuxeo.ecm.core.management.statuses.AdministrativeStatusManagerImpl.notifyEvent(AdministrativeStatusManagerImpl.java:78) ~[nuxeo-core-management-10.10-HF19.jar:?]
      	at org.nuxeo.ecm.core.management.statuses.AdministrativeStatusManagerImpl.notifyOnStatus(AdministrativeStatusManagerImpl.java:152) ~[nuxeo-core-management-10.10-HF19.jar:?]
      	at org.nuxeo.ecm.core.management.statuses.AdministrativeStatusManagerImpl.doNotifyAllStatuses(AdministrativeStatusManagerImpl.java:118) ~[nuxeo-core-management-10.10-HF19.jar:?]
      	at org.nuxeo.ecm.core.management.statuses.AdministrativeStatusManagerImpl.onNuxeoServerStartup(AdministrativeStatusManagerImpl.java:104) ~[nuxeo-core-management-10.10-HF19.jar:?]
      	at org.nuxeo.ecm.core.management.CoreManagementComponent.onNuxeoServerStartup(CoreManagementComponent.java:141) ~[nuxeo-core-management-10.10-HF19.jar:?]
      	at org.nuxeo.ecm.core.management.storage.DocumentStoreManager.doInitializeRepository(DocumentStoreManager.java:107) ~[nuxeo-core-management-10.10-HF19.jar:?]
      	at org.nuxeo.ecm.core.repository.RepositoryInitializationHandler.initializeRepository(RepositoryInitializationHandler.java:93) ~[nuxeo-core-10.10-HF36.jar:?]
      	at org.nuxeo.ecm.core.repository.RepositoryInitializationHandler.initializeRepository(RepositoryInitializationHandler.java:91) ~[nuxeo-core-10.10-HF36.jar:?]
      	at org.nuxeo.ecm.core.repository.RepositoryService$2.run(RepositoryService.java:158) ~[nuxeo-core-10.10-HF36.jar:?]
      	at org.nuxeo.ecm.core.api.UnrestrictedSessionRunner.runUnrestricted(UnrestrictedSessionRunner.java:137) ~[nuxeo-core-api-10.10-HF37.jar:?]
      	at org.nuxeo.ecm.core.repository.RepositoryService.initializeRepository(RepositoryService.java:160) ~[nuxeo-core-10.10-HF36.jar:?]
      	at org.nuxeo.ecm.core.repository.RepositoryService.doInitRepositories(RepositoryService.java:142) ~[nuxeo-core-10.10-HF36.jar:?]
      	at org.nuxeo.runtime.transaction.TransactionHelper.lambda$runInTransaction$5(TransactionHelper.java:587) ~[nuxeo-runtime-jtajca-10.10-HF14.jar:?]
      	at org.nuxeo.runtime.transaction.TransactionHelper.runInTransaction(TransactionHelper.java:607) ~[nuxeo-runtime-jtajca-10.10-HF14.jar:?]
      	at org.nuxeo.runtime.transaction.TransactionHelper.runInTransaction(TransactionHelper.java:587) ~[nuxeo-runtime-jtajca-10.10-HF14.jar:?]
      	at org.nuxeo.ecm.core.repository.RepositoryService.initRepositories(RepositoryService.java:100) ~[nuxeo-core-10.10-HF36.jar:?]
      	at org.nuxeo.ecm.core.repository.RepositoryService$1.afterStart(RepositoryService.java:78) ~[nuxeo-core-10.10-HF36.jar:?]
      	at org.nuxeo.runtime.model.impl.ComponentManagerImpl$Listeners.afterStart(ComponentManagerImpl.java:1135) ~[nuxeo-runtime-10.10-HF10.jar:?]
      	at org.nuxeo.runtime.model.impl.ComponentManagerImpl.startComponents(ComponentManagerImpl.java:695) ~[nuxeo-runtime-10.10-HF10.jar:?]
      

      We should use the CoreSession#getOrCreateDocument API for this usage to have an atomic behavior. The code to change is in DocumentModelStatusPersister.StatusSaver

      Also, we might want to change the DocumentModelStatusPersister#getStatus to log a WARN error in case there's more than one element but return the first one instead of null.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                kleturc Kevin Leturc
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  PagerDuty

                  Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.