Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-33169

Hierarchy Table Indexes can get out of sync

    Details

    • Type: Bug
    • Status: RESOLVED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.9.4 [Tentative]
    • Fix Version/s: None
    • Component/s: DelegatedAccess
    • Labels:
      None
    • Previous Issue Keys:
      DAC-52

      Description

      Somehow during the Site Hierarchy Job, the hierarchy service ends up getting the HIERARCHY_NODE and HIERARCHY_NODE_META sequences out of sync, causing the Hierarchy Job to not work properly.

      A tell tail sign is this error:

      java.lang.IllegalArgumentException: Invalid node id, cannot find node with id: 27673
      at org.sakaiproject.hierarchy.impl.HierarchyServiceImpl.saveNodeMetaData(HierarchyServiceImpl.java:338)
      at org.sakaiproject.delegatedaccess.jobs.DelegatedAccessSiteHierarchyJob.checkAndAddNode(DelegatedAccessSiteHierarchyJob.java:235)
      at org.sakaiproject.delegatedaccess.jobs.DelegatedAccessSiteHierarchyJob.execute(DelegatedAccessSiteHierarchyJob.java:144)
      at org.sakaiproject.component.app.scheduler.jobs.SpringJobBeanWrapper.execute(SpringJobBeanWrapper.java:70)
      at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
      at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:534)
      mgt40203_f13: Invalid node id, cannot find node with id: 27674

      This is because the metadata id is out of sync with the node id. To fix this issue manually, do the following:

      1) Make sure all the null titles/descriptions are removed:

      Update HIERARCHY_NODE hn

      right join (select ID from HIERARCHY_NODE_META where TITLE is null or description is null) a on hn.childIds like concat('%:', concat(a.ID, ':%'))

      set hn.childIds = replace(hn.childIds, concat(':', concat(a.ID, ':')), ":");

      Update HIERARCHY_NODE hn

      right join (select ID from HIERARCHY_NODE_META where TITLE is null or description is null) a on hn.directchildIds like concat('%:', concat(a.ID, ':%'))

      set hn.directchildIds = replace(hn.directchildIds, concat(':', concat(a.ID, ':')), ":");

      *Run both of the updates until you see "0 record(s) affected". Once all updates are complete, then you can run the delete queries below

      Delete From HIERARCHY_PERMS where nodeId in (select ID from HIERARCHY_NODE_META where title is null or description is null);

      Delete from HIERARCHY_NODE where id in (select ID from HIERARCHY_NODE_META where title is null or description is null);

      Delete From HIERARCHY_NODE_META where title is null or description is null;

      2) Update the job last ran flag to a time before you saw this error:

      Select * FROM HIERARCHY_PERMS where permission like 'siteHierarchyJobLastRunDate%'

      (update this record)

      3) Make sure the Indexes are in sync

      There are 2 indexes:

      HIERARCHY_NODE

      HIERARCHY_NODE_META

      However, this isn't a good solution! We need a programatic one. So I've attached a patch this this jira that will check if the indexes are out of sync and attempt to resync them automatically. Looking at the patch, you might think it is slower, but it is probably faster than the original code.

      Old Way:

      dao.saveMixedSet(entitySets);
      ->checkEntitySet
      ->checkEntitySet
      ->saveSet
      ----->checkEntitySet
      ->saveSet
      ----->checkEntitySet

      New Way

      dao.saveSet
      --->checkEntitySet
      null & != check
      dao.saveSet
      --->checkEntitySet
      null & != check

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  baholladay Bryan Holladay
                  Reporter:
                  baholladay Bryan Holladay
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Git Source Code