-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
Empty show more show less
-
Not Needed
We run the nodejs mongo driver in the following environments
- fastify server
- docker lts-alpine image
- aws ecs fargate
- azure container instances
Our logs are constantly reporting the following error:
{{
{ "level": 30, "time": 1620059246339, "pid": 1, "hostname": "ip-10-0-34-147.ec2.internal", "type": "error", "message": "Pool with id [1] failed attempted illegal state transition from [disconnected] to [connected] only following state allowed [[ 'connecting', 'destroyed', 'disconnected' ]]", "className": "ReplSet", "date": 1620059246339, "msg": "[ERROR-ReplSet:1] 1620059246339 Pool with id [1] failed attempted illegal state transition from [disconnected] to [connected] only following state allowed [[ 'connecting', 'destroyed', 'disconnected' ]]" }}}
Looking at the code i think i can eyeball the issue
function stateTransition(self, newState) {
{{ var legalTransitions = {}}
disconnected: [CONNECTING, DESTROYED, DISCONNECTED],
connecting: [CONNECTING, DESTROYED, CONNECTED, DISCONNECTED],
connected: [CONNECTED, DISCONNECTED, DESTROYED, UNREFERENCED],
unreferenced: [UNREFERENCED, DESTROYED],
destroyed: [DESTROYED]
{{ };}}
But there exists the following caller still
if (
{{ self.state === DISCONNECTED &&}}
{{ ((self.s.replicaSetState.hasSecondary() &&}}
{{ self.s.options.secondaryOnlyConnectionAllowed) ||}}
{{ self.s.replicaSetState.hasPrimary())}}
{{ ) {}}
stateTransition(self, CONNECTED);// Rexecute any stalled operation
rexecuteOperations(self);// Emit connected sign
process.nextTick(function() {
self.emit('reconnect', self);
{{ });}}
{{ }}}