diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiFhirHibernateJpaDialect.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiFhirHibernateJpaDialect.java index 4e2b5d1f5c3..a926dc35c85 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiFhirHibernateJpaDialect.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiFhirHibernateJpaDialect.java @@ -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(); diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java index ee5228052c5..a4a4425071c 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java @@ -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()); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseComboParamsR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseComboParamsR4Test.java index bea022b22f8..f73670fbddc 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseComboParamsR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseComboParamsR4Test.java @@ -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); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamIT.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamIT.java index 5346c027c31..65dec5ee11c 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamIT.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamIT.java @@ -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 tables = myResourceTableDao.findAll(); - String resourceIds = tables.stream().map(t -> t.getIdDt().getValue()).collect(Collectors.joining(", ")); + List 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); }