[GODRIVER-2918] Topology logicalSessionTimeoutMinutes may not be updated if server is removed Created: 24/Jul/23  Updated: 24/Jul/23

Status: Backlog
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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.


Generated at Thu Feb 08 08:39:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.