[JAVA-4362] KeyRetriever uses majority read concern in a hard-coded way that breaks while disabling majority read concern Created: 20/Oct/21  Updated: 22/Jun/22

Status: Blocked
Project: Java Driver
Component/s: Client Side Encryption
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Mohammad Javadi Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: external-user
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to DRIVERS-1960 Make read concern and write concern f... Backlog

 Description   

I'm using client-side field-level encryption. I realized when the driver wants to fetch the key from db, it uses com.mongodb.client.internal.KeyRetriever class internally:

    public List<BsonDocument> find(final BsonDocument keyFilter) {
        return client.getDatabase(namespace.getDatabaseName()).getCollection(namespace.getCollectionName(), BsonDocument.class)
                .withReadConcern(ReadConcern.MAJORITY)
                .find(keyFilter).into(new ArrayList<BsonDocument>());
    }

I can see readConcern has set to majority. This one leads to a problem since I use a PSA architecture and I disabled the majority read concern as it's suggested in the MongoDB documentation
this method should respect the client setting that I've provided while creating the client:

ClientEncryptionSettings clientEncryptionSettings = ClientEncryptionSettings.builder()
        .keyVaultMongoClientSettings(MongoClientSettings.builder()
                .applyConnectionString(new ConnectionString(mongodbUri))
                .readConcern(ReadConcern.AVAILABLE)
                .build())

but it doesn't
 



 Comments   
Comment by Jeffrey Yemin [ 20/Oct/21 ]

Hi javadi91.5@gmail.com,

Thanks for reporting this.  We're discussing with the rest of the drivers team (as all of our drivers behave similarly), and will get back to you.

I changed the priority to Major since I believe there is a workaround (temporarily re-enable majority read concern).

Generated at Thu Feb 08 09:01:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.