Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix(retryable-writes): don't add txnNumber for standalone servers
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Apr 18, 2019
1 parent 4b6e607 commit 8489265
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/topologies/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const os = require('os');
const f = require('util').format;
const ReadPreference = require('./read_preference');
const Buffer = require('safe-buffer').Buffer;
const TopologyType = require('../sdam/topology_description').TopologyType;

/**
* Emit event if it exists
Expand Down Expand Up @@ -398,6 +399,20 @@ const SessionMixins = {
}
};

function topologyType(topology) {
if (topology.description) {
return topology.description.type;
}

if (topology.type === 'mongos') {
return TopologyType.Sharded;
} else if (topology.type === 'replset') {
return TopologyType.ReplicaSetWithPrimary;
}

return TopologyType.Single;
}

const RETRYABLE_WIRE_VERSION = 6;

/**
Expand All @@ -415,6 +430,10 @@ const isRetryableWritesSupported = function(topology) {
return false;
}

if (topologyType(topology) === TopologyType.Single) {
return false;
}

return true;
};

Expand Down

0 comments on commit 8489265

Please sign in to comment.