From 8f7eb85de149c996a4e0a284b8a0de1c05340599 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Mon, 16 Dec 2024 14:19:54 -0500 Subject: [PATCH 01/12] parent 70d476aa0be7e60b62c543596f6b2ff6a7c0e8c2 author Aditi Khare 1734376794 -0500 committer Aditi Khare 1737656635 -0500 parent 70d476aa0be7e60b62c543596f6b2ff6a7c0e8c2 author Aditi Khare 1734376794 -0500 committer Aditi Khare 1737656626 -0500 parent 70d476aa0be7e60b62c543596f6b2ff6a7c0e8c2 author Aditi Khare 1734376794 -0500 committer Aditi Khare 1737656617 -0500 parent 70d476aa0be7e60b62c543596f6b2ff6a7c0e8c2 author Aditi Khare 1734376794 -0500 committer Aditi Khare 1737656617 -0500 parent 70d476aa0be7e60b62c543596f6b2ff6a7c0e8c2 author Aditi Khare 1734376794 -0500 committer Aditi Khare 1737656613 -0500 parent 70d476aa0be7e60b62c543596f6b2ff6a7c0e8c2 author Aditi Khare 1734376794 -0500 committer Aditi Khare 1737656583 -0500 parent 70d476aa0be7e60b62c543596f6b2ff6a7c0e8c2 author Aditi Khare 1734376794 -0500 committer Aditi Khare 1737656581 -0500 skeleton skeleton updates refactor for table fix remove misc file clean up Delete logs.txt requested changes: additional expectation remove extra file ready for review server selection test fix --- .../node-specific/client_close.test.ts | 110 +++++++++++++++++- .../resource_tracking_script_builder.ts | 4 +- .../fixtures/close_resource_script.in.js | 34 ++++++ 3 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 test/tools/fixtures/close_resource_script.in.js diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index 0743cd211d..ad9ce4a00c 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -1,8 +1,10 @@ /* eslint-disable @typescript-eslint/no-empty-function */ +import { expect } from 'chai'; + import { type TestConfiguration } from '../../tools/runner/config'; import { runScriptAndGetProcessInfo } from './resource_tracking_script_builder'; -describe.skip('MongoClient.close() Integration', () => { +describe('MongoClient.close() Integration', () => { // note: these tests are set-up in accordance of the resource ownership tree let config: TestConfiguration; @@ -452,29 +454,85 @@ describe.skip('MongoClient.close() Integration', () => { }); describe('ClientSession (Implicit)', () => { + let idleSessionsBeforeClose; + let idleSessionsAfterClose; + + beforeEach(async function () { + const client = this.configuration.newClient(); + await client.connect(); + const session = client.startSession({ explicit: false }); + session.startTransaction(); + await client.db('db').collection('collection').insertOne({ x: 1 }, { session }); + + const opBefore = await client.db().admin().command({ currentOp: 1 }); + idleSessionsBeforeClose = opBefore.inprog.filter(s => s.type === 'idleSession'); + + await client.close(); + await client.connect(); + + const opAfter = await client.db().admin().command({ currentOp: 1 }); + idleSessionsAfterClose = opAfter.inprog.filter(s => s.type === 'idleSession'); + + await client.close(); + }); + describe('Server resource: LSID/ServerSession', () => { describe('after a clientSession is implicitly created and used', () => { - it.skip('the server-side ServerSession is cleaned up by client.close()', async function () {}); + it('the server-side ServerSession is cleaned up by client.close()', async function () { + expect(idleSessionsBeforeClose).to.not.be.empty; + expect(idleSessionsAfterClose).to.be.empty; + }); }); }); describe('Server resource: Transactions', () => { describe('after a clientSession is implicitly created and used', () => { - it.skip('the server-side transaction is cleaned up by client.close()', async function () {}); + it('the server-side transaction is cleaned up by client.close()', async function () { + expect(idleSessionsBeforeClose[0].transaction.txnNumber).to.not.null; + expect(idleSessionsAfterClose).to.be.empty; + }); }); }); }); describe('ClientSession (Explicit)', () => { + let idleSessionsBeforeClose; + let idleSessionsAfterClose; + + beforeEach(async function () { + const client = this.configuration.newClient(); + await client.connect(); + const session = client.startSession(); + session.startTransaction(); + await client.db('db').collection('collection').insertOne({ x: 1 }, { session }); + + const opBefore = await client.db().admin().command({ currentOp: 1 }); + idleSessionsBeforeClose = opBefore.inprog.filter(s => s.type === 'idleSession'); + + await client.close(); + await client.connect(); + + const opAfter = await client.db().admin().command({ currentOp: 1 }); + idleSessionsAfterClose = opAfter.inprog.filter(s => s.type === 'idleSession'); + + await client.close(); + }); + describe('Server resource: LSID/ServerSession', () => { describe('after a clientSession is created and used', () => { - it.skip('the server-side ServerSession is cleaned up by client.close()', async function () {}); + it('the server-side ServerSession is cleaned up by client.close()', async function () { + expect(idleSessionsBeforeClose).to.not.be.empty; + expect(idleSessionsAfterClose).to.be.empty; + }); }); }); describe('Server resource: Transactions', () => { describe('after a clientSession is created and used', () => { - it.skip('the server-side transaction is cleaned up by client.close()', async function () {}); + it('the server-side transaction is cleaned up by client.close()', async function () { + expect(idleSessionsBeforeClose[0].transaction.txnNumber).to.not.null; + expect(idleSessionsAfterClose).to.be.empty; + }); }); }); }); @@ -584,7 +642,47 @@ describe.skip('MongoClient.close() Integration', () => { describe('Server resource: Cursor', () => { describe('after cursors are created', () => { - it.skip('all active server-side cursors are closed by client.close()', async function () {}); + let client; + let coll; + let cursor; + + beforeEach(async function () { + client = this.configuration.newClient(); + coll = client.db('db').collection('coll'); + }); + + afterEach(async function () { + await client?.close(); + await cursor?.close(); + }); + + it('all active server-side cursors are closed by client.close()', async function () { + const getCursors = async () => { + const res = await client + .db() + .admin() + .command({ + aggregate: 1, + cursor: { batchSize: 10 }, + pipeline: [{ $currentOp: { idleCursors: true } }] + }); + return res.cursor.firstBatch.filter( + r => r.type === 'idleCursor' || (r.type === 'op' && r.desc === 'getMore') + ); + }; + + await coll.insertMany([{ a: 1 }, { b: 2 }, { c: 3 }]); + cursor = await coll.find(); + + // assert creation + expect(await getCursors()).to.not.be.empty; + + await client.close(); + await client.connect(); + + // assert clean-up + expect(await getCursors()).to.be.empty; + }); }); }); }); diff --git a/test/integration/node-specific/resource_tracking_script_builder.ts b/test/integration/node-specific/resource_tracking_script_builder.ts index 066fb9fad1..310acc9457 100644 --- a/test/integration/node-specific/resource_tracking_script_builder.ts +++ b/test/integration/node-specific/resource_tracking_script_builder.ts @@ -58,7 +58,9 @@ export async function testScriptFactory( resourceScript = resourceScript.replace('FUNCTION_STRING', `(${func.toString()})`); resourceScript = resourceScript.replace('SCRIPT_NAME_STRING', JSON.stringify(name)); resourceScript = resourceScript.replace('URI_STRING', JSON.stringify(uri)); - resourceScript = resourceScript.replace('ITERATIONS_STRING', `${iterations}`); + if (resourceScriptPath === HEAP_RESOURCE_SCRIPT_PATH) { + resourceScript = resourceScript.replace('ITERATIONS_STRING', `${iterations}`); + } return resourceScript; } diff --git a/test/tools/fixtures/close_resource_script.in.js b/test/tools/fixtures/close_resource_script.in.js new file mode 100644 index 0000000000..84f2ab431a --- /dev/null +++ b/test/tools/fixtures/close_resource_script.in.js @@ -0,0 +1,34 @@ +'use strict'; + +/* eslint-disable no-undef */ + +const driverPath = DRIVER_SOURCE_PATH; +const func = FUNCTION_STRING; +const name = NAME_STRING; +const uri = URI_STRING; +const iterations = ITERATIONS_STRING; + +const { MongoClient } = require(driverPath); +const process = require('node:process'); +const v8 = require('node:v8'); +const util = require('node:util'); +const timers = require('node:timers'); + +const run = func; + +async function main() { + process.on('beforeExit', (code) => { + process.send({beforeExit: true}); + }); + await run({ MongoClient, uri, iteration }); + const report = process.report.getReport(); + process.send({ report }); +} + +main() + .then(() => { + process.exit(0); + }) + .catch(() => { + process.exit(1); + }); From 08d8c261f23ad5c1e9e17743f6da6d71048dc74b Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Thu, 23 Jan 2025 13:26:53 -0500 Subject: [PATCH 02/12] clean up clean up 2 clean up 2 clean up --- .../node-specific/client_close.test.ts | 138 +++++++++++------- .../resource_tracking_script_builder.ts | 4 +- .../fixtures/close_resource_script.in.js | 34 ----- 3 files changed, 88 insertions(+), 88 deletions(-) delete mode 100644 test/tools/fixtures/close_resource_script.in.js diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index ad9ce4a00c..f4594b53ff 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -15,7 +15,7 @@ describe('MongoClient.close() Integration', () => { describe('Node.js resource: TLS File read', () => { describe('when client is connecting and reads an infinite TLS file', () => { - it('the file read is interrupted by client.close()', async function () { + it.skip('the file read is interrupted by client.close()', async function () { await runScriptAndGetProcessInfo( 'tls-file-read', config, @@ -51,7 +51,7 @@ describe('MongoClient.close() Integration', () => { }); describe('when MongoClientAuthProviders is instantiated and token file read hangs', () => { - it('the file read is interrupted by client.close()', async () => { + it.skip('the file read is interrupted by client.close()', async () => { await runScriptAndGetProcessInfo( 'token-file-read', config, @@ -78,8 +78,7 @@ describe('MongoClient.close() Integration', () => { describe('Node.js resource: Server Selection Timer', () => { describe('after a Topology is created through client.connect()', () => { const metadata: MongoDBMetadataUI = { requires: { topology: 'replicaset' } }; - - it('server selection timers are cleaned up by client.close()', metadata, async () => { + it.skip('server selection timers are cleaned up by client.close()', metadata, async () => { const run = async function ({ MongoClient, uri, expect, sleep, mongodb, getTimerCount }) { const serverSelectionTimeoutMS = 2222; const client = new MongoClient(uri, { @@ -118,7 +117,7 @@ describe('MongoClient.close() Integration', () => { describe('MonitorInterval', () => { describe('Node.js resource: Timer', () => { describe('after a new monitor is made', () => { - it( + it.skip( 'monitor interval timer is cleaned up by client.close()', metadata, async function () { @@ -151,7 +150,7 @@ describe('MongoClient.close() Integration', () => { }); describe('after a heartbeat fails', () => { - it( + it.skip( 'the new monitor interval timer is cleaned up by client.close()', metadata, async () => { @@ -161,7 +160,6 @@ describe('MongoClient.close() Integration', () => { const willBeHeartbeatFailed = once(client, 'serverHeartbeatFailed'); client.connect(); await willBeHeartbeatFailed; - function getMonitorTimer(servers) { for (const [, server] of servers) { return server?.monitor.monitorId.timerId; @@ -184,7 +182,7 @@ describe('MongoClient.close() Integration', () => { describe('Monitoring Connection', () => { describe('Node.js resource: Socket', () => { - it('no sockets remain after client.close()', metadata, async function () { + it.skip('no sockets remain after client.close()', metadata, async function () { const run = async function ({ MongoClient, uri, expect, getSocketEndpoints }) { const client = new MongoClient(uri); await client.connect(); @@ -212,7 +210,7 @@ describe('MongoClient.close() Integration', () => { describe('RTT Pinger', () => { describe('Node.js resource: Timer', () => { describe('after entering monitor streaming mode ', () => { - it( + it.skip( 'the rtt pinger timer is cleaned up by client.close()', metadata, async function () { @@ -248,8 +246,8 @@ describe('MongoClient.close() Integration', () => { describe('Connection', () => { describe('Node.js resource: Socket', () => { describe('when rtt monitoring is turned on', () => { - it('no sockets remain after client.close()', metadata, async () => { - const run = async ({ MongoClient, uri, expect, getSockets, once, log }) => { + it.skip('no sockets remain after client.close()', metadata, async () => { + const run = async ({ MongoClient, uri, expect, getSockets, once }) => { const heartbeatFrequencyMS = 500; const client = new MongoClient(uri, { serverMonitoringMode: 'stream', @@ -266,7 +264,6 @@ describe('MongoClient.close() Integration', () => { while (heartbeatOccurredSet.size < servers.size) { const ev = await once(client, 'serverHeartbeatSucceeded'); - log({ ev: ev[0] }); heartbeatOccurredSet.add(ev[0].connectionId); } @@ -282,8 +279,6 @@ describe('MongoClient.close() Integration', () => { // close the client await client.close(); - - log({ socketsAfterClose: getSockets() }); // upon close, assert rttPinger sockets are cleaned up const activeSocketsAfterClose = activeSocketsAfterHeartbeat(); expect(activeSocketsAfterClose).to.have.lengthOf(0); @@ -300,7 +295,7 @@ describe('MongoClient.close() Integration', () => { describe('ConnectionPool', () => { describe('Node.js resource: minPoolSize timer', () => { describe('after new connection pool is created', () => { - it('the minPoolSize timer is cleaned up by client.close()', async function () { + it.skip('the minPoolSize timer is cleaned up by client.close()', async function () { const run = async function ({ MongoClient, uri, expect, getTimerCount }) { const client = new MongoClient(uri, { minPoolSize: 1 }); let minPoolSizeTimerCreated = false; @@ -358,7 +353,7 @@ describe('MongoClient.close() Integration', () => { await utilClient.close(); }); - it('the wait queue timer is cleaned up by client.close()', async function () { + it.skip('the wait queue timer is cleaned up by client.close()', async function () { const run = async function ({ MongoClient, uri, expect, getTimerCount, once }) { const waitQueueTimeoutMS = 1515; @@ -400,7 +395,7 @@ describe('MongoClient.close() Integration', () => { describe('Connection', () => { describe('Node.js resource: Socket', () => { describe('after a minPoolSize has been set on the ConnectionPool', () => { - it('no sockets remain after client.close()', async function () { + it.skip('no sockets remain after client.close()', async function () { const run = async function ({ MongoClient, uri, expect, getSockets }) { // assert no sockets to start with expect(getSockets()).to.have.lengthOf(0); @@ -432,7 +427,7 @@ describe('MongoClient.close() Integration', () => { const metadata: MongoDBMetadataUI = { requires: { topology: 'sharded' } }; describe('after SRVPoller is created', () => { - it('timers are cleaned up by client.close()', metadata, async () => { + it.skip('timers are cleaned up by client.close()', metadata, async () => { const run = async function ({ MongoClient, expect, getTimerCount }) { const SRV_CONNECTION_STRING = `mongodb+srv://test1.test.build.10gen.cc`; // 27018 localhost.test.build.10gen.cc. @@ -456,41 +451,60 @@ describe('MongoClient.close() Integration', () => { describe('ClientSession (Implicit)', () => { let idleSessionsBeforeClose; let idleSessionsAfterClose; + let client; + let utilClient; + let session; + + const metadata: MongoDBMetadataUI = { requires: { topology: ['replicaset', 'sharded'] } }; beforeEach(async function () { - const client = this.configuration.newClient(); + client = this.configuration.newClient(); + utilClient = this.configuration.newClient(); await client.connect(); - const session = client.startSession({ explicit: false }); + session = client.startSession({ explicit: false }); session.startTransaction(); await client.db('db').collection('collection').insertOne({ x: 1 }, { session }); - const opBefore = await client.db().admin().command({ currentOp: 1 }); + const opBefore = await utilClient.db().admin().command({ currentOp: 1 }); idleSessionsBeforeClose = opBefore.inprog.filter(s => s.type === 'idleSession'); await client.close(); - await client.connect(); - const opAfter = await client.db().admin().command({ currentOp: 1 }); + const opAfter = await utilClient.db().admin().command({ currentOp: 1 }); idleSessionsAfterClose = opAfter.inprog.filter(s => s.type === 'idleSession'); - await client.close(); + await utilClient.close(); + }); + + afterEach(async function () { + await utilClient?.close(); + await session?.endSession(); + await client?.close(); }); describe('Server resource: LSID/ServerSession', () => { describe('after a clientSession is implicitly created and used', () => { - it('the server-side ServerSession is cleaned up by client.close()', async function () { - expect(idleSessionsBeforeClose).to.not.be.empty; - expect(idleSessionsAfterClose).to.be.empty; - }); + it( + 'the server-side ServerSession is cleaned up by client.close()', + metadata, + async function () { + expect(idleSessionsBeforeClose).to.not.be.empty; + expect(idleSessionsAfterClose).to.be.empty; + } + ); }); }); describe('Server resource: Transactions', () => { describe('after a clientSession is implicitly created and used', () => { - it('the server-side transaction is cleaned up by client.close()', async function () { - expect(idleSessionsBeforeClose[0].transaction.txnNumber).to.not.null; - expect(idleSessionsAfterClose).to.be.empty; - }); + it( + 'the server-side transaction is cleaned up by client.close()', + metadata, + async function () { + expect(idleSessionsBeforeClose[0].transaction.txnNumber).to.not.null; + expect(idleSessionsAfterClose).to.be.empty; + } + ); }); }); }); @@ -498,41 +512,58 @@ describe('MongoClient.close() Integration', () => { describe('ClientSession (Explicit)', () => { let idleSessionsBeforeClose; let idleSessionsAfterClose; + let client; + let utilClient; + let session; + + const metadata: MongoDBMetadataUI = { requires: { topology: ['replicaset', 'sharded'] } }; beforeEach(async function () { - const client = this.configuration.newClient(); + client = this.configuration.newClient(); + utilClient = this.configuration.newClient(); await client.connect(); - const session = client.startSession(); + session = client.startSession(); session.startTransaction(); await client.db('db').collection('collection').insertOne({ x: 1 }, { session }); - const opBefore = await client.db().admin().command({ currentOp: 1 }); + const opBefore = await utilClient.db().admin().command({ currentOp: 1 }); idleSessionsBeforeClose = opBefore.inprog.filter(s => s.type === 'idleSession'); await client.close(); - await client.connect(); - const opAfter = await client.db().admin().command({ currentOp: 1 }); + const opAfter = await utilClient.db().admin().command({ currentOp: 1 }); idleSessionsAfterClose = opAfter.inprog.filter(s => s.type === 'idleSession'); + }); - await client.close(); + afterEach(async function () { + await utilClient?.close(); + await session?.endSession(); + await client?.close(); }); describe('Server resource: LSID/ServerSession', () => { describe('after a clientSession is created and used', () => { - it('the server-side ServerSession is cleaned up by client.close()', async function () { - expect(idleSessionsBeforeClose).to.not.be.empty; - expect(idleSessionsAfterClose).to.be.empty; - }); + it( + 'the server-side ServerSession is cleaned up by client.close()', + metadata, + async function () { + expect(idleSessionsBeforeClose).to.not.be.empty; + expect(idleSessionsAfterClose).to.be.empty; + } + ); }); }); describe('Server resource: Transactions', () => { describe('after a clientSession is created and used', () => { - it('the server-side transaction is cleaned up by client.close()', async function () { - expect(idleSessionsBeforeClose[0].transaction.txnNumber).to.not.null; - expect(idleSessionsAfterClose).to.be.empty; - }); + it( + 'the server-side transaction is cleaned up by client.close()', + metadata, + async function () { + expect(idleSessionsBeforeClose[0].transaction.txnNumber).to.not.null; + expect(idleSessionsAfterClose).to.be.empty; + } + ); }); }); }); @@ -548,7 +579,7 @@ describe('MongoClient.close() Integration', () => { describe('KMS Request', () => { describe('Node.js resource: TLS file read', () => { describe('when KMSRequest reads an infinite TLS file', () => { - it('the file read is interrupted by client.close()', metadata, async () => { + it.skip('the file read is interrupted by client.close()', metadata, async () => { await runScriptAndGetProcessInfo( 'tls-file-read-auto-encryption', config, @@ -645,20 +676,24 @@ describe('MongoClient.close() Integration', () => { let client; let coll; let cursor; + let utilClient; beforeEach(async function () { client = this.configuration.newClient(); + utilClient = this.configuration.newClient(); + await client.connect(); coll = client.db('db').collection('coll'); }); afterEach(async function () { + await utilClient?.close(); await client?.close(); await cursor?.close(); }); - it('all active server-side cursors are closed by client.close()', async function () { + it.skip('all active server-side cursors are closed by client.close()', async function () { const getCursors = async () => { - const res = await client + const res = await utilClient .db() .admin() .command({ @@ -672,17 +707,18 @@ describe('MongoClient.close() Integration', () => { }; await coll.insertMany([{ a: 1 }, { b: 2 }, { c: 3 }]); + await coll.insertMany([{ d: 4 }, { e: 5 }, { f: 3 }]); cursor = await coll.find(); + await cursor.next(); // assert creation expect(await getCursors()).to.not.be.empty; await client.close(); - await client.connect(); // assert clean-up expect(await getCursors()).to.be.empty; }); }); }); -}); +}); \ No newline at end of file diff --git a/test/integration/node-specific/resource_tracking_script_builder.ts b/test/integration/node-specific/resource_tracking_script_builder.ts index 310acc9457..066fb9fad1 100644 --- a/test/integration/node-specific/resource_tracking_script_builder.ts +++ b/test/integration/node-specific/resource_tracking_script_builder.ts @@ -58,9 +58,7 @@ export async function testScriptFactory( resourceScript = resourceScript.replace('FUNCTION_STRING', `(${func.toString()})`); resourceScript = resourceScript.replace('SCRIPT_NAME_STRING', JSON.stringify(name)); resourceScript = resourceScript.replace('URI_STRING', JSON.stringify(uri)); - if (resourceScriptPath === HEAP_RESOURCE_SCRIPT_PATH) { - resourceScript = resourceScript.replace('ITERATIONS_STRING', `${iterations}`); - } + resourceScript = resourceScript.replace('ITERATIONS_STRING', `${iterations}`); return resourceScript; } diff --git a/test/tools/fixtures/close_resource_script.in.js b/test/tools/fixtures/close_resource_script.in.js deleted file mode 100644 index 84f2ab431a..0000000000 --- a/test/tools/fixtures/close_resource_script.in.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -/* eslint-disable no-undef */ - -const driverPath = DRIVER_SOURCE_PATH; -const func = FUNCTION_STRING; -const name = NAME_STRING; -const uri = URI_STRING; -const iterations = ITERATIONS_STRING; - -const { MongoClient } = require(driverPath); -const process = require('node:process'); -const v8 = require('node:v8'); -const util = require('node:util'); -const timers = require('node:timers'); - -const run = func; - -async function main() { - process.on('beforeExit', (code) => { - process.send({beforeExit: true}); - }); - await run({ MongoClient, uri, iteration }); - const report = process.report.getReport(); - process.send({ report }); -} - -main() - .then(() => { - process.exit(0); - }) - .catch(() => { - process.exit(1); - }); From 24dcee8128572d4086c5689e1d4db43fc14b55c4 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Thu, 23 Jan 2025 13:42:32 -0500 Subject: [PATCH 03/12] lint --- test/integration/node-specific/client_close.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index f4594b53ff..fd9e4075f1 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -721,4 +721,4 @@ describe('MongoClient.close() Integration', () => { }); }); }); -}); \ No newline at end of file +}); From 6a70114320c18c4b195e0f287478c1a88346d5d5 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Thu, 23 Jan 2025 17:33:40 -0500 Subject: [PATCH 04/12] txn test fix txn test fix 2 lint --- .../node-specific/client_close.test.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index fd9e4075f1..3c11ab8c95 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -455,15 +455,21 @@ describe('MongoClient.close() Integration', () => { let utilClient; let session; - const metadata: MongoDBMetadataUI = { requires: { topology: ['replicaset', 'sharded'] } }; + const metadata: MongoDBMetadataUI = { + requires: { + topology: ['replicaset', 'sharded'], + mongodb: '>=5.0' // currentOp requires 5.0 and above + } + }; beforeEach(async function () { client = this.configuration.newClient(); utilClient = this.configuration.newClient(); await client.connect(); + const collection = client.db('db').collection('collection'); session = client.startSession({ explicit: false }); session.startTransaction(); - await client.db('db').collection('collection').insertOne({ x: 1 }, { session }); + await collection.insertOne({ x: 1 }, { session }); const opBefore = await utilClient.db().admin().command({ currentOp: 1 }); idleSessionsBeforeClose = opBefore.inprog.filter(s => s.type === 'idleSession'); @@ -522,9 +528,10 @@ describe('MongoClient.close() Integration', () => { client = this.configuration.newClient(); utilClient = this.configuration.newClient(); await client.connect(); + const collection = client.db('db').collection('collection'); session = client.startSession(); session.startTransaction(); - await client.db('db').collection('collection').insertOne({ x: 1 }, { session }); + await collection.insertOne({ x: 1 }, { session }); const opBefore = await utilClient.db().admin().command({ currentOp: 1 }); idleSessionsBeforeClose = opBefore.inprog.filter(s => s.type === 'idleSession'); @@ -698,7 +705,7 @@ describe('MongoClient.close() Integration', () => { .admin() .command({ aggregate: 1, - cursor: { batchSize: 10 }, + cursor: {}, pipeline: [{ $currentOp: { idleCursors: true } }] }); return res.cursor.firstBatch.filter( From 689706b39a80073702fceff8937f1498c0dce2fe Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Fri, 24 Jan 2025 15:40:25 -0500 Subject: [PATCH 05/12] test fixes --- .../node-specific/client_close.test.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index 3c11ab8c95..3b2ba9e4c6 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -430,10 +430,14 @@ describe('MongoClient.close() Integration', () => { it.skip('timers are cleaned up by client.close()', metadata, async () => { const run = async function ({ MongoClient, expect, getTimerCount }) { const SRV_CONNECTION_STRING = `mongodb+srv://test1.test.build.10gen.cc`; + // 27018 localhost.test.build.10gen.cc. // 27017 localhost.test.build.10gen.cc. - const client = new MongoClient(SRV_CONNECTION_STRING); + const client = new MongoClient(SRV_CONNECTION_STRING, { + serverSelectionTimeoutMS: 2000, + tls: false + }); await client.connect(); // the current expected behavior is that _timeout is set to undefined until SRV polling starts // then _timeout is set to undefined again when SRV polling stops @@ -689,7 +693,7 @@ describe('MongoClient.close() Integration', () => { client = this.configuration.newClient(); utilClient = this.configuration.newClient(); await client.connect(); - coll = client.db('db').collection('coll'); + coll = await client.db('db').createCollection('coll', { capped: true, size: 1_000_000 }); }); afterEach(async function () { @@ -714,8 +718,13 @@ describe('MongoClient.close() Integration', () => { }; await coll.insertMany([{ a: 1 }, { b: 2 }, { c: 3 }]); - await coll.insertMany([{ d: 4 }, { e: 5 }, { f: 3 }]); - cursor = await coll.find(); + cursor = await coll.find( + {}, + { + tailable: true, + awaitData: true + } + ); await cursor.next(); // assert creation From 6629343395907ef1fc22f4e5241c8eb8f8920606 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Tue, 28 Jan 2025 11:26:23 -0500 Subject: [PATCH 06/12] await collection creation - fix txn test --- test/integration/node-specific/client_close.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index 3b2ba9e4c6..d810023eac 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -470,10 +470,14 @@ describe('MongoClient.close() Integration', () => { client = this.configuration.newClient(); utilClient = this.configuration.newClient(); await client.connect(); - const collection = client.db('db').collection('collection'); + const collection = await client.db('db').createCollection('collection'); + console.log('createCollection done'); session = client.startSession({ explicit: false }); + console.log('startSession done'); session.startTransaction(); + console.log('startTransaction done'); await collection.insertOne({ x: 1 }, { session }); + console.log('insert done'); const opBefore = await utilClient.db().admin().command({ currentOp: 1 }); idleSessionsBeforeClose = opBefore.inprog.filter(s => s.type === 'idleSession'); @@ -532,7 +536,7 @@ describe('MongoClient.close() Integration', () => { client = this.configuration.newClient(); utilClient = this.configuration.newClient(); await client.connect(); - const collection = client.db('db').collection('collection'); + const collection = await client.db('db').createCollection('collection'); session = client.startSession(); session.startTransaction(); await collection.insertOne({ x: 1 }, { session }); From 729c269c5e4f24f9ff187a444fbfe9d3c95c6afe Mon Sep 17 00:00:00 2001 From: Warren James Date: Tue, 28 Jan 2025 12:35:16 -0500 Subject: [PATCH 07/12] test(NODE-4955): sync unacknowledged write spec tests (#4380) --- .../logging/command.json | 2 ++ .../logging/command.yml | 5 ++-- .../monitoring/find.json | 26 ++++++++++++------- .../monitoring/find.yml | 10 ++++++- .../monitoring/unacknowledgedBulkWrite.json | 12 +-------- .../monitoring/unacknowledgedBulkWrite.yml | 4 --- .../monitoring/writeConcernError.json | 20 +++++++------- .../monitoring/writeConcernError.yml | 9 ++++--- 8 files changed, 47 insertions(+), 41 deletions(-) diff --git a/test/spec/command-logging-and-monitoring/logging/command.json b/test/spec/command-logging-and-monitoring/logging/command.json index 3d5c2570be..d2970df692 100644 --- a/test/spec/command-logging-and-monitoring/logging/command.json +++ b/test/spec/command-logging-and-monitoring/logging/command.json @@ -93,6 +93,7 @@ "component": "command", "data": { "message": "Command succeeded", + "databaseName": "logging-tests", "commandName": "ping", "reply": { "$$type": "string" @@ -177,6 +178,7 @@ "component": "command", "data": { "message": "Command failed", + "databaseName": "logging-tests", "commandName": "find", "failure": { "$$exists": true diff --git a/test/spec/command-logging-and-monitoring/logging/command.yml b/test/spec/command-logging-and-monitoring/logging/command.yml index b21a4c6090..3e3410b06d 100644 --- a/test/spec/command-logging-and-monitoring/logging/command.yml +++ b/test/spec/command-logging-and-monitoring/logging/command.yml @@ -52,13 +52,14 @@ tests: component: command data: message: "Command succeeded" + databaseName: *databaseName commandName: *commandName reply: { $$type: string } requestId: { $$type: [int, long] } serverHost: { $$type: string } serverPort: { $$type: [int, long] } durationMS: { $$type: [double, int, long] } - + - description: "A failed command" operations: - name: &commandName find @@ -85,10 +86,10 @@ tests: component: command data: message: "Command failed" + databaseName: *databaseName commandName: *commandName failure: { $$exists: true } requestId: { $$type: [int, long] } serverHost: { $$type: string } serverPort: { $$type: [int, long] } durationMS: { $$type: [double, int, long] } - diff --git a/test/spec/command-logging-and-monitoring/monitoring/find.json b/test/spec/command-logging-and-monitoring/monitoring/find.json index 4b5f45ae99..bc9668499b 100644 --- a/test/spec/command-logging-and-monitoring/monitoring/find.json +++ b/test/spec/command-logging-and-monitoring/monitoring/find.json @@ -1,6 +1,6 @@ { "description": "find", - "schemaVersion": "1.1", + "schemaVersion": "1.15", "createEntities": [ { "client": { @@ -103,7 +103,8 @@ ] } }, - "commandName": "find" + "commandName": "find", + "databaseName": "command-monitoring-tests" } } ] @@ -198,7 +199,8 @@ ] } }, - "commandName": "find" + "commandName": "find", + "databaseName": "command-monitoring-tests" } } ] @@ -262,7 +264,8 @@ ] } }, - "commandName": "find" + "commandName": "find", + "databaseName": "command-monitoring-tests" } } ] @@ -338,7 +341,8 @@ ] } }, - "commandName": "find" + "commandName": "find", + "databaseName": "command-monitoring-tests" } }, { @@ -376,7 +380,8 @@ ] } }, - "commandName": "getMore" + "commandName": "getMore", + "databaseName": "command-monitoring-tests" } } ] @@ -464,7 +469,8 @@ ] } }, - "commandName": "find" + "commandName": "find", + "databaseName": "command-monitoring-tests" } }, { @@ -498,7 +504,8 @@ ] } }, - "commandName": "getMore" + "commandName": "getMore", + "databaseName": "command-monitoring-tests" } } ] @@ -539,7 +546,8 @@ }, { "commandFailedEvent": { - "commandName": "find" + "commandName": "find", + "databaseName": "command-monitoring-tests" } } ] diff --git a/test/spec/command-logging-and-monitoring/monitoring/find.yml b/test/spec/command-logging-and-monitoring/monitoring/find.yml index e2bb3f8c92..479e4a460c 100644 --- a/test/spec/command-logging-and-monitoring/monitoring/find.yml +++ b/test/spec/command-logging-and-monitoring/monitoring/find.yml @@ -1,6 +1,6 @@ description: "find" -schemaVersion: "1.1" +schemaVersion: "1.15" createEntities: - client: @@ -56,6 +56,7 @@ tests: firstBatch: - { _id: 1, x: 11 } commandName: find + databaseName: *databaseName - description: "A successful find with options" operations: @@ -98,6 +99,7 @@ tests: - { x: 33 } - { x: 22 } commandName: find + databaseName: *databaseName - description: "A successful find with showRecordId and returnKey" operations: @@ -131,6 +133,7 @@ tests: - { _id: 4 } - { _id: 5 } commandName: find + databaseName: *databaseName - description: "A successful find with a getMore" operations: @@ -162,6 +165,7 @@ tests: - { _id: 2, x: 22 } - { _id: 3, x: 33 } commandName: find + databaseName: *databaseName - commandStartedEvent: command: getMore: { $$type: [ int, long ] } @@ -179,6 +183,7 @@ tests: - { _id: 4, x: 44 } - { _id: 5, x: 55 } commandName: getMore + databaseName: *databaseName - description: "A successful find event with a getmore and the server kills the cursor (<= 4.4)" runOnRequirements: @@ -216,6 +221,7 @@ tests: - { _id: 2, x: 22 } - { _id: 3, x: 33 } commandName: find + databaseName: *databaseName - commandStartedEvent: command: getMore: { $$type: [ int, long ] } @@ -232,6 +238,7 @@ tests: nextBatch: - { _id: 4, x: 44 } commandName: getMore + databaseName: *databaseName - description: "A failed find event" operations: @@ -252,3 +259,4 @@ tests: databaseName: *databaseName - commandFailedEvent: commandName: find + databaseName: *databaseName diff --git a/test/spec/command-logging-and-monitoring/monitoring/unacknowledgedBulkWrite.json b/test/spec/command-logging-and-monitoring/monitoring/unacknowledgedBulkWrite.json index ed6ceafa5f..78ddde767f 100644 --- a/test/spec/command-logging-and-monitoring/monitoring/unacknowledgedBulkWrite.json +++ b/test/spec/command-logging-and-monitoring/monitoring/unacknowledgedBulkWrite.json @@ -71,17 +71,7 @@ "object": "collection", "arguments": { "filter": {} - }, - "expectResult": [ - { - "_id": 1, - "x": 11 - }, - { - "_id": "unorderedBulkWriteInsertW0", - "x": 44 - } - ] + } } ], "expectEvents": [ diff --git a/test/spec/command-logging-and-monitoring/monitoring/unacknowledgedBulkWrite.yml b/test/spec/command-logging-and-monitoring/monitoring/unacknowledgedBulkWrite.yml index 4cf3396a7f..c526fab325 100644 --- a/test/spec/command-logging-and-monitoring/monitoring/unacknowledgedBulkWrite.yml +++ b/test/spec/command-logging-and-monitoring/monitoring/unacknowledgedBulkWrite.yml @@ -42,10 +42,6 @@ tests: object: *collection arguments: filter: { } - expectResult: [ - { _id: 1, x: 11 }, - { _id: "unorderedBulkWriteInsertW0", x: 44 } - ] expectEvents: - client: *client ignoreExtraEvents: true diff --git a/test/spec/command-logging-and-monitoring/monitoring/writeConcernError.json b/test/spec/command-logging-and-monitoring/monitoring/writeConcernError.json index cc97450687..455e5422b7 100644 --- a/test/spec/command-logging-and-monitoring/monitoring/writeConcernError.json +++ b/test/spec/command-logging-and-monitoring/monitoring/writeConcernError.json @@ -1,9 +1,9 @@ { "description": "writeConcernError", - "schemaVersion": "1.13", + "schemaVersion": "1.4", "runOnRequirements": [ { - "minServerVersion": "4.1.0", + "minServerVersion": "4.3.1", "topologies": [ "replicaset" ], @@ -66,11 +66,11 @@ "failCommands": [ "insert" ], + "errorLabels": [ + "RetryableWriteError" + ], "writeConcernError": { - "code": 91, - "errorLabels": [ - "RetryableWriteError" - ] + "code": 91 } } } @@ -112,11 +112,11 @@ "reply": { "ok": 1, "n": 1, + "errorLabels": [ + "RetryableWriteError" + ], "writeConcernError": { - "code": 91, - "errorLabels": [ - "RetryableWriteError" - ] + "code": 91 } }, "commandName": "insert" diff --git a/test/spec/command-logging-and-monitoring/monitoring/writeConcernError.yml b/test/spec/command-logging-and-monitoring/monitoring/writeConcernError.yml index fbaa4a330d..b63db8eef7 100644 --- a/test/spec/command-logging-and-monitoring/monitoring/writeConcernError.yml +++ b/test/spec/command-logging-and-monitoring/monitoring/writeConcernError.yml @@ -1,8 +1,8 @@ description: "writeConcernError" -schemaVersion: "1.13" +schemaVersion: "1.4" runOnRequirements: - - minServerVersion: 4.1.0 + minServerVersion: "4.3.1" # failCommand errorLabels option topologies: - replicaset serverless: "forbid" @@ -41,9 +41,9 @@ tests: mode: { times: 1 } data: failCommands: [ insert ] + errorLabels: [ RetryableWriteError ] writeConcernError: code: 91 # ShutdownInProgress - errorLabels: [RetryableWriteError] - name: insertOne object: *collection arguments: @@ -63,7 +63,8 @@ tests: reply: ok: 1 n: 1 - writeConcernError: { code: 91, errorLabels: [ "RetryableWriteError" ] } + errorLabels: [ "RetryableWriteError" ] + writeConcernError: { code: 91 } commandName: insert - commandStartedEvent: command: From f2f8dce73b8ca1ea2ab3e17f871044016c04b09f Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Wed, 29 Jan 2025 15:44:46 -0500 Subject: [PATCH 08/12] failing test fixed --- .../node-specific/client_close.test.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index d810023eac..677bd7f112 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -461,8 +461,7 @@ describe('MongoClient.close() Integration', () => { const metadata: MongoDBMetadataUI = { requires: { - topology: ['replicaset', 'sharded'], - mongodb: '>=5.0' // currentOp requires 5.0 and above + topology: ['replicaset', 'sharded'] } }; @@ -470,14 +469,15 @@ describe('MongoClient.close() Integration', () => { client = this.configuration.newClient(); utilClient = this.configuration.newClient(); await client.connect(); + await client + .db('db') + .collection('collection') + ?.drop() + .catch(() => null); const collection = await client.db('db').createCollection('collection'); - console.log('createCollection done'); session = client.startSession({ explicit: false }); - console.log('startSession done'); session.startTransaction(); - console.log('startTransaction done'); await collection.insertOne({ x: 1 }, { session }); - console.log('insert done'); const opBefore = await utilClient.db().admin().command({ currentOp: 1 }); idleSessionsBeforeClose = opBefore.inprog.filter(s => s.type === 'idleSession'); @@ -530,12 +530,21 @@ describe('MongoClient.close() Integration', () => { let utilClient; let session; - const metadata: MongoDBMetadataUI = { requires: { topology: ['replicaset', 'sharded'] } }; + const metadata: MongoDBMetadataUI = { + requires: { + topology: ['replicaset', 'sharded'] + } + }; beforeEach(async function () { client = this.configuration.newClient(); utilClient = this.configuration.newClient(); await client.connect(); + await client + .db('db') + .collection('collection') + ?.drop() + .catch(() => null); const collection = await client.db('db').createCollection('collection'); session = client.startSession(); session.startTransaction(); @@ -697,7 +706,7 @@ describe('MongoClient.close() Integration', () => { client = this.configuration.newClient(); utilClient = this.configuration.newClient(); await client.connect(); - coll = await client.db('db').createCollection('coll', { capped: true, size: 1_000_000 }); + coll = await client.db('db').collection('coll', { capped: true, size: 1_000_000 }); }); afterEach(async function () { From 35435db1232f30b5561b19bb726d4563d9b365e8 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Wed, 29 Jan 2025 16:33:17 -0500 Subject: [PATCH 09/12] currentOp requires >=4.2 --- test/integration/node-specific/client_close.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index 677bd7f112..c52c8bf41c 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -461,7 +461,8 @@ describe('MongoClient.close() Integration', () => { const metadata: MongoDBMetadataUI = { requires: { - topology: ['replicaset', 'sharded'] + topology: ['replicaset', 'sharded'], + mongodb: '>=4.2' } }; @@ -532,7 +533,8 @@ describe('MongoClient.close() Integration', () => { const metadata: MongoDBMetadataUI = { requires: { - topology: ['replicaset', 'sharded'] + topology: ['replicaset', 'sharded'], + mongodb: '>=4.2' } }; From 3c98214c8ea17be28a5166741884d03e59cb30de Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Thu, 30 Jan 2025 11:07:51 -0500 Subject: [PATCH 10/12] requested changes --- .../node-specific/client_close.test.ts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index c52c8bf41c..4f0e15edb6 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-function */ import { expect } from 'chai'; +import { type Collection, type FindCursor, type MongoClient } from '../../mongodb'; import { type TestConfiguration } from '../../tools/runner/config'; import { runScriptAndGetProcessInfo } from './resource_tracking_script_builder'; @@ -699,16 +700,24 @@ describe('MongoClient.close() Integration', () => { describe('Server resource: Cursor', () => { describe('after cursors are created', () => { - let client; - let coll; - let cursor; - let utilClient; + let client: MongoClient; + let coll: Collection; + let cursor: FindCursor; + let utilClient: MongoClient; beforeEach(async function () { client = this.configuration.newClient(); utilClient = this.configuration.newClient(); await client.connect(); - coll = await client.db('db').collection('coll', { capped: true, size: 1_000_000 }); + await client + .db('db') + .collection('coll') + ?.drop() + .catch(() => null); + coll = await client + .db('db') + .createCollection('coll', { capped: true, size: 1_000, max: 4 }); + await coll.insertMany([{ a: 1 }, { b: 2 }, { c: 3 }]); }); afterEach(async function () { @@ -717,7 +726,7 @@ describe('MongoClient.close() Integration', () => { await cursor?.close(); }); - it.skip('all active server-side cursors are closed by client.close()', async function () { + it('all active server-side cursors are closed by client.close()', async function () { const getCursors = async () => { const res = await utilClient .db() @@ -732,8 +741,7 @@ describe('MongoClient.close() Integration', () => { ); }; - await coll.insertMany([{ a: 1 }, { b: 2 }, { c: 3 }]); - cursor = await coll.find( + cursor = coll.find( {}, { tailable: true, From f53ecc6fed61f5330592b8da7aad69d791d948ae Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Thu, 30 Jan 2025 11:31:01 -0500 Subject: [PATCH 11/12] $currentOp idleCursors needs >= 4.2 --- .../node-specific/client_close.test.ts | 66 +++++++++++-------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index 4f0e15edb6..b5fcc17aec 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -699,6 +699,12 @@ describe('MongoClient.close() Integration', () => { }); describe('Server resource: Cursor', () => { + const metadata: MongoDBMetadataUI = { + requires: { + mongodb: '>=4.2.0' + } + }; + describe('after cursors are created', () => { let client: MongoClient; let coll: Collection; @@ -726,38 +732,42 @@ describe('MongoClient.close() Integration', () => { await cursor?.close(); }); - it('all active server-side cursors are closed by client.close()', async function () { - const getCursors = async () => { - const res = await utilClient - .db() - .admin() - .command({ - aggregate: 1, - cursor: {}, - pipeline: [{ $currentOp: { idleCursors: true } }] - }); - return res.cursor.firstBatch.filter( - r => r.type === 'idleCursor' || (r.type === 'op' && r.desc === 'getMore') - ); - }; + it( + 'all active server-side cursors are closed by client.close()', + metadata, + async function () { + const getCursors = async () => { + const res = await utilClient + .db() + .admin() + .command({ + aggregate: 1, + cursor: {}, + pipeline: [{ $currentOp: { idleCursors: true } }] + }); + return res.cursor.firstBatch.filter( + r => r.type === 'idleCursor' || (r.type === 'op' && r.desc === 'getMore') + ); + }; - cursor = coll.find( - {}, - { - tailable: true, - awaitData: true - } - ); - await cursor.next(); + cursor = coll.find( + {}, + { + tailable: true, + awaitData: true + } + ); + await cursor.next(); - // assert creation - expect(await getCursors()).to.not.be.empty; + // assert creation + expect(await getCursors()).to.not.be.empty; - await client.close(); + await client.close(); - // assert clean-up - expect(await getCursors()).to.be.empty; - }); + // assert clean-up + expect(await getCursors()).to.be.empty; + } + ); }); }); }); From 1d3fd919547571899b3dccc2f6faefe8cff77f21 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Fri, 31 Jan 2025 12:40:21 -0500 Subject: [PATCH 12/12] bug fixed bug fixed --- src/cursor/abstract_cursor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cursor/abstract_cursor.ts b/src/cursor/abstract_cursor.ts index 1758e80c24..42f3b1188a 100644 --- a/src/cursor/abstract_cursor.ts +++ b/src/cursor/abstract_cursor.ts @@ -1039,9 +1039,7 @@ export abstract class AbstractCursor< this.selectedServer && !this.cursorSession.hasEnded ) { - this.isKilled = true; const cursorId = this.cursorId; - this.cursorId = Long.ZERO; await executeOperation( this.cursorClient, @@ -1061,6 +1059,8 @@ export abstract class AbstractCursor< if (!this.cursorSession?.inTransaction()) { maybeClearPinnedConnection(this.cursorSession, { error }); } + this.cursorId = Long.ZERO; + this.isKilled = true; } finally { this.emitClose(); }