Details
-
Bug
-
Resolution: Unresolved
-
Minor - P4
-
None
-
None
-
None
-
None
Description
Scope:
- Update topology-wide logicalSessionTimeoutMinutes when server is removed.
Background & Motivation
SDAM describes behavior for tracking the topology-wide logicalSessionTimeoutMinutes:
Whenever a client updates the TopologyDescription from a hello or legacy hello response, it MUST set TopologyDescription.logicalSessionTimeoutMinutes to the smallest logicalSessionTimeoutMinutes value among ServerDescriptions of all data-bearing server types. If any have a null logicalSessionTimeoutMinutes, then TopologyDescription.logicalSessionTimeoutMinutes MUST be set to null.
The topology-wide logicalSessionTimeoutMinutes may not be updated if a server is removed from the topology description.
Here is a failing test:
t.Run("test timeout after server removed", func(t *testing.T) {
|
f := fsm{
|
Topology: description.Topology{
|
Kind: description.ReplicaSetWithPrimary,
|
SessionTimeoutMinutesPtr: int64ToPtr(1),
|
Servers: []description.Server{
|
{
|
Kind: description.RSPrimary,
|
SessionTimeoutMinutesPtr: int64ToPtr(2),
|
Addr: "host1:27017",
|
Members: []address.Address{
|
"host1:27017",
|
"host2:27017",
|
},
|
},
|
{
|
Kind: description.RSSecondary,
|
SessionTimeoutMinutesPtr: int64ToPtr(1),
|
Addr: "host2:27017",
|
Members: []address.Address{
|
"host1:27017",
|
"host2:27017",
|
},
|
},
|
},
|
},
|
}
|
|
|
// Apply a new server description that removes `host2` from the FSM.
|
f.apply(description.Server{
|
Kind: description.RSPrimary,
|
SessionTimeoutMinutesPtr: int64ToPtr(2),
|
Addr: "host1:27017",
|
Members: []address.Address{
|
"host1:27017",
|
},
|
})
|
|
|
expect := []description.Server{
|
{
|
Kind: description.RSPrimary,
|
SessionTimeoutMinutesPtr: int64ToPtr(2),
|
Addr: "host1:27017",
|
Members: []address.Address{
|
"host1:27017",
|
},
|
},
|
}
|
|
|
assert.Equal(t, expect, f.Servers)
|
|
|
// Check that the SessionTimeoutMinutesPtr has been updated to the new minimum (2).
|
assert.NotNil(t, f.SessionTimeoutMinutesPtr)
|
assert.Equal(t, *f.SessionTimeoutMinutesPtr, int64(2)) // Fails
|
})
|
https://github.com/mongodb/mongo-go-driver/pull/1295/files#r1267070655 includes a suggested fix.
The topology-wide logicalSessionTimeoutMinutes is calculated by checking each server's reported logicalSessionTimeoutMinutes. Each server reports logicalSessionTimeoutMinutes in the response the "hello".
I expect this is low/no impact bug. The topology-wide logicalSessionTimeoutMinutes is used to determine session support. Sessions were introduced in server 3.6 (see DRIVERS-2337). Since the Go driver requires server 3.6 or newer, this may not have realistic impact.