Change Transactions Examples to not drop database

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • None
    • Component/s: None
    • None

      In sharding, dropping the database does not go through database versioning. So if you have more than 1 mongos and are round robining requests (in the way all drivers do) any mongos that did not explicitly send the drop or create will not discover that the database exists, thus sending incorrect results. For example after inserting data and then performing a count, you'll see the count is 0. See this ticket for details: HELP-9914

      We're working on potential solutions on the server-side, but I want to update all the transactions examples that we'd like to reference in the general public beta.

      I do not believe the node examples have this issue: https://gist.github.com/mbroadst/2a719a7adeb8b0476f50ac5643d70166

      Python does: https://github.com/mongodb/mongo-python-driver/blob/3.7.0b0/test/test_examples.py#L849

      Java also does: https://gist.github.com/jyemin/7031cc235759e4619ab0ab342f22db37#file-betaexamples-java-L53

      Changing Java to the below works

             database = client.getDatabase("test");
              // create the collections in advance so there is no attempt to implicitly create them within the transaction
              database.createCollection("inventory");
              database.createCollection("shipment");
      
              inventory = database.getCollection("inventory");
              shipment = database.getCollection("shipment");
      
              inventory.deleteMany(new Document());
              shipment.deleteMany(new Document());
      
      

            Assignee:
            Unassigned
            Reporter:
            Alyson Cabral (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: