mongodb 7.0.0-dev.20251202.sha.d4e44388 → 7.0.0-dev.20251204.sha.ae2e037e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cmap/connection.js +3 -3
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +2 -2
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/connection_pool_events.js +3 -3
- package/lib/cmap/connection_pool_events.js.map +1 -1
- package/lib/db.js +0 -1
- package/lib/db.js.map +1 -1
- package/lib/operations/rename.js.map +1 -1
- package/lib/sdam/monitor.js +7 -7
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server_description.js +1 -1
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/topology.js +3 -2
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sessions.js +8 -6
- package/lib/sessions.js.map +1 -1
- package/lib/utils.js +9 -6
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +6 -1
- package/package.json +1 -1
- package/src/cmap/connection.ts +4 -4
- package/src/cmap/connection_pool.ts +3 -3
- package/src/cmap/connection_pool_events.ts +4 -4
- package/src/db.ts +0 -1
- package/src/operations/rename.ts +6 -1
- package/src/sdam/monitor.ts +9 -9
- package/src/sdam/server_description.ts +8 -2
- package/src/sdam/topology.ts +4 -3
- package/src/sessions.ts +9 -7
- package/src/utils.ts +8 -5
package/src/sdam/monitor.ts
CHANGED
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
type EventEmitterWithState,
|
|
15
15
|
makeStateMachine,
|
|
16
16
|
noop,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
ns,
|
|
18
|
+
processTimeMS
|
|
19
19
|
} from '../utils';
|
|
20
20
|
import { ServerType, STATE_CLOSED, STATE_CLOSING } from './common';
|
|
21
21
|
import {
|
|
@@ -326,7 +326,7 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
|
|
|
326
326
|
);
|
|
327
327
|
// We have not actually sent an outgoing handshake, but when we get the next response we
|
|
328
328
|
// want the duration to reflect the time since we last heard from the server
|
|
329
|
-
start =
|
|
329
|
+
start = processTimeMS();
|
|
330
330
|
} else {
|
|
331
331
|
monitor.rttPinger?.close();
|
|
332
332
|
monitor.rttPinger = undefined;
|
|
@@ -360,7 +360,7 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
|
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
// Record new start time before sending handshake
|
|
363
|
-
start =
|
|
363
|
+
start = processTimeMS();
|
|
364
364
|
|
|
365
365
|
if (isAwaitable) {
|
|
366
366
|
awaited = true;
|
|
@@ -383,7 +383,7 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
|
|
|
383
383
|
const socket = await makeSocket(monitor.connectOptions);
|
|
384
384
|
const connection = makeConnection(monitor.connectOptions, socket);
|
|
385
385
|
// The start time is after socket creation but before the handshake
|
|
386
|
-
start =
|
|
386
|
+
start = processTimeMS();
|
|
387
387
|
try {
|
|
388
388
|
await performInitialHandshake(connection, monitor.connectOptions);
|
|
389
389
|
return connection;
|
|
@@ -532,7 +532,7 @@ export class RTTPinger {
|
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
private measureRoundTripTime() {
|
|
535
|
-
const start =
|
|
535
|
+
const start = processTimeMS();
|
|
536
536
|
|
|
537
537
|
if (this.closed) {
|
|
538
538
|
return;
|
|
@@ -607,7 +607,7 @@ export class MonitorInterval {
|
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
wake() {
|
|
610
|
-
const currentTime =
|
|
610
|
+
const currentTime = processTimeMS();
|
|
611
611
|
const timeSinceLastCall = currentTime - this.lastExecutionEnded;
|
|
612
612
|
|
|
613
613
|
// TODO(NODE-4674): Add error handling and logging to the monitor
|
|
@@ -651,7 +651,7 @@ export class MonitorInterval {
|
|
|
651
651
|
}
|
|
652
652
|
|
|
653
653
|
toJSON() {
|
|
654
|
-
const currentTime =
|
|
654
|
+
const currentTime = processTimeMS();
|
|
655
655
|
const timeSinceLastCall = currentTime - this.lastExecutionEnded;
|
|
656
656
|
return {
|
|
657
657
|
timerId: this.timerId != null ? 'set' : 'cleared',
|
|
@@ -684,7 +684,7 @@ export class MonitorInterval {
|
|
|
684
684
|
this.isExecutionInProgress = true;
|
|
685
685
|
|
|
686
686
|
this.fn(() => {
|
|
687
|
-
this.lastExecutionEnded =
|
|
687
|
+
this.lastExecutionEnded = processTimeMS();
|
|
688
688
|
this.isExecutionInProgress = false;
|
|
689
689
|
this._reschedule(this.heartbeatFrequencyMS);
|
|
690
690
|
});
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type Document, Long, type ObjectId } from '../bson';
|
|
2
2
|
import { type MongoError, MongoRuntimeError } from '../error';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
arrayStrictEqual,
|
|
5
|
+
compareObjectId,
|
|
6
|
+
errorStrictEqual,
|
|
7
|
+
HostAddress,
|
|
8
|
+
processTimeMS
|
|
9
|
+
} from '../utils';
|
|
4
10
|
import { type ClusterTime, ServerType } from './common';
|
|
5
11
|
|
|
6
12
|
const WRITABLE_SERVER_TYPES = new Set<ServerType>([
|
|
@@ -110,7 +116,7 @@ export class ServerDescription {
|
|
|
110
116
|
this.maxWireVersion = hello?.maxWireVersion ?? 0;
|
|
111
117
|
this.roundTripTime = options?.roundTripTime ?? -1;
|
|
112
118
|
this.minRoundTripTime = options?.minRoundTripTime ?? 0;
|
|
113
|
-
this.lastUpdateTime =
|
|
119
|
+
this.lastUpdateTime = processTimeMS();
|
|
114
120
|
this.lastWriteDate = hello?.lastWrite?.lastWriteDate ?? 0;
|
|
115
121
|
// NOTE: This actually builds the stack string instead of holding onto the getter and all its
|
|
116
122
|
// associated references. This is done to prevent a memory leak.
|
package/src/sdam/topology.ts
CHANGED
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
List,
|
|
46
46
|
makeStateMachine,
|
|
47
47
|
noop,
|
|
48
|
-
|
|
48
|
+
processTimeMS,
|
|
49
49
|
promiseWithResolvers,
|
|
50
50
|
shuffle
|
|
51
51
|
} from '../utils';
|
|
@@ -602,7 +602,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
|
|
|
602
602
|
resolve,
|
|
603
603
|
reject,
|
|
604
604
|
cancelled: false,
|
|
605
|
-
startTime:
|
|
605
|
+
startTime: processTimeMS(),
|
|
606
606
|
operationName: options.operationName,
|
|
607
607
|
waitingLogged: false,
|
|
608
608
|
previousServer: options.previousServer
|
|
@@ -1001,7 +1001,8 @@ function processWaitQueue(topology: Topology) {
|
|
|
1001
1001
|
waitQueueMember.serverSelector,
|
|
1002
1002
|
topology.description,
|
|
1003
1003
|
topology.s.serverSelectionTimeoutMS !== 0
|
|
1004
|
-
? topology.s.serverSelectionTimeoutMS -
|
|
1004
|
+
? topology.s.serverSelectionTimeoutMS -
|
|
1005
|
+
(processTimeMS() - waitQueueMember.startTime)
|
|
1005
1006
|
: -1,
|
|
1006
1007
|
waitQueueMember.operationName
|
|
1007
1008
|
)
|
package/src/sessions.ts
CHANGED
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
List,
|
|
43
43
|
MongoDBNamespace,
|
|
44
44
|
noop,
|
|
45
|
-
|
|
45
|
+
processTimeMS,
|
|
46
46
|
squashError,
|
|
47
47
|
uuidV4
|
|
48
48
|
} from './utils';
|
|
@@ -726,7 +726,9 @@ export class ClientSession
|
|
|
726
726
|
})
|
|
727
727
|
: null;
|
|
728
728
|
|
|
729
|
-
const startTime = this.timeoutContext?.csotEnabled()
|
|
729
|
+
const startTime = this.timeoutContext?.csotEnabled()
|
|
730
|
+
? this.timeoutContext.start
|
|
731
|
+
: processTimeMS();
|
|
730
732
|
|
|
731
733
|
let committed = false;
|
|
732
734
|
let result: any;
|
|
@@ -768,7 +770,7 @@ export class ClientSession
|
|
|
768
770
|
|
|
769
771
|
if (
|
|
770
772
|
fnError.hasErrorLabel(MongoErrorLabel.TransientTransactionError) &&
|
|
771
|
-
(this.timeoutContext != null ||
|
|
773
|
+
(this.timeoutContext != null || processTimeMS() - startTime < MAX_TIMEOUT)
|
|
772
774
|
) {
|
|
773
775
|
continue;
|
|
774
776
|
}
|
|
@@ -796,14 +798,14 @@ export class ClientSession
|
|
|
796
798
|
if (
|
|
797
799
|
!isMaxTimeMSExpiredError(commitError) &&
|
|
798
800
|
commitError.hasErrorLabel(MongoErrorLabel.UnknownTransactionCommitResult) &&
|
|
799
|
-
(this.timeoutContext != null ||
|
|
801
|
+
(this.timeoutContext != null || processTimeMS() - startTime < MAX_TIMEOUT)
|
|
800
802
|
) {
|
|
801
803
|
continue;
|
|
802
804
|
}
|
|
803
805
|
|
|
804
806
|
if (
|
|
805
807
|
commitError.hasErrorLabel(MongoErrorLabel.TransientTransactionError) &&
|
|
806
|
-
(this.timeoutContext != null ||
|
|
808
|
+
(this.timeoutContext != null || processTimeMS() - startTime < MAX_TIMEOUT)
|
|
807
809
|
) {
|
|
808
810
|
break;
|
|
809
811
|
}
|
|
@@ -943,7 +945,7 @@ export class ServerSession {
|
|
|
943
945
|
return;
|
|
944
946
|
}
|
|
945
947
|
this.id = { id: new Binary(uuidV4(), Binary.SUBTYPE_UUID) };
|
|
946
|
-
this.lastUse =
|
|
948
|
+
this.lastUse = processTimeMS();
|
|
947
949
|
this.txnNumber = 0;
|
|
948
950
|
this.isDirty = false;
|
|
949
951
|
}
|
|
@@ -1078,7 +1080,7 @@ export function applySession(
|
|
|
1078
1080
|
}
|
|
1079
1081
|
|
|
1080
1082
|
// mark the last use of this session, and apply the `lsid`
|
|
1081
|
-
serverSession.lastUse =
|
|
1083
|
+
serverSession.lastUse = processTimeMS();
|
|
1082
1084
|
command.lsid = serverSession.id;
|
|
1083
1085
|
|
|
1084
1086
|
const inTxnOrTxnCommand = session.inTransaction() || isTransactionCommand(command);
|
package/src/utils.ts
CHANGED
|
@@ -434,10 +434,13 @@ export function makeStateMachine(stateTable: StateTable): StateTransitionFunctio
|
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
-
/**
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
437
|
+
/**
|
|
438
|
+
* This function returns the number of milliseconds since an arbitrary point in time.
|
|
439
|
+
* This function should only be used to measure time intervals.
|
|
440
|
+
* @internal
|
|
441
|
+
* */
|
|
442
|
+
export function processTimeMS(): number {
|
|
443
|
+
return Math.floor(performance.now());
|
|
441
444
|
}
|
|
442
445
|
|
|
443
446
|
/** @internal */
|
|
@@ -446,7 +449,7 @@ export function calculateDurationInMs(started: number | undefined): number {
|
|
|
446
449
|
return -1;
|
|
447
450
|
}
|
|
448
451
|
|
|
449
|
-
const elapsed =
|
|
452
|
+
const elapsed = processTimeMS() - started;
|
|
450
453
|
return elapsed < 0 ? 0 : elapsed;
|
|
451
454
|
}
|
|
452
455
|
|