Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3136

"Incompatible wire version" error with MongoDB 4.4 secondary reads when a secondary goes down

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.4
    • Component/s: None
    • None
    • Not Needed

      Environment (required to reproduce the issue)

      • Node.js driver 3.6.4
      • MongoDB 4.4 sharded cluster
      • URI includes "maxStalenessSeconds=90" and "readPreference=secondary"
      • application is running queries via mongos that end up on a shard X
      • shard X is a 3-member replica set, and one of the members goes down

      If any of these conditions is not met, the error does not happen. In particular, the maxStalenessSeconds option must be present, and the MongoDB version must be 4.4, and a secondary must be down.

      If the conditions are met, the following error occurs on the client side:

      MongoError: Encountered non-retryable error during query :: caused by :: Incompatible wire version
      

      The following sample program demonstrates the issue, when run against a MongoDB 4.4 sharded cluster, connected to the mongos. Start the program, and while it's running, take down one of the secondaries of the primary shard for the "test" database. The error should be seen immediately. As the shard still has a primary and a secondary, it should be able to handle secondary queries.

      const { MongoClient } = require("mongodb");
      
      const uri = "mongodb://admin:tester@repro/?retryWrites=true&w=majority&readPreference=secondary&maxStalenessSeconds=90";
      const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });
      
      async function run() {
          try {
              await client.connect();
              const database = client.db('test');
              const collection = database.collection('bar');
              for (i=0; i<10000; i++) {
                  const doc = {a: 42+i};
                  await collection.insertOne(doc);
                  const doc2 = await collection.findOne(doc);
                  console.log(doc2);
              }
          } catch(err) {
              console.error(`something went wrong: ${err}`);
          } finally {
              await client.close();
          }
      }
      run().catch(console.dir);
      

            Assignee:
            eric.adum@mongodb.com Eric Adum (Inactive)
            Reporter:
            spencer.brown@mongodb.com Spencer Brown
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: