One more deadlock
This commit is contained in:
parent
82171da0cc
commit
2b72bb6c2f
|
@ -23,8 +23,6 @@ import java.util.*;
|
|||
import java.util.concurrent.*;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.transaction.Transactional.TxType;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
@ -35,6 +33,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.data.domain.*;
|
||||
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
|
||||
import org.springframework.transaction.*;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.*;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
@ -106,7 +106,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(value = TxType.NOT_SUPPORTED)
|
||||
@Transactional(propagation=Propagation.SUPPORTS)
|
||||
public List<Long> getResources(final String theUuid, int theFrom, int theTo) {
|
||||
if (myNeverUseLocalSearchForUnitTests == false) {
|
||||
SearchTask task = myIdToSearchTask.get(theUuid);
|
||||
|
@ -116,7 +116,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
}
|
||||
|
||||
TransactionTemplate txTemplate = new TransactionTemplate(myManagedTxManager);
|
||||
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
|
||||
Search search;
|
||||
StopWatch sw = new StopWatch();
|
||||
|
|
|
@ -37,7 +37,14 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
|||
retVal.setUrl("jdbc:derby:memory:myUnitTestDB;create=true");
|
||||
retVal.setUsername("");
|
||||
retVal.setPassword("");
|
||||
retVal.setMaxTotal((int)(Math.random() * 6) + 1);
|
||||
|
||||
/*
|
||||
* We use a randomized number of maximum threads in order to try
|
||||
* and catch any potential deadlocks caused by database connection
|
||||
* starvation
|
||||
*/
|
||||
int maxThreads = (int)(Math.random() * 6) + 1;
|
||||
retVal.setMaxTotal(maxThreads);
|
||||
|
||||
DataSource dataSource = ProxyDataSourceBuilder
|
||||
.create(retVal)
|
||||
|
|
|
@ -15,9 +15,11 @@ import org.hl7.fhir.dstu3.model.Bundle.BundleType;
|
|||
import org.hl7.fhir.dstu3.model.Bundle.HTTPVerb;
|
||||
import org.junit.*;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import ca.uhn.fhir.jpa.provider.dstu3.BaseResourceProviderDstu3Test;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
|
@ -162,16 +164,37 @@ public class StressTestDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
CloseableHttpResponse get = null;
|
||||
CloseableHttpResponse getResp = null;
|
||||
for (int i = 0; i < 20; i++) {
|
||||
try {
|
||||
get = ourHttpClient.execute(new HttpGet(ourServerBase + "/Patient?identifier=http%3A%2F%2Ftest%7CBAR," + UUID.randomUUID().toString()));
|
||||
Bundle respBundle;
|
||||
|
||||
// Load search
|
||||
HttpGet get = new HttpGet(ourServerBase + "/Patient?identifier=http%3A%2F%2Ftest%7CBAR," + UUID.randomUUID().toString());
|
||||
get.addHeader(Constants.HEADER_CONTENT_TYPE, Constants.CT_FHIR_JSON_NEW);
|
||||
getResp = ourHttpClient.execute(get);
|
||||
try {
|
||||
assertEquals(200, get.getStatusLine().getStatusCode());
|
||||
assertEquals(200, getResp.getStatusLine().getStatusCode());
|
||||
String respBundleString = IOUtils.toString(getResp.getEntity().getContent(), Charsets.UTF_8);
|
||||
respBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, respBundleString);
|
||||
myTaskCount++;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(get);
|
||||
IOUtils.closeQuietly(getResp);
|
||||
}
|
||||
|
||||
// Load page 2
|
||||
get = new HttpGet(respBundle.getLink("next").getUrl());
|
||||
get.addHeader(Constants.HEADER_CONTENT_TYPE, Constants.CT_FHIR_JSON_NEW);
|
||||
getResp = ourHttpClient.execute(get);
|
||||
try {
|
||||
assertEquals(200, getResp.getStatusLine().getStatusCode());
|
||||
String respBundleString = IOUtils.toString(getResp.getEntity().getContent(), Charsets.UTF_8);
|
||||
respBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, respBundleString);
|
||||
myTaskCount++;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(getResp);
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
ourLog.error("Failure during search", e);
|
||||
myError = e;
|
||||
|
|
Loading…
Reference in New Issue