Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/operations/execute_operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,15 @@ async function executeOperationWithRetries<
session.unpin({ force: true, forceClear: true });
}

if (
operationError.hasErrorLabel(MongoErrorLabel.SystemOverloadedError) &&
session != null &&
session.isPinned &&
!session.inTransaction()
) {
session.unpin({ force: true });
}
Comment thread
PavelSafronov marked this conversation as resolved.
Comment thread
PavelSafronov marked this conversation as resolved.

if (
topology.description.type === TopologyType.Sharded ||
operationError.hasErrorLabel(MongoErrorLabel.SystemOverloadedError)
Expand Down
129 changes: 129 additions & 0 deletions test/spec/client-backpressure/backpressure-connection-checkin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"description": "tests that connections are returned to the pool on retry attempts for overload errors",
"schemaVersion": "1.3",
"runOnRequirements": [
{
"minServerVersion": "4.4",
"topologies": [
"replicaset",
"sharded",
"load-balanced"
]
}
],
"createEntities": [
{
"client": {
"id": "client",
"useMultipleMongoses": false,
"observeEvents": [
"connectionCheckedOutEvent",
"connectionCheckedInEvent"
]
}
},
{
"client": {
"id": "fail_point_client",
"useMultipleMongoses": false
}
},
{
"database": {
"id": "database",
"client": "client",
"databaseName": "backpressure-connection-checkin"
}
},
{
"collection": {
"id": "collection",
"database": "database",
"collectionName": "coll"
}
}
],
"tests": [
{
"description": "overload error retry attempts return connections to the pool",
"operations": [
{
"name": "failPoint",
"object": "testRunner",
"arguments": {
"client": "fail_point_client",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": "alwaysOn",
"data": {
"failCommands": [
"find"
],
"errorLabels": [
"RetryableError",
"SystemOverloadedError"
],
"errorCode": 2
}
}
}
},
{
"name": "find",
"object": "collection",
"arguments": {
"filter": {}
},
"expectError": {
"isError": true,
"isClientError": false
}
}
],
"expectEvents": [
{
"client": "client",
"eventType": "cmap",
"events": [
{
"connectionCheckedOutEvent": {}
},
{
"connectionCheckedInEvent": {}
},
{
"connectionCheckedOutEvent": {}
},
{
"connectionCheckedInEvent": {}
},
{
"connectionCheckedOutEvent": {}
},
{
"connectionCheckedInEvent": {}
},
{
"connectionCheckedOutEvent": {}
},
{
"connectionCheckedInEvent": {}
},
{
"connectionCheckedOutEvent": {}
},
{
"connectionCheckedInEvent": {}
},
{
"connectionCheckedOutEvent": {}
},
{
"connectionCheckedInEvent": {}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
description: tests that connections are returned to the pool on retry attempts for overload errors
schemaVersion: "1.3"
runOnRequirements:
- minServerVersion: "4.4"
topologies:
- replicaset
- sharded
- load-balanced
createEntities:
- client:
id: client
useMultipleMongoses: false
observeEvents:
- connectionCheckedOutEvent
- connectionCheckedInEvent
- client:
id: fail_point_client
useMultipleMongoses: false
- database:
id: database
client: client
databaseName: backpressure-connection-checkin
- collection:
id: collection
database: database
collectionName: coll
tests:
- description: overload error retry attempts return connections to the pool
operations:
- name: failPoint
object: testRunner
arguments:
client: fail_point_client
failPoint:
configureFailPoint: failCommand
mode: alwaysOn
data:
failCommands:
- find
errorLabels:
- RetryableError
- SystemOverloadedError
errorCode: 2
- name: find
object: collection
arguments:
filter: {}
expectError:
isError: true
isClientError: false
expectEvents:
- client: client
eventType: cmap
events:
- connectionCheckedOutEvent: {}
- connectionCheckedInEvent: {}
- connectionCheckedOutEvent: {}
- connectionCheckedInEvent: {}
- connectionCheckedOutEvent: {}
- connectionCheckedInEvent: {}
- connectionCheckedOutEvent: {}
- connectionCheckedInEvent: {}
- connectionCheckedOutEvent: {}
- connectionCheckedInEvent: {}
- connectionCheckedOutEvent: {}
- connectionCheckedInEvent: {}

Loading