Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in RequestPartitionId.isDefaultPartition #6565

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Slice<JpaPid> findIdsOfResourcesWithinUpdatedRangeOrderedFromNewest(
Slice<JpaPid> findIdsOfResourcesWithinUpdatedRangeOrderedFromOldest(
Pageable thePage, @Param("low") Date theLow, @Param("high") Date theHigh);

//TODO A :Look at below TODO B, and note that these 2 queries are identical.
@Query(
"SELECT t.myPid, t.myResourceType, t.myUpdated FROM ResourceTable t WHERE t.myUpdated >= :low AND t.myUpdated <= :high ORDER BY t.myUpdated ASC")
Stream<Object[]> streamIdsTypesAndUpdateTimesOfResourcesWithinUpdatedRangeOrderedFromOldest(
Expand All @@ -80,6 +81,7 @@ Stream<Object[]> streamIdsTypesAndUpdateTimesOfResourcesWithinUpdatedRangeOrdere
@Param("high") Date theHigh,
@Param("partition_ids") List<Integer> theRequestPartitionIds);

//TODO B: look at this query. This is not a default partition query, this is an all partitions query.
@Query(
"SELECT t.myPid, t.myResourceType, t.myUpdated FROM ResourceTable t WHERE t.myUpdated >= :low AND t.myUpdated <= :high ORDER BY t.myUpdated ASC")
Stream<Object[]> streamIdsTypesAndUpdateTimesOfResourcesWithinUpdatedRangeOrderedFromOldestForDefaultPartition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class RequestPartitionHelperSvc extends BaseRequestPartitionHelperSvc {

public RequestPartitionHelperSvc() {}

//TODO C: Looks like this code here corrects the null partition and converts it into the actual default partition, but is this called everywhere?
@Override
public RequestPartitionId validateAndNormalizePartitionIds(RequestPartitionId theRequestPartitionId) {
List<String> names = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public Condition createPredicateResourceIds(boolean theInverse, Collection<JpaPi
return inResourceIds;
}

//TODO C: This code appears to kinda try to do what we are anticipating, by swapping out the `null` for the actual default partition, but is not widely used.
public static List<Integer> replaceDefaultPartitionIdIfNonNull(
PartitionSettings thePartitionSettings, List<Integer> thePartitionIds) {
List<Integer> partitionIds = thePartitionIds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void before() throws Exception {
super.before();

myPartitionSettings.setPartitioningEnabled(true);
myPartitionSettings.setDefaultPartitionId(0); //TODO Note this change
myPartitionLookupSvc.createPartition(new PartitionEntity().setId(1).setName(PARTITION_1), null);
myPartitionLookupSvc.createPartition(new PartitionEntity().setId(2).setName(PARTITION_2), null);
myPartitionLookupSvc.createPartition(new PartitionEntity().setId(3).setName(PARTITION_GOLDEN_RESOURCE), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import ca.uhn.fhir.jpa.test.BaseJpaR4Test;
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import org.hl7.fhir.r4.model.ConceptMap;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Patient;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
Expand All @@ -37,6 +35,8 @@ class RequestPartitionHelperSvcTest extends BaseJpaR4Test {
static final int UNKNOWN_PARTITION_ID = 1_000_000;
static final String UNKNOWN_PARTITION_NAME = "UNKNOWN";

// static final int CUSTOM_DEFAULT_PARTITION_ID = 666;

@Autowired
IPartitionDao myPartitionDao;
@Autowired
Expand All @@ -49,6 +49,7 @@ class RequestPartitionHelperSvcTest extends BaseJpaR4Test {
@BeforeEach
public void before(){
myPartitionDao.deleteAll();
myPartitionSettings.setDefaultPartitionId(null);
myPartitionSettings.setPartitioningEnabled(true);

myPatient = new Patient();
Expand Down
Loading