From 4b1faca762a45da77a07e133ad0df6a1e474e75e Mon Sep 17 00:00:00 2001 From: Marc Dutoo Date: Fri, 19 Aug 2016 15:18:49 +0200 Subject: [PATCH] workaround for #175 Project not found at startup because maxScan reached on model mongo queries --- .../entity/query/ldp/LdpEntityQueryServiceImpl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ozwillo-datacore-rest-server/src/main/java/org/oasis/datacore/core/entity/query/ldp/LdpEntityQueryServiceImpl.java b/ozwillo-datacore-rest-server/src/main/java/org/oasis/datacore/core/entity/query/ldp/LdpEntityQueryServiceImpl.java index 5ac3cffc..9410be2b 100644 --- a/ozwillo-datacore-rest-server/src/main/java/org/oasis/datacore/core/entity/query/ldp/LdpEntityQueryServiceImpl.java +++ b/ozwillo-datacore-rest-server/src/main/java/org/oasis/datacore/core/entity/query/ldp/LdpEntityQueryServiceImpl.java @@ -23,9 +23,11 @@ import org.oasis.datacore.core.meta.model.DCModelBase; import org.oasis.datacore.core.meta.model.DCModelService; import org.oasis.datacore.core.meta.model.DCResourceField; +import org.oasis.datacore.core.meta.pov.DCProject; import org.oasis.datacore.core.security.DCUserImpl; import org.oasis.datacore.core.security.EntityPermissionEvaluator; import org.oasis.datacore.core.security.service.DatacoreSecurityService; +import org.oasis.datacore.model.resource.ResourceMetamodelIniter; import org.oasis.datacore.rest.api.DCResource; import org.oasis.datacore.rest.api.DatacoreApi; import org.oasis.datacore.rest.server.MonitoringLogServiceImpl; @@ -718,7 +720,13 @@ private List executeMongoDbQuery(Query springMongoQuery, // (BEWARE it is NOT the max amount of doc returned because sorts or multiple // criteria can eat some scans) boolean applyMaxScan = queryParsingContext.isHasNoIndexedField() // true // to test only - || mgo == mgoManager.getDefaultMongoTemplate(); // else custom secondary + //&& !storageModel.getCollectionName().equals(DCProject.OASIS_META + '.' + ResourceMetamodelIniter.MODEL_MIXIN_NAME) // don't apply + && !storageModel.getCollectionName().startsWith(DCProject.OASIS_META + '.') // don't apply + // on metamodel ; WORKAROUND FOR #175 Project not found at startup because maxScan reached on model mongo queries + // which is OK because there are not a lot of entities in metamodel. + // Solution : maybe prefix existing indexes ex. _p.dcmo:globalFields.dcmf:name by _b, + // but shouldn't they be used anyway ? + && mgo == mgoManager.getDefaultMongoTemplate(); // don't apply on custom secondary int maxScan = 0; if (applyMaxScan) { maxScan = this.maxScan;