Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-2586 Add log messages to CMAP spec #1165

Merged
merged 111 commits into from
Feb 27, 2023

Conversation

prestonvasquez
Copy link
Collaborator

@prestonvasquez prestonvasquez commented Jan 26, 2023

GODRIVER-2586

Summary

This PR adds log messages to CMAP operations.

Additional Updates

1. Add Reason type to the "event" and "logging" packages

There is an unexported function in the x "topology" package used to source the event reason for the event monitor called "connectionPerished". The exact strings for the event reason differ between the "event" and "logging" packages. In order to unify the two packages, this PR proposes that we update the function signature to return a struct with fields for various reasons:

type reason struct {
	loggerConn logger.Reason
	event      event.Reason
}

2. Unify Component Keys

Add constants to the logger/component.go file that represent "key names". This will unify the IO Sink, the serialization methods, and the key/values appended to logs messages through pool and command operations.

3. Closing v. Checkout Failure

The Go Driver creates it’s pool of connections in the background and there is always a realistic chance that a connection will close after a checkout fails. After careful consideration, the team doesn’t believe this behavior is a bug but a consequence of gracefully trying to concurrently deliver checkouts.

These issues will almost certainly come up again in the specifications PR #1369.

Multiple solutions have been proposed to resolve this issue:

  1. Relaxing the requirements on the number of logs, suggested by specifications PR #1372. This was rejected on the basis that we lose the ability to ensure drivers are not generating extra, incorrect log message
  2. Guarding the "ready" channel with a mutex in the Go Driver, suggested by PR Guard wantConn.ready with a Mutex #1172. Despite only synchronizing error handling, there is concern from the Go Driver team that this code is confusing.
  3. Adding an "unordered" boolean to the “expectedLogMessages.message” objects to indicate that the order for a particular message is not strict. While this has not been rejected, the spec owner wants to discuss the implications of 1369 first.

To prevent GODRIVER-2586 from being blocked, this PR suggests that for the moment we relax the order requirements for logs with "ConnectionClosed" and "ConnectionCheckoutFailed" messages.

Background & Motivation

To add log messages and corresponding tests for connection pool logging.

@prestonvasquez prestonvasquez marked this pull request as ready for review February 8, 2023 23:08
Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

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

Some comments about synchronization/buffering of json.Encoder, but everything else looks great!

Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

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

One suggestion to fix the ExampleClientOptions_SetLoggerOptions_customLogger test failures. Otherwise, looks good 👍

Co-authored-by: Matt Dale <9760375+matthewdale@users.noreply.github.com>
Copy link
Collaborator

@qingyang-hu qingyang-hu left a comment

Choose a reason for hiding this comment

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

Great job!

@prestonvasquez prestonvasquez merged commit 038249a into mongodb:master Feb 27, 2023
@prestonvasquez prestonvasquez deleted the GODRIVER-2586 branch February 27, 2023 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants