Consider the following situation: A session is in r15. A change is made in a "live association cache"—that is, a cache where the cached list can be modified directly (e.g., by reordering or adding items). The local cache is requested. Before the refetch during the commit, a new object is added in a second session (in r16).
Now the commit (r17) fails.
The cause is that the local !DBContext is removed first, and then the association caches are updated. However, the session has not yet been updated to r17, so the new objects are no longer visible (they were visible before because they were accessible via the DBContext), resulting in a DeletedObjectAccess.
Noticed in Project
When reordering projects in Prime via the maintenance page /com.top_logic.project.pos/webapp/jsp/administration/maintenance/SortProjects.jsp, similarly:
List childs = ProjectRoot::getChildren(); Collections.sort(childs); ProjectRoot::setValue(StructuredElement.CHILDREN_ATTR, childs);
The following error occurred during the commit while updating/publishing the KB caches:
2020-06-18 17:42:08.931 ERROR [Default Executor-thread-30]: c.i._._SortProjects -- Error: Failed to update project sort order.
2020-06-18 17:42:08.932 ERROR [Default Executor-thread-30]: c.i._._SortProjects -- com.top_logic.knowledge.service.db2.DeletedObjectAccess: Object hasStructureChild:7333763 already deleted.
com.top_logic.knowledge.service.db2.DeletedObjectAccess: Object hasStructureChild:7333763 has already been deleted.
at com.top_logic.knowledge.service.db2.DBKnowledgeItem.checkAlive(DBKnowledgeItem.java:836)
at com.top_logic.knowledge.service.db2.DBKnowledgeItem.getAttributeValue(DBKnowledgeItem.java:175)
at com.top_logic.knowledge.service.db2.DBKnowledgeItem.getAttributeValue(DBKnowledgeItem.java:169)
at com.top_logic.knowledge.service.db2.DynamicKnowledgeItem.getAttributeValue(DynamicKnowledgeItem.java:101)
at com.top_logic.knowledge.service.db2.DBKnowledgeItem.getAttributeValue(DBKnowledgeItem.java:125)
at com.top_logic.knowledge.service.db2.AbstractDBKnowledgeItem.getAttributeValue(AbstractDBKnowledgeItem.java:298)
at com.top_logic.knowledge.service.db2.LiveAssociationsList.getPosition(LiveAssociationsList.java:137)
at com.top_logic.knowledge.service.db2.LiveAssociationsList.internalAdd(LiveAssociationsList.java:124)
at com.top_logic.knowledge.service.db2.LiveAssociationsList.addLinkResolved(LiveAssociationsList.java:111)
at com.top_logic.knowledge.service.db2.Associations.addLink(Associations.java:56)
at com.top_logic.knowledge.service.db2.AssociationCache.createLocalCache(AssociationCache.java:286)
at com.top_logic.knowledge.service.db2.AssociationCache.validateLocalCacheInCommit(AssociationCache.java:454)
at com.top_logic.knowledge.service.db2.AssociationCache.internalCommit(AssociationCache.java:497)
at com.top_logic.knowledge.service.db2.DefaultDBContext.publishAssociationCaches(DefaultDBContext.java:1063)
at com.top_logic.knowledge.service.db2.DefaultDBContext.localCommit(DefaultDBContext.java:1056)
at com.top_logic.knowledge.service.db2.DefaultDBContext.commitTransaction(DefaultDBContext.java:784)
at com.top_logic.knowledge.service.db2.DefaultDBContext.commitAnonymous(DefaultDBContext.java:717)
at com.top_logic.knowledge.service.db2.DBKnowledgeBase.commit(DBKnowledgeBase.java:2846)
at com.top_logic.util.MaintenanceJspBase.commit(MaintenanceJspBase.java:294)
at com.ibm._jsp._SortProjects.doWork(_SortProjects.java:100)
at com.top_logic.util.MaintenanceJspBase.runWork(MaintenanceJspBase.java:317)
at com.ibm._jsp._SortProjects._jspService(_SortProjects.java:389)
Test
TestAssociationCacheOrdered#testUpdateCacheOnConcurrentChange