Skip to content

Commit 4586f8f

Browse files
committed
GitHub Issue #783: Server lockup when updating data class domain design
1 parent c63767f commit 4586f8f

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,11 +1263,14 @@ public void indexDataClass(ExpDataClassImpl dataClass, SearchService.TaskIndexin
12631263
if (table == null)
12641264
return;
12651265

1266-
// Index the data class if it has never been indexed OR it has changed since it was last indexed
1266+
indexDataClassData(dataClass, q);
1267+
1268+
// GitHub Issue 783: Server lockup when updating data class domain design
1269+
// Index DataClass after data indexing, to avoid holding locks on exp.DataClass table for too long
12671270
SQLFragment sql = new SQLFragment("SELECT * FROM ")
12681271
.append(getTinfoDataClass(), "dc")
12691272
.append(" WHERE dc.LSID = ?").add(dataClass.getLSID())
1270-
.append(" AND (dc.lastIndexed IS NULL OR dc.lastIndexed < ?)")
1273+
.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
12711274
.add(dataClass.getModified());
12721275

12731276
DataClass dClass = new SqlSelector(getExpSchema().getScope(), sql).getObject(DataClass.class);
@@ -1276,8 +1279,6 @@ public void indexDataClass(ExpDataClassImpl dataClass, SearchService.TaskIndexin
12761279
ExpDataClassImpl impl = new ExpDataClassImpl(dClass);
12771280
impl.index(q, table);
12781281
}
1279-
1280-
indexDataClassData(dataClass, q);
12811282
});
12821283
}
12831284

@@ -8046,7 +8047,7 @@ public ValidationException updateDataClass(@NotNull Container c, @NotNull User u
80468047
if (!errors.hasErrors())
80478048
{
80488049
transaction.addCommitTask(() -> clearDataClassCache(c), DbScope.CommitTaskOption.IMMEDIATE, POSTCOMMIT, POSTROLLBACK);
8049-
transaction.addCommitTask(() -> indexDataClass(getDataClass(c, dataClass.getName()), SearchService.get().defaultTask().getQueue(c, SearchService.PRIORITY.modified)), POSTCOMMIT);
8050+
transaction.addCommitTask(() -> indexDataClass(dataClass, SearchService.get().defaultTask().getQueue(c, SearchService.PRIORITY.modified)), POSTCOMMIT);
80508051
transaction.commit();
80518052
}
80528053
}

experiment/src/org/labkey/experiment/api/SampleTypeServiceImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ public void indexSampleType(ExpSampleType sampleType, SearchService.TaskIndexing
331331
return;
332332

333333
queue.addRunnable((q) -> {
334+
indexSampleTypeMaterials(sampleType, q);
335+
336+
// GitHub Issue 783: Server lockup when updating data class domain design
337+
// Index MaterialSource after materials indexing, to avoid holding locks on exp.MaterialSource table for too long
334338
// Index all ExpMaterial that have never been indexed OR where either the ExpSampleType definition or ExpMaterial itself has changed since last indexed
335339
SQLFragment sql = new SQLFragment("SELECT * FROM ")
336340
.append(getTinfoMaterialSource(), "ms")
@@ -345,8 +349,6 @@ public void indexSampleType(ExpSampleType sampleType, SearchService.TaskIndexing
345349
ExpSampleTypeImpl impl = new ExpSampleTypeImpl(materialSource);
346350
impl.index(q, null);
347351
}
348-
349-
indexSampleTypeMaterials(sampleType, q);
350352
});
351353
}
352354

0 commit comments

Comments
 (0)