[CDRIVER-3514] SCRAM cache should be shared among all pooled clients Created: 02/Feb/20  Updated: 16/Oct/23  Resolved: 12/Oct/23

Status: Closed
Project: C Driver
Component/s: auth, libmongoc, Performance
Affects Version/s: None
Fix Version/s: 1.25.0

Type: Improvement Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Kyle Kloberdanz
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File perf.svg     Zip Archive scram-cache-testing.zip    
Issue Links:
Depends
Epic Link: CDRIVER-4575
Quarter: FY24Q3

 Description   

The cache for SCRAM credentials is attached to the mongoc_cluster_t object, which manages the connections for a single mongoc_client_t.

However, this means that two mongoc_client_t's popped from a mongoc_pool_t have different SCRAM caches. I believe it should instead be moved to the mongoc_topology_t, so client pools can better utilize the cache.



 Comments   
Comment by Githook User [ 16/Oct/23 ]

Author:

{'name': 'Kyle Kloberdanz', 'email': 'kyle.kloberdanz@mongodb.com', 'username': 'kkloberdanz'}

Message: Fix Windows shared mutex unlocking (#1445)

Unlike a POSIX read/write lock, in which both a read lock and a write
lock are unlocked by the same function, Windows requires that a read
lock is unlocked by a different function than a write lock.

Related: CDRIVER-3514
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/2baa45ca752ffadd57ed8ea167fbe633db7e044a

Comment by Githook User [ 12/Oct/23 ]

Author:

{'name': 'Kyle Kloberdanz', 'email': 'kyle.kloberdanz@mongodb.com', 'username': 'kkloberdanz'}

Message: Share SCRAM cache via a global lookup table (#1406)

CDRIVER-3514

  • Share SCRAM cache via a global lookup table
  • Suppress pre-existing race condition
  • Fix pre-existing memory leak
  • Add test for scram cache invalidation

---------

Co-authored-by: Kevin Albertson <kevin.albertson@10gen.com>
Co-authored-by: Adrian Dole <donald@dole.tech>
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/84d9d8f5da9ded04d8d2ef9836373679bf8119fb

Comment by Josh Siegel (Inactive) [ 11/Aug/23 ]

I was unable to complete this ticket before my internship ended. Here is all of the progress I was able to make with an explanation and my thoughts on the next steps: https://github.com/mongodb/mongo-c-driver/pull/1375

Comment by Josh Siegel (Inactive) [ 08/Aug/23 ]

Here is a simple project to test changes against a local install of the C driver in `mongo-c-driver/.install` (see `configure.sh`): scram-cache-testing.zip

The steps to take to generate the FlameGraph are as follows:

  1. Start a local MongoDB server. Here is the command I run as an example:

mlaunch init \
--replicaset --nodes=1 --name=rs0 --priority --enableMajorityReadConcern \
--hostname localhost --setParameter enableTestCommands=1 \
--binarypath ~/bin/mongodl/archive/7.0.0-rc5/mongodb-linux-aarch64-enterprise-ubuntu2204-7.0.0-rc5/bin/ \
--dir .menv

      2. `./configure.sh`, `./build.sh`

      3.  `sudo perf record --call-graph fp ./test.sh`

      4.  `sudo chmod +rx perf.data`

      5.  `perf script | ./stackcollapse-perf.pl |./flamegraph.pl > perf.svg`

You can then download `perf.svg` and open it in a browser to view. I attached what it looks like for me prior to any changes.

Comment by Simon Eismann [ 05/Jun/23 ]

This currently causes our performance tests with 10K threads to be bottlenecked on the client side. See PERF-4166 and this Slack thread for details.

Generated at Wed Feb 07 21:18:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.