Skip to content

Conversation

qingyang-hu
Copy link
Collaborator

GODRIVER-3288

Summary

Stop gossiping $clusterTime on SDAM commands.

Background & Motivation

@mongodb-drivers-pr-bot mongodb-drivers-pr-bot bot added the review-priority-low Low Priority PR for Review: within 3 business days label Jul 30, 2025
Copy link
Contributor

mongodb-drivers-pr-bot bot commented Jul 30, 2025

API Change Report

No changes found!

@qingyang-hu qingyang-hu force-pushed the godriver3288 branch 19 times, most recently from 111c4bc to 5c9f226 Compare August 13, 2025 15:15
@qingyang-hu qingyang-hu force-pushed the godriver3288 branch 2 times, most recently from 5d5a41a to 76cd8a3 Compare August 13, 2025 20:42
@qingyang-hu qingyang-hu marked this pull request as ready for review August 13, 2025 21:16
@Copilot Copilot AI review requested due to automatic review settings August 13, 2025 21:16
@qingyang-hu qingyang-hu requested a review from a team as a code owner August 13, 2025 21:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes cluster clock gossiping from Server Discovery and Monitoring (SDAM) commands, specifically the "hello" command used for heartbeats and initial server discovery. The change ensures that $clusterTime is not included in SDAM operations to comply with MongoDB driver specifications.

  • Removed cluster clock parameter from Hello operation constructors
  • Added null checks to prevent cluster time operations when no clock is provided
  • Added integration test to verify SDAM commands no longer gossip $clusterTime

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
x/mongo/driver/topology/topology_options.go Removed cluster clock from Hello operation configuration
x/mongo/driver/topology/server.go Removed cluster clock from heartbeat Hello operations
x/mongo/driver/operation/hello.go Removed ClusterClock method and field from Hello struct
x/mongo/driver/operation.go Added null checks for cluster clock operations
x/mongo/driver/auth/auth.go Removed cluster clock from authentication Hello operations
internal/integration/sessions_test.go Added test to verify SDAM commands don't gossip cluster time
internal/integration/mtest/mongotest.go Added null check before client disconnect

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <[email protected]>
}

// ClusterClock sets the cluster clock for this operation.
func (h *Hello) ClusterClock(clock *session.ClusterClock) *Hello {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC we still want to gossip cluster times when establishing connections.

@qingyang-hu qingyang-hu marked this pull request as draft August 15, 2025 21:32
@qingyang-hu qingyang-hu marked this pull request as ready for review August 15, 2025 23:59
op.updateClusterTimes(res)
// When a cluster clock is given, update cluster/operation time and recovery tokens before handling the error
// to ensure we're properly updating everything.
if op.Clock != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this block? Wouldn't op.updateClusterTimes(res) be a no-op if op.Click == nil for hello commands?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to stop updating the cluster time in session too, so L1709 in addClusterTime() will not append a “$clusterTime”.

Comment on lines 516 to 517
heartbeatStarted := make(chan struct{})
heartbeatSucceeded := make(chan struct{})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest buffering these channels and adding a wait function:

wait := func(mt *mtest.T, ch <-chan struct{}, label string) {
	mt.Helper()

	select {
	case <-ch:
	case <-time.After(5 * time.Second):
		mt.Fatalf("timed out waiting for %s", label)
	}
}
wait(mt, heartbeatStarted, "heartbeat started")
wait(mt, heartbeatSucceeded, "heartbeat succeeded")

@qingyang-hu qingyang-hu merged commit f7babc7 into mongodb:master Aug 20, 2025
30 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement review-priority-low Low Priority PR for Review: within 3 business days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants