Server-side JS deadlocks/broken maxTimeMS since 8.3.0-alpha0-1890-g2f3d245

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Gone away
    • Priority: Major - P3
    • None
    • Affects Version/s: 8.3.0-rc0
    • Component/s: None
    • None
    • Query Integration
    • ALL
    • Hide

      test.js:

      const { MongoClient } = require('mongodb');
      
      async function main() {
        const client = await MongoClient.connect(process.env.MONGODB_URI);
        console.log((await client.db('admin').command({ buildInfo: 1 })).version);
        const coll = client.db('test').collection('test');
      
        await coll.insertOne({ name: 'test' });
        await coll.findOne({
          $where: function() { while(true); },
        }, { maxTimeMS: 100, serializeFunctions: true });
        await client.close();
      }
      
      main();
      

      Run the server, then execute node test.js with a recent-ish Node.js version.

      (e.g. in Evergreen, full repro:

      # In one terminal:
      # Download "Binaries" artifact from https://spruce.mongodb.com/task/mongodb_mongo_master_amazon_linux2023_arm64_static_compile_archive_dist_test_2f3d2452dd9de72aa889f727927711df240912b5_25_10_06_20_03_12/files?execution=0
      # by copying the download link, then doing
      $ curl -O '<insert copied URL>'
      $ tar -xvzf mongo-76137.tgz
      $ rm -rf db && mkdir -p db && ./dist-test/bin/mongod --dbpath /tmp/u/db --port 27017
      # In the other terminal:
      $ export PATH=/opt/devtools/bin:$PATH
      $ npm install mongodb
      $ env MONGODB_URI='mongodb://localhost/' node test.js
      

      Note how, in addition to the missing MaxTimeMSExpired error, Ctrl+C on the server process lets it hang for a while instead of exiting immediately.
      )

      Show
      test.js: const { MongoClient } = require( 'mongodb' ); async function main() { const client = await MongoClient.connect(process.env.MONGODB_URI); console.log((await client.db( 'admin' ).command({ buildInfo: 1 })).version); const coll = client.db( 'test' ).collection( 'test' ); await coll.insertOne({ name: 'test' }); await coll.findOne({ $where: function() { while ( true ); }, }, { maxTimeMS: 100, serializeFunctions: true }); await client.close(); } main(); Run the server, then execute node test.js with a recent-ish Node.js version. (e.g. in Evergreen, full repro: # In one terminal: # Download "Binaries" artifact from https: //spruce.mongodb.com/task/mongodb_mongo_master_amazon_linux2023_arm64_static_compile_archive_dist_test_2f3d2452dd9de72aa889f727927711df240912b5_25_10_06_20_03_12/files?execution=0 # by copying the download link, then doing $ curl -O '<insert copied URL>' $ tar -xvzf mongo-76137.tgz $ rm -rf db && mkdir -p db && ./dist-test/bin/mongod --dbpath /tmp/u/db --port 27017 # In the other terminal: $ export PATH=/opt/devtools/bin:$PATH $ npm install mongodb $ env MONGODB_URI= 'mongodb: //localhost/' node test.js Note how, in addition to the missing MaxTimeMSExpired error, Ctrl+C on the server process lets it hang for a while instead of exiting immediately. )
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      mongosh integration tests have been failing for maxTimeMS integration for server-side JS execution for the last two weeks.

      Through bisecting the binaries generated in Evergreen (mongodb-mongo-master, Amazon Linux 2023 arm64 Atlas Compile, archive_dist_test – history), we've narrowed this down to 8.3.0-alpha0-1890-g2f3d245 (SERVER-111617).

      Specifically, when you execute a query with $where using a long-running function and with the maxTimeMS option specified, the operation will no longer abort with an MaxTimeMSExpired error after the given timeout. Additionally, shutting down the server will hang for a while.

            Assignee:
            Gil Alon
            Reporter:
            Anna Henningsen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: