Skip to content

Commit 501d41c

Browse files
issue #396 fix for derby deadlock issue
Signed-off-by: Albert Wang <xuwang@us.ibm.com>
1 parent 247153b commit 501d41c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

fhir-persistence-schema/src/main/java/com/ibm/fhir/schema/control/FhirResourceGroup.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ public void addLogicalResources(List<IDatabaseObject> group, String prefix) {
159159
.setTablespace(fhirTablespace)
160160
.addPrivileges(resourceTablePrivileges)
161161
.enableAccessControl(this.sessionVariable)
162+
// Add indexes to avoid dead lock issue of derby
163+
// Derby requires all columns used in where clause to be indexed, otherwise whole table lock will be
164+
// used instead of row lock, which can cause dead lock issue frequently during concurrent accesses.
165+
.addIndex(IDX + tableName + CURRENT_RESOURCE_ID, CURRENT_RESOURCE_ID)
166+
.addIndex(IDX + tableName + LOGICAL_ID, LOGICAL_ID)
162167
.build(model);
163168

164169
group.add(tbl);

0 commit comments

Comments
 (0)