4 Replies Latest reply on Sep 20, 2016 10:20 AM by Antoine Mischler

    Mapdb exception after unregistering index

    Antoine Mischler Newbie

      Hi,

       

      We have published a new version of your application which unregisters an unused index from Modeshape configuration. The index has been removed from the Modeshape json configuration file. It seems that is was not sufficient to unregister this index on the repositories for which the index had been previously registered so we also execute the following command on repository startup :

       

      ((Workspace) session.getWorkspace()).getIndexManager().unregisterIndexes("nodesByUUID")

       

      For some users, the index wen't then corrupted and all save operations in the repository fail with the following exception :

       

      Caused by: java.lang.ClassCastException: org.mapdb.HTreeMap$LinkedNode cannot be cast to java.lang.Long

        at org.mapdb.Atomic$Long.get(Atomic.java:315) ~[dsdk-launcher.jar:na]

        at org.mapdb.Atomic$Long.incrementAndGet(Atomic.java:406) ~[dsdk-launcher.jar:na]

        at org.mapdb.Bind$1.update(Bind.java:146) ~[dsdk-launcher.jar:na]

        at org.mapdb.BTreeMap.notify(BTreeMap.java:2793) ~[dsdk-launcher.jar:na]

        at org.mapdb.BTreeMap.put2(BTreeMap.java:755) ~[dsdk-launcher.jar:na]

        at org.mapdb.BTreeMap.put(BTreeMap.java:643) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.index.local.LocalDuplicateIndex.add(LocalDuplicateIndex.java:91) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.spi.index.provider.IndexChangeAdapters$PropertyChangeAdapter.addValues(IndexChangeAdapters.java:694) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.spi.index.provider.IndexChangeAdapters$AbstractPropertyChangeAdapter.modifyProperties(IndexChangeAdapters.java:651) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.cache.change.ChangeSetAdapter.firePropertyChanges(ChangeSetAdapter.java:228) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.cache.change.ChangeSetAdapter.notify(ChangeSetAdapter.java:154) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.spi.index.provider.IndexProvider$AtomicIndex.notify(IndexProvider.java:1493) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.bus.RepositoryChangeBus.notify(RepositoryChangeBus.java:190) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.cache.document.WorkspaceCache.changed(WorkspaceCache.java:333) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.txn.SynchronizedTransactions.updateCache(SynchronizedTransactions.java:223) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:751) ~[dsdk-launcher.jar:na]

        at org.modeshape.jcr.JcrSession.save(JcrSession.java:1171) ~[dsdk-launcher.jar:na]

        ... 17 common frames omitted

       

      This does not happened for all of our users. Any idea where this error could come from ? Is this the correct way to unregister an index ?

       

      Note that we are using Modeshape 4.6.0.Final.

       

      Thanks for any help.

      --

      Antoine

        • 1. Re: Mapdb exception after unregistering index
          Horia Chiorean Master

          First, this particular exception seems to be related to a MapDB bug: Race condition in RECID reusal · Issue #445 · jankotek/mapdb · GitHub So it seems that you may come across this if you're using any of the local index provider caching options (cacheLRUEnable and cacheSize). If you are using any of those, remove them from the configuration.

           

          The stack trace shows the exception occurring when indexing some data, so not sure if it has anything to do with the unregistration of indexes or not (you are using the correct way of unregistering index definitions).

          • 2. Re: Mapdb exception after unregistering index
            Antoine Mischler Newbie

            Thanks for your anwser. It looks like the MapDB issue you pointed out is related to what we get. However, we don't use any of the caching options you mentioned. We are using the following index configuration :

             

            "indexProviders": {

              "local": {

               "classname": "org.modeshape.jcr.index.local.LocalIndexProvider",
               "directory": "${application.workspace}/indexes"
              }

            },
            "indexes": {

              "smartTextKeys": {

               "kind": "value",
               "provider": "local",
               "synchronous": "true",
               "nodeType": "dsdk:smarttext",
               "columns": "smartTextKey(STRING)"
              },
              "nodesByName": {

               "kind": "value",
               "provider": "local",
               "synchronous": "true",
               "nodeType": "nt:base",
               "columns": "name(STRING)"
              },
              "nodeTypes": {

               "kind": "nodeType",
               "provider": "local",
               "synchronous": "true",
               "nodeType": "nt:base",
               "columns": "jcr:primaryType(STRING)"
              },
              "nodesByPath": {

               "kind": "value",
               "provider": "local",
               "synchronous": "true",
               "nodeType": "nt:base",
               "columns": "jcr:path(PATH)"
              },
              "deletedNodes": {

               "kind": "nodeType",
               "provider": "local",
               "synchronous": "true",
               "nodeType": "mix:deleted",
               "columns": "jcr:mixinTypes(STRING)"
              }

            }

             

            Can you see anything wrong with this configuration ?

             

            You are right, the link with the index unregistration action is not clear. But this issue happened to many of our customers directly after the migration unregistering the index, so I guess this might be related. However, this is pretty hard to reproduce in a unit case, this issue seems to appear randomly.

            • 3. Re: Mapdb exception after unregistering index
              Horia Chiorean Master

              your index configuration looks fine. Without a test case which exposes the issue on the latest master (ModeShape 5.x) there's not much else one can do with this, especially since it's looking like a MapDB bug.

              • 4. Re: Mapdb exception after unregistering index
                Antoine Mischler Newbie

                It's not really easy to provide a unit test since its a random issue and it seems to be linked to the current index state when this happens which is pretty complicated to reproduce systematically. Anyway, we will plan an upgrade to Modeshape 5.x in the next months, we will see if this happens again after that.

                Thanks for your help.