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

EVA-3396 - Few small changes to enforce concerns regardless of the Spring context #10

Open
wants to merge 1 commit into
base: main
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 @@ -16,6 +16,8 @@
package uk.ac.ebi.eva.groovy.commons

import com.mongodb.MongoBulkWriteException
import com.mongodb.ReadPreference
import com.mongodb.WriteConcern
import com.mongodb.bulk.BulkWriteResult
import com.mongodb.MongoClient
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -88,6 +90,8 @@ class EVADatabaseEnvironment {

def mc = context.getBean(MongoClient.class)
def mt = context.getBean(MongoTemplate.class)
mt.setReadPreference(ReadPreference.primary())
mt.setWriteConcern(WriteConcern.MAJORITY)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the Spring context and application, these may not be fully enforced. So we are extra cautious here and explicitly setting them.

def (sva, cva) = [null, null]
try {
sva = context.getBean(SubmittedVariantAccessioningService.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RetryableBatchingCursor<T> implements Iterable<T> {
.causallyConsistent(true).build()
ClientSession session = null
try {
this.mongoTemplate.mongoDbFactory.getSession(sessionOptions)
session = this.mongoTemplate.mongoDbFactory.getSession(sessionOptions)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how the code worked without this so far!

this.hasSessionSupport = true
}
catch (MongoClientException ex) { // Handle stand-alone instances that don't have session support
Expand Down
Loading