Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-1351

executeBulkWrite() does not use bulk OP_INSERT when w=0

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.7.0
    • Affects Version/s: None
    • Component/s: None
    • None

      The decision to allow bulk OP_INSERT operations is determined when mongoc_bulk_operation_insert_with_opts() calls _mongoc_write_command_init_insert() to initialize a new insert command. The last argument (allow_bulk_op_insert) is determined by the acknowledgement, or lack thereof, of the mongoc_bulk_operation_t's current write concern.

      Since PHPC constructs a mongoc_bulk_operation_t via mongoc_bulk_operation_new(), many fields are left initialized (e.g. database/collection name, write concern). These values are not set on the bulk write until it is executed with executeBulkWrite(). Therefore, insert commands will never permit bulk OP_INSERTs. The mongoc_bulk_operation_t definition is not public to PHPC so we cannot retroactively change the allow_bulk_op_insert at execution time (short of libmongoc adding some new public API to allow us to do so).

      That said, there may be an alternative solution. Since libmongoc dropped support for MongoDB 2.6 in CDRIVER-2510, legacy opcodes should no longer be used for anything except unacknowledged writes in server versions prior to 3.6. With server versions 3.6+, libmongoc 1.10+ will route unacknowledged writes through OP_MSG (CDRIVER-2366). Given this, it may be safe for _mongoc_write_command_insert_legacy() to always enable allow_bulk_op_insert.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: