diff --git a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java index 367d743da66..cd4d69cbd2e 100644 --- a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java +++ b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java @@ -1263,11 +1263,14 @@ public void indexDataClass(ExpDataClassImpl dataClass, SearchService.TaskIndexin if (table == null) return; - // Index the data class if it has never been indexed OR it has changed since it was last indexed + indexDataClassData(dataClass, q); + + // GitHub Issue 783: Server lockup when updating data class domain design + // Index DataClass after data indexing, to avoid holding locks on exp.DataClass table for too long SQLFragment sql = new SQLFragment("SELECT * FROM ") .append(getTinfoDataClass(), "dc") .append(" WHERE dc.LSID = ?").add(dataClass.getLSID()) - .append(" AND (dc.lastIndexed IS NULL OR dc.lastIndexed < ?)") + .append(" AND (dc.lastIndexed IS NULL OR dc.lastIndexed < ?)") // Index the data class if it has never been indexed OR it has changed since it was last indexed .add(dataClass.getModified()); DataClass dClass = new SqlSelector(getExpSchema().getScope(), sql).getObject(DataClass.class); @@ -1276,8 +1279,6 @@ public void indexDataClass(ExpDataClassImpl dataClass, SearchService.TaskIndexin ExpDataClassImpl impl = new ExpDataClassImpl(dClass); impl.index(q, table); } - - indexDataClassData(dataClass, q); }); } @@ -8046,7 +8047,7 @@ public ValidationException updateDataClass(@NotNull Container c, @NotNull User u if (!errors.hasErrors()) { transaction.addCommitTask(() -> clearDataClassCache(c), DbScope.CommitTaskOption.IMMEDIATE, POSTCOMMIT, POSTROLLBACK); - transaction.addCommitTask(() -> indexDataClass(getDataClass(c, dataClass.getName()), SearchService.get().defaultTask().getQueue(c, SearchService.PRIORITY.modified)), POSTCOMMIT); + transaction.addCommitTask(() -> indexDataClass(dataClass, SearchService.get().defaultTask().getQueue(c, SearchService.PRIORITY.modified)), POSTCOMMIT); transaction.commit(); } } diff --git a/experiment/src/org/labkey/experiment/api/SampleTypeServiceImpl.java b/experiment/src/org/labkey/experiment/api/SampleTypeServiceImpl.java index af04d68fa32..94b1feb99a9 100644 --- a/experiment/src/org/labkey/experiment/api/SampleTypeServiceImpl.java +++ b/experiment/src/org/labkey/experiment/api/SampleTypeServiceImpl.java @@ -331,6 +331,10 @@ public void indexSampleType(ExpSampleType sampleType, SearchService.TaskIndexing return; queue.addRunnable((q) -> { + indexSampleTypeMaterials(sampleType, q); + + // GitHub Issue 783: Server lockup when updating data class domain design + // Index MaterialSource after materials indexing, to avoid holding locks on exp.MaterialSource table for too long // Index all ExpMaterial that have never been indexed OR where either the ExpSampleType definition or ExpMaterial itself has changed since last indexed SQLFragment sql = new SQLFragment("SELECT * FROM ") .append(getTinfoMaterialSource(), "ms") @@ -345,8 +349,6 @@ public void indexSampleType(ExpSampleType sampleType, SearchService.TaskIndexing ExpSampleTypeImpl impl = new ExpSampleTypeImpl(materialSource); impl.index(q, null); } - - indexSampleTypeMaterials(sampleType, q); }); }