Merge pull request #2899 from hapifhir/Partitioning-bug-in-resource-dao-svc-impl

set version map to check all partitions
This commit is contained in:
Tadgh 2021-08-17 20:42:34 -04:00 committed by GitHub
commit 61101d3637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -20,6 +20,7 @@ package ca.uhn.fhir.jpa.cache;
* #L%
*/
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
@ -28,6 +29,7 @@ import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.util.QueryChunker;
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -36,12 +38,15 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static org.slf4j.LoggerFactory.getLogger;
/**
* This service builds a map of resource ids to versions based on a SearchParameterMap.
* It is used by the in-memory resource-version cache to detect when resource versions have been changed by remote processes.
*/
@Service
public class ResourceVersionSvcDaoImpl implements IResourceVersionSvc {
private static final Logger ourLog = getLogger(ResourceVersionSvcDaoImpl.class);
@Autowired
DaoRegistry myDaoRegistry;
@ -53,7 +58,11 @@ public class ResourceVersionSvcDaoImpl implements IResourceVersionSvc {
public ResourceVersionMap getVersionMap(String theResourceName, SearchParameterMap theSearchParamMap) {
IFhirResourceDao<?> dao = myDaoRegistry.getResourceDao(theResourceName);
List<Long> matchingIds = dao.searchForIds(theSearchParamMap, new SystemRequestDetails()).stream()
if (ourLog.isDebugEnabled()) {
ourLog.debug("About to retrieve version map for resource type: {}", theResourceName);
}
List<Long> matchingIds = dao.searchForIds(theSearchParamMap, new SystemRequestDetails().setRequestPartitionId(RequestPartitionId.allPartitions())).stream()
.map(ResourcePersistentId::getIdAsLong)
.collect(Collectors.toList());