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

Issue with threading and incorrect data

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

      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.

       

       

       

       

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

              Created:
              Updated:
              Resolved: