combosp intermittent (#5225)

* fix intermittent

* spotless
This commit is contained in:
Ken Stevens 2023-08-22 09:59:11 -04:00 committed by GitHub
parent deeffe2253
commit 943a052a0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 8 deletions

View File

@ -26,6 +26,7 @@ import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedComboStringUnique;
import ca.uhn.fhir.jpa.model.entity.ResourceSearchUrlEntity;
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
import ca.uhn.fhir.system.HapiSystemProperties;
import org.hibernate.HibernateException;
import org.hibernate.PessimisticLockException;
import org.hibernate.exception.ConstraintViolationException;
@ -71,6 +72,10 @@ public class HapiFhirHibernateJpaDialect extends HibernateJpaDialect {
messageToPrepend = theMessageToPrepend + " - ";
}
if (HapiSystemProperties.isUnitTestModeEnabled()) {
ourLog.error("Hibernate exception", theException);
}
if (theException instanceof ConstraintViolationException) {
String constraintName = ((ConstraintViolationException) theException).getConstraintName();

View File

@ -454,7 +454,11 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
extractParameterCombinationsForComboParam(theParams, theResourceType, theRuntimeParam);
for (String nextQueryString : queryStringsToPopulate) {
ourLog.trace("Adding composite unique SP: {}", nextQueryString);
ourLog.trace(
"Adding composite unique SP: {} on {} for {}",
nextQueryString,
theResourceType,
theRuntimeParam.getId());
ResourceIndexedComboStringUnique uniqueParam = new ResourceIndexedComboStringUnique();
uniqueParam.setIndexString(nextQueryString);
uniqueParam.setSearchParameterId(theRuntimeParam.getId());

View File

@ -36,6 +36,7 @@ public abstract class BaseComboParamsR4Test extends BaseJpaR4Test {
@BeforeEach
public void before() throws Exception {
super.before();
myStorageSettings.setMarkResourcesForReindexingUponSearchParameterChange(false);
myStorageSettings.setDefaultSearchParamsCanBeOverridden(true);
myStorageSettings.setSchedulingDisabled(true);
myStorageSettings.setUniqueIndexesEnabled(true);

View File

@ -17,7 +17,6 @@ import ca.uhn.fhir.rest.param.DateParam;
import ca.uhn.fhir.rest.param.ReferenceParam;
import ca.uhn.fhir.rest.param.TokenAndListParam;
import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.util.HapiExtensions;
@ -52,6 +51,7 @@ import java.util.UUID;
import java.util.stream.Collectors;
import static ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.INDEX_STATUS_INDEXED;
import static ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.INDEX_STATUS_INDEXING_FAILED;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
@ -862,12 +862,14 @@ public class FhirResourceDaoR4ComboUniqueParamIT extends BaseComboParamsR4Test {
executeReindex("Coverage?");
runInTransaction(() -> {
List<ResourceTable> tables = myResourceTableDao.findAll();
String resourceIds = tables.stream().map(t -> t.getIdDt().getValue()).collect(Collectors.joining(", "));
List<ResourceTable> resources = myResourceTableDao.findAll();
String resourceIds = resources.stream().map(t -> t.getIdDt().getValue()).collect(Collectors.joining(", "));
// 1 patient, 1 coverage, 3 search parameters
assertEquals(5, tables.size(), resourceIds);
for (int i = 0; i < tables.size(); i++) {
assertEquals(INDEX_STATUS_INDEXED, tables.get(i).getIndexStatus().intValue());
assertEquals(5, resources.size(), resourceIds);
for (int i = 0; i < resources.size(); i++) {
int indexStatus = resources.get(i).getIndexStatus().intValue();
assertEquals(INDEX_STATUS_INDEXED, indexStatus, "Expected resource " + i + " to have index status INDEXED but was " +
(indexStatus == INDEX_STATUS_INDEXING_FAILED ? "FAILED" : "UNKNOWN(" + indexStatus + ")"));
}
});
@ -890,7 +892,8 @@ public class FhirResourceDaoR4ComboUniqueParamIT extends BaseComboParamsR4Test {
JobInstanceStartRequest startRequest = new JobInstanceStartRequest();
startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX);
startRequest.setParameters(parameters);
Batch2JobStartResponse res = myJobCoordinator.startInstance(startRequest);
Batch2JobStartResponse res = myJobCoordinator.startInstance(mySrd, startRequest);
ourLog.info("Started reindex job with id {}", res.getInstanceId());
myBatch2JobHelper.awaitJobCompletion(res);
}