Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-57136

Incompatible wire version error on secondary shutdown in sharded cluster

    • Fully Compatible
    • ALL
    • v5.0, v4.4
    • Hide

      1. Start a sharded cluster, e.g. with mlaunch init --replicaset --sharded 1 --nodes 3 --mongos 1
      2. Kill one of the secondary nodes, e.g. using rs.status() to find a secondary and ps/kill -9 to find the PID and terminate it
      3. Run the provided reproduction script for Node and/or Python

      This should produce the following error from the server on the next find operation:
      Encountered non-retryable error during query :: caused by :: Incompatible wire version

      Node repro script

      'use strict';
      
      const MongoClient = require('mongodb').MongoClient;
      
      const uri = 'mongodb://localhost:27017/?readPreference=secondary&maxStalenessSeconds=90';
      const client = new MongoClient(uri);
      
      async function run() {
        try {
          await client.connect();
          const database = client.db('test');
          const collection = database.collection('bar');
          for (let i = 0; i < 10000; i++) {
            const doc = { a: 42 + i };
            console.log(await collection.insertOne(doc));
            console.log(await collection.findOne(doc));
          }
        } catch (err) {
          console.error(err);
        } finally {
          await client.close();
        }
      }
      run().catch(console.dir);
      

      Python repro script

      from pymongo import MongoClient
      import pprint
      
      client = MongoClient('mongodb://localhost:27017/?readPreference=secondary&maxStalenessSeconds=90')
      db = client.test
      coll = db.collection.bar
      i = 0
      while i < 10000:
        doc = { 'a': 42 + i }
        pprint.pprint(coll.insert_one(doc))
        pprint.pprint(coll.find_one(doc))
        i += 1
      
      Show
      1. Start a sharded cluster, e.g. with mlaunch init --replicaset --sharded 1 --nodes 3 --mongos 1 2. Kill one of the secondary nodes, e.g. using rs.status() to find a secondary and ps / kill -9 to find the PID and terminate it 3. Run the provided reproduction script for Node and/or Python This should produce the following error from the server on the next find operation: Encountered non-retryable error during query :: caused by :: Incompatible wire version Node repro script 'use strict' ; const MongoClient = require( 'mongodb' ).MongoClient; const uri = 'mongodb: //localhost:27017/?readPreference=secondary&maxStalenessSeconds=90' ; const client = new MongoClient(uri); async function run() { try { await client.connect(); const database = client.db( 'test' ); const collection = database.collection( 'bar' ); for (let i = 0; i < 10000; i++) { const doc = { a: 42 + i }; console.log(await collection.insertOne(doc)); console.log(await collection.findOne(doc)); } } catch (err) { console.error(err); } finally { await client.close(); } } run(). catch (console.dir); Python repro script from pymongo import MongoClient import pprint client = MongoClient( 'mongodb://localhost:27017/?readPreference=secondary&maxStalenessSeconds=90' ) db = client.test coll = db.collection.bar i = 0 while i < 10000: doc = { 'a' : 42 + i } pprint.pprint(coll.insert_one(doc)) pprint.pprint(coll.find_one(doc)) i += 1
    • Sharding 2021-06-14

      On a MongoDB v4.4.1+ sharded cluster, when a secondary is taken down, certain operations that should succeed result in an error from the server when the connection string includes readPreference=secondary&maxStalenessSeconds=90.

      The error looks to be a result of SERVER-50170, specifically this new check.

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            eric.adum@mongodb.com Eric Adum (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: