Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-1578

CSFLE test bypass_mongocryptd_via_shared_library is flaky

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.4.0
    • Affects Version/s: None
    • Component/s: None
    • None

      The test will sometimes fail (example) with:
      [2023/01/05 23:53:50.372] Error: Kind: An error occurred during client-side encryption: CryptShared (1): csfle lib_create() failed: Cannot initialize the Mongo Crypt Shared Support Library when it is already initialized. [Error 3, code 1], labels: {}

      This failure happens at the EncryptedClientBuilder::build method, tracing back to the libmongocrypt mongocrypt_init call.

      Open questions:

      • Why does this failure happen at all? Loading and unloading of the shared support library loading is handled entirely within libmongocrypt, and it's explicitly documented that creating multiple handles via mongocrypt_init is allowed.
      • Even given the above, all of the csfle tests are exclusive, so there shouldn't be multiple instances existing at any given moment anyway.
      • Why does this failure only happen in that test? It doesn't do anything notable with initialization (single instance, standard setup).
      • Why does this failure only happen on MacOS? This is likely a timing issue; we've seen that other flaky tests are more likely to fail there as well.

      My current theory is that there's some race condition within libmongocrypt initialization that doesn't properly handle concurrent [de]initialization; that's getting tickled (somehow) by the background nature of `Client` teardown, which is (again, hypothetically) allowing a previously-constructed `Crypt` to persist in lifetime into the execution of the above test.

            Assignee:
            abraham.egnor@mongodb.com Abraham Egnor
            Reporter:
            abraham.egnor@mongodb.com Abraham Egnor
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: