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

TASK-6754 - Create cohort with more than 1000 samples lead to MongoDB restarts #2517

Merged
merged 3 commits into from
Oct 22, 2024
Merged
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 @@ -70,11 +70,23 @@ public abstract class AnnotationMongoDBAdaptor<T> extends CatalogMongoDBAdaptor

protected abstract MongoDBCollection getCollection();

abstract OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, T entry, ObjectMap parameters,
OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, T entry, ObjectMap parameters,
List<VariableSet> variableSetList, QueryOptions queryOptions)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException {
return transactionalUpdate(clientSession, entry, parameters, variableSetList, queryOptions, true);
}

abstract OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, T entry, ObjectMap parameters,
List<VariableSet> variableSetList, QueryOptions queryOptions, boolean incrementVersion)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException;

abstract OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query, UpdateDocument updateDocument)
OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query, UpdateDocument updateDocument)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException {
return transactionalUpdate(clientSession, studyUid, query, updateDocument, true);
}

abstract OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query, UpdateDocument updateDocument,
boolean incrementVersion)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException;

public enum AnnotationSetParams implements QueryParam {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,20 +355,21 @@ OpenCGAResult transactionalUpdate(ClientSession clientSession, ClinicalAnalysis

@Override
OpenCGAResult<ClinicalAnalysis> transactionalUpdate(ClientSession clientSession, ClinicalAnalysis entry, ObjectMap parameters,
List<VariableSet> variableSetList, QueryOptions queryOptions)
List<VariableSet> variableSetList, QueryOptions queryOptions,
boolean incrementVersion)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException {
throw new NotImplementedException("Please call to the other transactionalUpdate method passing the ClinicalAudit list");
}

@Override
OpenCGAResult<ClinicalAnalysis> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query,
UpdateDocument updateDocument)
UpdateDocument updateDocument, boolean incrementVersion)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException {
long tmpStartTime = startQuery();

Document updateOperation = updateDocument.toFinalUpdateDocument();
if (!updateOperation.isEmpty()) {
return versionedMongoDBAdaptor.update(clientSession, query, entryList -> {
SnapshotVersionedMongoDBAdaptor.FunctionWithException<ClinicalAnalysis> updateClinicalReferences = (clinicalList) -> {
logger.debug("Update clinical analysis. Query: {}, Update: {}", query.toBsonDocument(), updateDocument);
DataResult<?> update = clinicalCollection.update(clientSession, query, updateOperation, null);

Expand All @@ -385,7 +386,12 @@ OpenCGAResult<ClinicalAnalysis> transactionalUpdate(ClientSession clientSession,

logger.debug("{} clinical analyses successfully updated", update.getNumUpdated());
return endWrite(tmpStartTime, update.getNumMatches(), update.getNumUpdated(), Collections.emptyList());
}, null, null);
};
if (incrementVersion) {
return versionedMongoDBAdaptor.update(clientSession, query, null, updateClinicalReferences, null, null);
} else {
return versionedMongoDBAdaptor.updateWithoutVersionIncrement(clientSession, query, null, updateClinicalReferences);
}
} else {
throw new CatalogDBException("Nothing to update");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public OpenCGAResult update(Query query, ObjectMap parameters, List<VariableSet>

@Override
OpenCGAResult<Cohort> transactionalUpdate(ClientSession clientSession, Cohort cohort, ObjectMap parameters,
List<VariableSet> variableSetList, QueryOptions queryOptions)
List<VariableSet> variableSetList, QueryOptions queryOptions, boolean incrementVersion)
throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException {
long tmpStartTime = startQuery();
Query tmpQuery = new Query()
Expand Down Expand Up @@ -341,7 +341,8 @@ OpenCGAResult<Cohort> transactionalUpdate(ClientSession clientSession, Cohort co
}

@Override
OpenCGAResult<Cohort> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query, UpdateDocument updateDocument)
OpenCGAResult<Cohort> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query, UpdateDocument updateDocument,
boolean incrementVersion)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException {
long tmpStartTime = startQuery();

Expand Down
Loading
Loading