Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2836

Issue with threading and incorrect data

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 1.13.0
    • Fix Version/s: None
    • Component/s: libbson, libmongoc
    • Labels:
      None
    • Environment:
      Windows 10

      Description

      Our server is multi-threaded and from what I can glime from the documentation it states that both mongodb c driver and bson is not thread safe.

      However I would have thought that if using the client pool I could get a client object for the thread that needs it so that the client object is thread safe and then getting a collection object from the client using mongoc_client_get_collection() and then a cursor object from the collection object using mongoc_collection_find_with_opts(), it should all be thread safe.

      All seems fine when performing requests across a single thread however if I start up a two or more threads I eventually get an issue where I am not seeing the correct data from the collection for that thread, I have created an assert that verifies that the data retrieved should be for that collection on a thread.

      Do I have to put a mutex lock/unlock combination around every bson and mongoc call?

      If that is the case the performance is going to be really bad.

       

       

       

       

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            pcarruthers Phillip Carruthers
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: