Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-8568

prevent OConcurrentModificationException when expiring not found cache and updating package metadata at the same time for a npm repository

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.11.2
    • Fix Version/s: 2.11.3
    • Component/s: NPM
    • Labels:
      None
    • Story Points:
      1
    • Sprint:
      Sprint 42, Sprint 43

      Description

      The npm database can get in a state where expiring the not found cache on an npm repository can trigger an OConcurrentModificationException if package metadata is updated at the same time by another thread. The other thread would typically be a get or PUT request for an npm package.

      {{com.orientechnologies.orient.core.exception.OConcurrentModificationException: Cannot UPDATE the record #9:293 because the version is not the latest. Probably you are updating an old record or it has been modified by another user (db=v6 your=v5)
      }}

      2015-05-07 11:14:27,457-0400 INFO  [qtp1949268043-463] admin org.sonatype.nexus.logging.rest.LogResource - 
      *************************
      * expire cache at 11:00 *
      *************************
      2015-05-07 11:14:40,605-0400 INFO  [pxpool-1-thread-1] admin org.sonatype.nexus.tasks.ExpireCacheTask - Scheduled task (ExpireCacheTask) started :: Expiring caches for repository npm from path / and below.
      2015-05-07 11:14:42,305-0400 WARN  [pxpool-1-thread-1] admin org.sonatype.nexus.tasks.ExpireCacheTask - Scheduled task (ExpireCacheTask) failed :: Expiring caches for repository npm from path / and below. (started 2015-05-07T11:14:40-04:00, runtime 0:00:01.697)
      com.orientechnologies.orient.core.exception.OConcurrentModificationException: Cannot UPDATE the record #9:293 because the version is not the latest. Probably you are updating an old record or it has been modified by another user (db=v6 your=v5)
      	at com.orientechnologies.orient.core.conflict.OVersionRecordConflictStrategy.checkVersions(OVersionRecordConflictStrategy.java:54) ~[na:na]
      	at com.orientechnologies.orient.core.conflict.OVersionRecordConflictStrategy.onUpdate(OVersionRecordConflictStrategy.java:41) ~[na:na]
      	at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.checkAndIncrementVersion(OAbstractPaginatedStorage.java:2009) ~[na:na]
      	at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.doUpdateRecord(OAbstractPaginatedStorage.java:1643) ~[na:na]
      	at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.commitEntry(OAbstractPaginatedStorage.java:2094) ~[na:na]
      	at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.commit(OAbstractPaginatedStorage.java:910) ~[na:na]
      	at com.orientechnologies.orient.core.tx.OTransactionOptimistic.doCommit(OTransactionOptimistic.java:483) ~[na:na]
      	at com.orientechnologies.orient.core.tx.OTransactionOptimistic.commit(OTransactionOptimistic.java:147) ~[na:na]
      	at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2370) ~[na:na]
      	at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2340) ~[na:na]
      	at com.bolyuba.nexus.plugin.npm.service.internal.orient.OrientMetadataStore.updatePackages(OrientMetadataStore.java:334) ~[na:na]
      	at com.bolyuba.nexus.plugin.npm.service.internal.ProxyMetadataServiceImpl.expireMetadataCaches(ProxyMetadataServiceImpl.java:83) ~[na:na]
      	at com.bolyuba.nexus.plugin.npm.proxy.DefaultNpmProxyRepository.doExpireProxyCaches(DefaultNpmProxyRepository.java:150) ~[na:na]
      	at org.sonatype.nexus.proxy.repository.AbstractProxyRepository.doExpireCaches(AbstractProxyRepository.java:356) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.proxy.repository.AbstractRepository.expireCaches(AbstractRepository.java:430) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.proxy.repository.AbstractGroupRepository.doExpireCaches(AbstractGroupRepository.java:133) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.proxy.repository.AbstractRepository.expireCaches(AbstractRepository.java:430) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.proxy.repository.AbstractRepository.expireCaches(AbstractRepository.java:421) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.tasks.ExpireCacheTask.doRun(ExpireCacheTask.java:51) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.scheduling.AbstractNexusTask.call(AbstractNexusTask.java:151) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.scheduling.DefaultScheduledTask.call(DefaultScheduledTask.java:418) [nexus-scheduler-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.threads.MDCAwareCallable.call(MDCAwareCallable.java:44) [nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) [shiro-core-1.2.3.jar:1.2.3]
      	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) [shiro-core-1.2.3.jar:1.2.3]
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_45]
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [na:1.7.0_45]
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [na:1.7.0_45]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_45]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_45]
      	at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
      2015-05-07 11:14:42,340-0400 WARN  [pxpool-1-thread-1] admin org.sonatype.scheduling.DefaultScheduledTask - Exception in call method of scheduled task Internal
      com.orientechnologies.orient.core.exception.OConcurrentModificationException: Cannot UPDATE the record #9:293 because the version is not the latest. Probably you are updating an old record or it has been modified by another user (db=v6 your=v5)
      	at com.orientechnologies.orient.core.conflict.OVersionRecordConflictStrategy.checkVersions(OVersionRecordConflictStrategy.java:54) ~[na:na]
      	at com.orientechnologies.orient.core.conflict.OVersionRecordConflictStrategy.onUpdate(OVersionRecordConflictStrategy.java:41) ~[na:na]
      	at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.checkAndIncrementVersion(OAbstractPaginatedStorage.java:2009) ~[na:na]
      	at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.doUpdateRecord(OAbstractPaginatedStorage.java:1643) ~[na:na]
      	at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.commitEntry(OAbstractPaginatedStorage.java:2094) ~[na:na]
      	at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.commit(OAbstractPaginatedStorage.java:910) ~[na:na]
      	at com.orientechnologies.orient.core.tx.OTransactionOptimistic.doCommit(OTransactionOptimistic.java:483) ~[na:na]
      	at com.orientechnologies.orient.core.tx.OTransactionOptimistic.commit(OTransactionOptimistic.java:147) ~[na:na]
      	at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2370) ~[na:na]
      	at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2340) ~[na:na]
      	at com.bolyuba.nexus.plugin.npm.service.internal.orient.OrientMetadataStore.updatePackages(OrientMetadataStore.java:334) ~[na:na]
      	at com.bolyuba.nexus.plugin.npm.service.internal.ProxyMetadataServiceImpl.expireMetadataCaches(ProxyMetadataServiceImpl.java:83) ~[na:na]
      	at com.bolyuba.nexus.plugin.npm.proxy.DefaultNpmProxyRepository.doExpireProxyCaches(DefaultNpmProxyRepository.java:150) ~[na:na]
      	at org.sonatype.nexus.proxy.repository.AbstractProxyRepository.doExpireCaches(AbstractProxyRepository.java:356) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.proxy.repository.AbstractRepository.expireCaches(AbstractRepository.java:430) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.proxy.repository.AbstractGroupRepository.doExpireCaches(AbstractGroupRepository.java:133) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.proxy.repository.AbstractRepository.expireCaches(AbstractRepository.java:430) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.proxy.repository.AbstractRepository.expireCaches(AbstractRepository.java:421) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.tasks.ExpireCacheTask.doRun(ExpireCacheTask.java:51) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.scheduling.AbstractNexusTask.call(AbstractNexusTask.java:151) ~[nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.scheduling.DefaultScheduledTask.call(DefaultScheduledTask.java:418) ~[nexus-scheduler-2.11.2-06.jar:2.11.2-06]
      	at org.sonatype.nexus.threads.MDCAwareCallable.call(MDCAwareCallable.java:44) [nexus-core-2.11.2-06.jar:2.11.2-06]
      	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) [shiro-core-1.2.3.jar:1.2.3]
      	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) [shiro-core-1.2.3.jar:1.2.3]
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_45]
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [na:1.7.0_45]
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [na:1.7.0_45]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_45]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_45]
      	at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
      2015-05-07 11:14:42,340-0400 INFO  [pxpool-1-thread-1] admin org.sonatype.nexus.configuration.application.DefaultNexusConfiguration - Applying Nexus Configuration due to changes in [Scheduled Tasks] made by *TASK...
      
      

      Expected: do better preventing this commonly reproducible concurrency issue

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jtom Joe Tom
              Reporter:
              plynch Peter Lynch
              Last Updated By:
              Peter Lynch Peter Lynch
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response:

                  tigCommentSecurity.panel-title