Skip to content

GODRIVER-3533 Optimize value reader and writer#2022

Merged
prestonvasquez merged 13 commits intomongodb:masterfrom
prestonvasquez:GODRIVER-3533
May 1, 2025
Merged

GODRIVER-3533 Optimize value reader and writer#2022
prestonvasquez merged 13 commits intomongodb:masterfrom
prestonvasquez:GODRIVER-3533

Conversation

@prestonvasquez
Copy link
Member

@prestonvasquez prestonvasquez commented Apr 16, 2025

GODRIVER-3533

Summary

Use sync.Pool for the value writer and reader when encoding and decoding, respectively. Additionally, use peek and discard when appending elements to the read dst. The danger here occurs when a user finds a way to call Get() more than Put() which would result in a "leak" of reusable objects.

Note: Regressions from v1 will be addressed in GODRIVER-3450. The primary goal of this PR is to add optimizations that were removed in the v2 implementation.

Marshaling Benchmarks

v1:

BenchmarkMarshal/BSON/simple_struct-10           5279845               227.6 ns/op           288 B/op          1 allocs/op
BenchmarkMarshal/BSON/nested_struct-10           2844418               440.9 ns/op           416 B/op          1 allocs/op
BenchmarkMarshal/BSON/simple_D-10                5591744               217.8 ns/op           288 B/op          1 allocs/op
BenchmarkMarshal/BSON/deep_bson.json.gz-10        188263              6385 ns/op            9114 B/op        316 allocs/op
BenchmarkMarshal/BSON/flat_bson.json.gz-10        166884              7429 ns/op           14901 B/op        292 allocs/op
BenchmarkMarshal/BSON/full_bson.json.gz-10        168651              7226 ns/op           11001 B/op        241 allocs/op
BenchmarkMarshal/extJSON/simple_struct-10         695290              1683 ns/op            3477 B/op         88 allocs/op
BenchmarkMarshal/extJSON/nested_struct-10         510933              2423 ns/op            4630 B/op        132 allocs/op
BenchmarkMarshal/extJSON/simple_D-10              712291              1664 ns/op            3476 B/op         88 allocs/op
BenchmarkMarshal/extJSON/deep_bson.json.gz-10      73616             16458 ns/op           30228 B/op        890 allocs/op
BenchmarkMarshal/extJSON/flat_bson.json.gz-10      33312             36623 ns/op           83594 B/op       1284 allocs/op
BenchmarkMarshal/extJSON/full_bson.json.gz-10      36608             32847 ns/op           68587 B/op       1232 allocs/op
BenchmarkMarshal/JSON/simple_struct-10           8541211               144.9 ns/op           240 B/op          1 allocs/op
BenchmarkMarshal/JSON/nested_struct-10           6256928               183.3 ns/op           352 B/op          1 allocs/op
BenchmarkMarshal/JSON/simple_D-10                4428652               281.7 ns/op           448 B/op          1 allocs/op
BenchmarkMarshal/JSON/deep_bson.json.gz-10        200554              6352 ns/op           10869 B/op        316 allocs/op
BenchmarkMarshal/JSON/flat_bson.json.gz-10        103041             11485 ns/op           17848 B/op        295 allocs/op
BenchmarkMarshal/JSON/full_bson.json.gz-10        130994              9218 ns/op           14130 B/op        235 allocs/op
PASS
ok      go.mongodb.org/mongo-driver/bson        25.208s

PR:

BenchmarkMarshal/BSON/simple_struct-10           5395154               216.7 ns/op           288 B/op          1 allocs/op
BenchmarkMarshal/BSON/nested_struct-10           2889548               445.5 ns/op           416 B/op          1 allocs/op
BenchmarkMarshal/BSON/simple_D-10                5884207               210.3 ns/op           288 B/op          1 allocs/op
BenchmarkMarshal/BSON/deep_bson.json.gz-10        592386              1990 ns/op            2162 B/op          6 allocs/op
BenchmarkMarshal/BSON/flat_bson.json.gz-10        185100              6838 ns/op           14898 B/op        292 allocs/op
BenchmarkMarshal/BSON/full_bson.json.gz-10        194402              6245 ns/op           10332 B/op        211 allocs/op
BenchmarkMarshal/extJSON/simple_struct-10         761506              1609 ns/op            3476 B/op         88 allocs/op
BenchmarkMarshal/extJSON/nested_struct-10         512126              2270 ns/op            4630 B/op        132 allocs/op
BenchmarkMarshal/extJSON/simple_D-10              712059              1649 ns/op            3477 B/op         88 allocs/op
BenchmarkMarshal/extJSON/deep_bson.json.gz-10     112938             10419 ns/op           23267 B/op        580 allocs/op
BenchmarkMarshal/extJSON/flat_bson.json.gz-10      34946             34078 ns/op           83585 B/op       1284 allocs/op
BenchmarkMarshal/extJSON/full_bson.json.gz-10      12500             92065 ns/op          188265 B/op       1369 allocs/op
BenchmarkMarshal/JSON/simple_struct-10           8987240               134.8 ns/op           240 B/op          1 allocs/op
BenchmarkMarshal/JSON/nested_struct-10           7025131               182.9 ns/op           352 B/op          1 allocs/op
BenchmarkMarshal/JSON/simple_D-10                1390707               775.8 ns/op           929 B/op         17 allocs/op
BenchmarkMarshal/JSON/deep_bson.json.gz-10         77088             15683 ns/op           21436 B/op        298 allocs/op
BenchmarkMarshal/JSON/flat_bson.json.gz-10        120090             10125 ns/op           17616 B/op        293 allocs/op
BenchmarkMarshal/JSON/full_bson.json.gz-10        120982              9982 ns/op           16129 B/op        270 allocs/op
PASS
ok      go.mongodb.org/mongo-driver/v2/bson     26.065s

Note that we improved in deep BSON test cases but regressed with full BSON test cases. Otherwise the results are fairly similar.

Unmarshaling Benchmarks

v1:

BenchmarkUnmarshal/BSON/simple_struct-10                 3398468               347.9 ns/op       773.22 MB/s         640 B/op         27 allocs/op
BenchmarkUnmarshal/BSON/nested_struct-10                 8039444               139.4 ns/op      2955.96 MB/s         328 B/op          4 allocs/op
BenchmarkUnmarshal/BSON/simple_to_map-10                 1000000              1154 ns/op         233.10 MB/s        2051 B/op         66 allocs/op
BenchmarkUnmarshal/BSON/simple_to_D-10                   1529571               779.5 ns/op       345.11 MB/s        1576 B/op         34 allocs/op
BenchmarkUnmarshal/BSON/nested_to_map-10                  331148              3646 ns/op         113.01 MB/s        8461 B/op        146 allocs/op
BenchmarkUnmarshal/BSON/nested_to_D-10                    548484              2205 ns/op         186.84 MB/s        4818 B/op         92 allocs/op
BenchmarkUnmarshal/BSON/deep_bson.json.gz_to_map-10                81966             14420 ns/op         136.34 MB/s       31172 B/op        825 allocs/op
BenchmarkUnmarshal/BSON/deep_bson.json.gz_to_D-10                 144742              8436 ns/op         233.06 MB/s       14093 B/op        573 allocs/op
BenchmarkUnmarshal/BSON/flat_bson.json.gz_to_map-10                66225             17945 ns/op         336.92 MB/s       33596 B/op        753 allocs/op
BenchmarkUnmarshal/BSON/flat_bson.json.gz_to_D-10                 165055              7163 ns/op         844.00 MB/s       15853 B/op        316 allocs/op
BenchmarkUnmarshal/BSON/full_bson.json.gz_to_map-10                67675             18299 ns/op         231.27 MB/s       30682 B/op        808 allocs/op
BenchmarkUnmarshal/BSON/full_bson.json.gz_to_D-10                  98814             12325 ns/op         343.38 MB/s       23794 B/op        511 allocs/op
BenchmarkUnmarshal/extJSON/simple_struct-10                       349196              3441 ns/op         111.59 MB/s        6931 B/op        201 allocs/op
BenchmarkUnmarshal/extJSON/nested_struct-10                       273610              4361 ns/op         115.81 MB/s        9204 B/op        271 allocs/op
BenchmarkUnmarshal/extJSON/simple_to_map-10                       280131              4320 ns/op          88.88 MB/s        8342 B/op        240 allocs/op
BenchmarkUnmarshal/extJSON/simple_to_D-10                         347761              3970 ns/op          96.74 MB/s        7868 B/op        208 allocs/op
BenchmarkUnmarshal/extJSON/nested_to_map-10                       147412              8172 ns/op          61.80 MB/s       17074 B/op        387 allocs/op
BenchmarkUnmarshal/extJSON/nested_to_D-10                         177060              6717 ns/op          75.18 MB/s       13429 B/op        333 allocs/op
BenchmarkUnmarshal/extJSON/deep_bson.json.gz_to_map-10             36777             33408 ns/op          53.10 MB/s       64852 B/op       1779 allocs/op
BenchmarkUnmarshal/extJSON/deep_bson.json.gz_to_D-10               46696             26018 ns/op          68.18 MB/s       47692 B/op       1527 allocs/op
BenchmarkUnmarshal/extJSON/flat_bson.json.gz_to_map-10             21060             56535 ns/op         144.23 MB/s      101612 B/op       2673 allocs/op
BenchmarkUnmarshal/extJSON/flat_bson.json.gz_to_D-10               25857             45972 ns/op         177.37 MB/s       83853 B/op       2235 allocs/op
BenchmarkUnmarshal/extJSON/full_bson.json.gz_to_map-10             15014             76837 ns/op          88.95 MB/s      120958 B/op       3488 allocs/op
BenchmarkUnmarshal/extJSON/full_bson.json.gz_to_D-10               16902             70240 ns/op          97.31 MB/s      114074 B/op       3191 allocs/op
BenchmarkUnmarshal/JSON/simple_struct-10                         2839286               425.9 ns/op       540.08 MB/s         360 B/op          9 allocs/op
BenchmarkUnmarshal/JSON/nested_struct-10                         2434580               498.2 ns/op       704.55 MB/s         520 B/op          7 allocs/op
BenchmarkUnmarshal/JSON/simple_to_map-10                         1215229               996.1 ns/op       230.90 MB/s        1682 B/op         50 allocs/op
--- FAIL: BenchmarkUnmarshal/JSON/simple_to_D
    benchmark_test.go:427: error unmarshalling JSON: json: cannot unmarshal object into Go value of type primitive.D
BenchmarkUnmarshal/JSON/nested_to_map-10                          512389              2257 ns/op         155.49 MB/s        5538 B/op         76 allocs/op
--- FAIL: BenchmarkUnmarshal/JSON/nested_to_D
    benchmark_test.go:427: error unmarshalling JSON: json: cannot unmarshal object into Go value of type primitive.D
BenchmarkUnmarshal/JSON/deep_bson.json.gz_to_map-10               113818             10240 ns/op         173.25 MB/s       23864 B/op        389 allocs/op
--- FAIL: BenchmarkUnmarshal/JSON/deep_bson.json.gz_to_D
    benchmark_test.go:427: error unmarshalling JSON: json: cannot unmarshal object into Go value of type primitive.D
BenchmarkUnmarshal/JSON/flat_bson.json.gz_to_map-10                63711             19287 ns/op         351.07 MB/s       30372 B/op        548 allocs/op
--- FAIL: BenchmarkUnmarshal/JSON/flat_bson.json.gz_to_D
    benchmark_test.go:427: error unmarshalling JSON: json: cannot unmarshal object into Go value of type primitive.D
BenchmarkUnmarshal/JSON/full_bson.json.gz_to_map-10                51853             22884 ns/op         232.22 MB/s       40788 B/op        764 allocs/op
--- FAIL: BenchmarkUnmarshal/JSON/full_bson.json.gz_to_D
    benchmark_test.go:427: error unmarshalling JSON: json: cannot unmarshal object into Go value of type primitive.D
--- FAIL: BenchmarkUnmarshal/JSON
--- FAIL: BenchmarkUnmarshal
FAIL
exit status 1
FAIL    go.mongodb.org/mongo-driver/bson        46.022s

PR:

BenchmarkUnmarshal/BSON/simple_struct-10                 2687252               435.8 ns/op       617.22 MB/s         594 B/op         43 allocs/op
BenchmarkUnmarshal/BSON/nested_struct-10                 5361310               223.5 ns/op      1843.79 MB/s         609 B/op          5 allocs/op
BenchmarkUnmarshal/BSON/simple_to_map-10                 1000000              1098 ns/op         244.94 MB/s        2006 B/op         82 allocs/op
BenchmarkUnmarshal/BSON/simple_to_D-10                   1298235               916.2 ns/op       293.61 MB/s        1723 B/op         62 allocs/op
BenchmarkUnmarshal/BSON/nested_to_map-10                  570775              1950 ns/op         211.28 MB/s        3494 B/op        140 allocs/op
BenchmarkUnmarshal/BSON/nested_to_D-10                    635196              1864 ns/op         221.03 MB/s        3221 B/op        139 allocs/op
BenchmarkUnmarshal/BSON/deep_bson.json.gz_to_map-10               119232             10405 ns/op         188.94 MB/s       16993 B/op        889 allocs/op
BenchmarkUnmarshal/BSON/deep_bson.json.gz_to_D-10                 116686             10105 ns/op         194.56 MB/s       16751 B/op        887 allocs/op
BenchmarkUnmarshal/BSON/flat_bson.json.gz_to_map-10                67744             19374 ns/op         312.07 MB/s       39974 B/op        923 allocs/op
BenchmarkUnmarshal/BSON/flat_bson.json.gz_to_D-10                 108649             11504 ns/op         525.57 MB/s       24534 B/op        630 allocs/op
BenchmarkUnmarshal/BSON/full_bson.json.gz_to_map-10                63975             19073 ns/op         221.88 MB/s       33227 B/op       1042 allocs/op
BenchmarkUnmarshal/BSON/full_bson.json.gz_to_D-10                  77899             15481 ns/op         273.38 MB/s       29404 B/op        860 allocs/op
BenchmarkUnmarshal/extJSON/simple_struct-10                       355491              3324 ns/op         115.51 MB/s        6931 B/op        201 allocs/op
BenchmarkUnmarshal/extJSON/nested_struct-10                       272911              4301 ns/op         117.42 MB/s        9204 B/op        271 allocs/op
BenchmarkUnmarshal/extJSON/simple_to_map-10                       283300              4178 ns/op          91.91 MB/s        8341 B/op        240 allocs/op
BenchmarkUnmarshal/extJSON/simple_to_D-10                         300330              3906 ns/op          98.30 MB/s        8059 B/op        220 allocs/op
BenchmarkUnmarshal/extJSON/nested_to_map-10                       173290              6956 ns/op          72.60 MB/s       14070 B/op        357 allocs/op
BenchmarkUnmarshal/extJSON/nested_to_D-10                         173780              6552 ns/op          77.07 MB/s       13797 B/op        356 allocs/op
BenchmarkUnmarshal/extJSON/deep_bson.json.gz_to_map-10             44523             26567 ns/op          66.77 MB/s       49980 B/op       1655 allocs/op
BenchmarkUnmarshal/extJSON/deep_bson.json.gz_to_D-10               47103             26318 ns/op          67.41 MB/s       49739 B/op       1653 allocs/op
BenchmarkUnmarshal/extJSON/flat_bson.json.gz_to_map-10             22389             53443 ns/op         152.57 MB/s      101592 B/op       2673 allocs/op
BenchmarkUnmarshal/extJSON/flat_bson.json.gz_to_D-10               27526             42824 ns/op         190.41 MB/s       86181 B/op       2380 allocs/op
BenchmarkUnmarshal/extJSON/full_bson.json.gz_to_map-10             17000             68351 ns/op         100.00 MB/s      119552 B/op       3476 allocs/op
BenchmarkUnmarshal/extJSON/full_bson.json.gz_to_D-10               17534             67082 ns/op         101.89 MB/s      115747 B/op       3294 allocs/op
BenchmarkUnmarshal/JSON/simple_struct-10                         2837935               405.6 ns/op       567.00 MB/s         360 B/op          9 allocs/op
BenchmarkUnmarshal/JSON/nested_struct-10                         2484396               474.1 ns/op       740.35 MB/s         520 B/op          7 allocs/op
BenchmarkUnmarshal/JSON/simple_to_map-10                         1255458               919.8 ns/op       250.07 MB/s        1682 B/op         50 allocs/op
BenchmarkUnmarshal/JSON/simple_to_D-10                            419559              2815 ns/op          81.69 MB/s        5127 B/op        199 allocs/op
BenchmarkUnmarshal/JSON/nested_to_map-10                          492206              2309 ns/op         152.02 MB/s        5538 B/op         76 allocs/op
BenchmarkUnmarshal/JSON/nested_to_D-10                            276355              4400 ns/op          79.77 MB/s        7624 B/op        317 allocs/op
BenchmarkUnmarshal/JSON/deep_bson.json.gz_to_map-10               115366             10117 ns/op         175.35 MB/s       23928 B/op        389 allocs/op
BenchmarkUnmarshal/JSON/deep_bson.json.gz_to_D-10                  56762             21424 ns/op          82.81 MB/s       35191 B/op       1722 allocs/op
BenchmarkUnmarshal/JSON/flat_bson.json.gz_to_map-10            64996         18060 ns/op         374.92 MB/s       30367 B/op        548 allocs/op
BenchmarkUnmarshal/JSON/flat_bson.json.gz_to_D-10              31407         37441 ns/op         180.85 MB/s       53649 B/op       2288 allocs/op
BenchmarkUnmarshal/JSON/full_bson.json.gz_to_map-10                65449             18243 ns/op         267.61 MB/s       32170 B/op        616 allocs/op
BenchmarkUnmarshal/JSON/full_bson.json.gz_to_D-10                  23976             41944 ns/op         116.39 MB/s       64659 B/op       2766 allocs/op
PASS
ok      go.mongodb.org/mongo-driver/v2/bson     52.558s

Background & Motivation

Some optimizations were removed while flatting the bson library during the v2 implementation. Specifically:

@prestonvasquez prestonvasquez requested a review from a team as a code owner April 16, 2025 21:40
@prestonvasquez prestonvasquez requested review from Copilot and qingyang-hu and removed request for qingyang-hu April 16, 2025 21:40
Copy link
Contributor

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.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

bson/value_reader.go:50

  • [nitpick] The field name 'ra' is ambiguous; consider renaming it to 'readerAt' for improved clarity.
ra io.ReaderAt // The underlying reader

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

API Change Report

No changes found!


buf := make([]byte, length)
_, err = io.ReadFull(vr.r, buf)
buf, err := vr.r.Peek(int(length))
Copy link
Member Author

Choose a reason for hiding this comment

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

Peek only allocates once for the bufio's internal buffer, we can borrow views of it with Peek without touching the heap. And append makes the copy.


var documentWriterPool = sync.Pool{
New: func() interface{} {
return NewDocumentWriter(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we call newDocumentWriter() because it returns a *valueWriter for syntactic clarity?

Copy link
Contributor

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 optimizes the BSON value writer and reader by introducing sync.Pool usage for pooling document writers and readers, and by updating the element appending logic to use peek and discard. Key changes include:

  • Replacing direct allocations in value writer/reader creation with pooled instances.
  • Refactoring the reader’s element appending to use bufio.Reader’s Peek and Discard methods.
  • Adding safe resource release (e.g. returning pooled readers) in both marshal and unmarshal paths.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
bson/value_writer.go Introduced a documentWriterPool with helper functions for reuse.
bson/value_reader.go Added pools for bufio.Reader and valueReader with updated reset and release logic.
bson/unmarshal.go Updated to properly release pooled valueReader after unmarshalling.
bson/marshal.go Replaced NewDocumentWriter with pooled value writers via getDocumentWriter.

@@ -57,14 +72,26 @@ func newValueReader(t Type, r io.Reader) ValueReader {
}

func newDocumentReader(r io.Reader) *valueReader {
Copy link
Contributor

Choose a reason for hiding this comment

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

newDocumentReader() is also called where releaseDocumentReader() is not called. It seems we will have to reverse newDocumentReader() and add a reset() for valueReader like what we did for valueWriter.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor

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 reintroduces optimizations for BSON value reading and writing by leveraging sync.Pool for reusing document readers and writers. Key changes include:

  • Pooling and reuse of valueWriter objects via getDocumentWriter/putDocumentWriter.
  • Pooling of bufio.Reader and valueReader objects with corresponding get/put helper functions.
  • Updated error handling in appendNextElement to use Peek and Discard for efficient byte reading.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
bson/value_writer.go Introduces pooling for valueWriter objects with proper state reset.
bson/value_reader.go Adds pooling for bufio.Reader and valueReader; refines element reading logic.
bson/unmarshal.go & marshal.go Adopts the new pooling functions for improved resource reuse.
Files not reviewed (1)
  • testdata/specifications: Language not supported
Comments suppressed due to low confidence (1)

bson/value_writer.go:45

  • Verify that calling reset with the existing buffer in getDocumentWriter fully clears all internal state to avoid side effects from previous pooled instances.
vw.reset(vw.buf)

if vr == nil {
return
}

Copy link

Copilot AI Apr 29, 2025

Choose a reason for hiding this comment

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

Consider resetting the bufio.Reader (for example, by calling Reset(nil)) before returning it to the pool to clear its internal buffer and help prevent unintended memory retention.

Suggested change
vr.r.Reset(nil) // Clear the internal buffer to prevent memory retention.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a dangerous change that could cause OOB errors, e.g:

panic: runtime error: slice bounds out of range [62:0]

Comment on lines +301 to +309
temp := make([]byte, length)
if _, err = io.ReadFull(vr.r, temp); err != nil {
return nil, err
}
dst = append(dst, temp...)
vr.offset += int64(len(temp))
return dst, nil
}

Copy link

Copilot AI Apr 29, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider refactoring the error handling for bufio.ErrBufferFull in appendNextElement to streamline the code and reduce duplication in the fallback path.

Suggested change
temp := make([]byte, length)
if _, err = io.ReadFull(vr.r, temp); err != nil {
return nil, err
}
dst = append(dst, temp...)
vr.offset += int64(len(temp))
return dst, nil
}
return vr.readAndAppend(length, dst)
}

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

This suggestion is a hallucination., vr.readAndAppend() is not part of the valueReader API.

@jtazin jtazin removed the review-priority-low Low Priority PR for Review: within 3 business days label Apr 30, 2025
@jtazin jtazin added the review-priority-urgent High Priority PR for Review: review immediately! label Apr 30, 2025
vr.frame = 0

vr.stack = vr.stack[:1]
vr.stack[0].mode = mTopLevel
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of initializing other fields in stack to gain greater peace of mind?
e.g.

vr.stack[0] = vrState{mode: mTopLevel}

qingyang-hu
qingyang-hu previously approved these changes May 1, 2025
@prestonvasquez prestonvasquez merged commit 8c453d2 into mongodb:master May 1, 2025
29 of 34 checks passed
@prestonvasquez prestonvasquez deleted the GODRIVER-3533 branch May 1, 2025 18:21
@prestonvasquez
Copy link
Member Author

drivers-pr-bot please backport to release/2.2

prestonvasquez added a commit to prestonvasquez/mongo-go-driver that referenced this pull request May 1, 2025
prestonvasquez added a commit to prestonvasquez/mongo-go-driver that referenced this pull request May 1, 2025
prestonvasquez added a commit to prestonvasquez/mongo-go-driver that referenced this pull request May 1, 2025
riverajo added a commit to riverajo/fitness-app that referenced this pull request Jan 28, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [go.mongodb.org/mongo-driver](https://github.com/mongodb/mongo-go-driver) | `v1.17.7` → `v2.4.2` | ![age](https://developer.mend.io/api/mc/badges/age/go/go.mongodb.org%2fmongo-driver/v2.4.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/go/go.mongodb.org%2fmongo-driver/v1.17.7/v2.4.2?slim=true) |

---

### Release Notes

<details>
<summary>mongodb/mongo-go-driver (go.mongodb.org/mongo-driver)</summary>

### [`v2.4.2`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.4.2): MongoDB Go Driver 2.4.2

[Compare Source](mongodb/mongo-go-driver@v2.4.1...v2.4.2)

The MongoDB Go Driver Team is pleased to release version 2.4.2 of the official MongoDB Go Driver.

#### Release Highlights

This release fixes buffer handling in GSSAPI error description and username functions.

<!-- Release notes generated using configuration in .github/release.yml at v2.4.2 -->

#### What's Changed

##### 🐛 Fixed

- GODRIVER-3770 Fix buffer handling in GSSAPI error description and username functions  by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2297](mongodb/mongo-go-driver#2297)

**Full Changelog**: <mongodb/mongo-go-driver@v2.4.1...v2.4.2>

For a full list of tickets included in this release, please see the [list of fixed issues](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20fixVersion%3D2.4.2).

Documentation for the Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo?tab=doc) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson?tab=doc). For issues with, questions about, or feedback for the Go Driver, please look into our [support channels](https://www.mongodb.com/docs/manual/support/), including [StackOverflow](https://stackoverflow.com/questions/tagged/mongodb%20go?sort=Newest). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the Go Driver is greatly appreciated!

### [`v2.4.1`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.4.1): MongoDB Go Driver 2.4.1

[Compare Source](mongodb/mongo-go-driver@v2.4.0...v2.4.1)

The MongoDB Go Driver Team is pleased to release version 2.4.1 of the official MongoDB Go Driver.

<!-- Release notes generated using configuration in .github/release.yml at v2.4.1 -->

#### What's Changed

##### 🐛 Fixed

- GODRIVER-3704 Fix search index failure on empty "Options". by [@&#8203;qingyang-hu](https://github.com/qingyang-hu) in [#&#8203;2247](mongodb/mongo-go-driver#2247)

##### 📝 Other Changes

- GODRIVER-3696: Add CI/CD label to label checker by [@&#8203;alcaeus](https://github.com/alcaeus) in [#&#8203;2243](mongodb/mongo-go-driver#2243)

**Full Changelog**: <mongodb/mongo-go-driver@v2.4.0...v2.4.1>

For a full list of tickets included in this release, please see the [list of fixed issues](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20fixVersion%3D2.4.1).

Documentation for the Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo?tab=doc) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson?tab=doc). For issues with, questions about, or feedback for the Go Driver, please look into our [support channels](https://www.mongodb.com/docs/manual/support/), including [StackOverflow](https://stackoverflow.com/questions/tagged/mongodb%20go?sort=Newest). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the Go Driver is greatly appreciated!

### [`v2.4.0`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.4.0): MongoDB Go Driver 2.4.0

[Compare Source](mongodb/mongo-go-driver@v2.3.1...v2.4.0)

The MongoDB Go Driver Team is pleased to release version 2.4.0 of the official MongoDB Go Driver.

#### Release Highlights

> \[!IMPORTANT]
> Go Driver v2.4 requires MongoDB 4.2 or newer.

This release adds a new method [Client.AppendDriverInfo](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2@&#8203;v2.4.0/mongo#Client.AppendDriverInfo) that adds information to the driver metadata sent on subsequent connection handshakes.

<!-- Release notes generated using configuration in .github/release.yml at v2.4.0 -->

#### What's Changed

##### ✨ New Features

- GODRIVER-3544, GODRIVER-3653 Allow Client to Send Client Metadata On-Demand by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2197](mongodb/mongo-go-driver#2197)

##### 📝 Other Changes

- GODRIVER-3523 Drop support for MongoDB 4.0. by [@&#8203;qingyang-hu](https://github.com/qingyang-hu) in [#&#8203;2221](mongodb/mongo-go-driver#2221)
- GODRIVER-3288 Stop gossiping $clusterTime on SDAM commands. by [@&#8203;qingyang-hu](https://github.com/qingyang-hu) in [#&#8203;2150](mongodb/mongo-go-driver#2150)
- GODRIVER-3632: Reroute to use perfcomp from DET by [@&#8203;zhouselena](https://github.com/zhouselena) in [#&#8203;2163](mongodb/mongo-go-driver#2163)
- Update README.md by [@&#8203;NiteshSingh17](https://github.com/NiteshSingh17) in [#&#8203;2176](mongodb/mongo-go-driver#2176)
- Rewrite mongo.Connect documentation. by [@&#8203;matthewdale](https://github.com/matthewdale) in [#&#8203;2185](mongodb/mongo-go-driver#2185)
- Allow ignore-for-release label to satisfy label checker \[v2] by [@&#8203;matthewdale](https://github.com/matthewdale) in [#&#8203;2209](mongodb/mongo-go-driver#2209)
- Merge release/2.3 into master by [@&#8203;mongodb-drivers-pr-bot](https://github.com/mongodb-drivers-pr-bot)\[bot] in [#&#8203;2210](mongodb/mongo-go-driver#2210)
- GODRIVER-3667 Update support links. by [@&#8203;matthewdale](https://github.com/matthewdale) in [#&#8203;2215](mongodb/mongo-go-driver#2215)
- GODRIVER-3675 Rename `internal/decimal/decinal128.go` to `decimal128.go` by [@&#8203;ggyuchive](https://github.com/ggyuchive) in [#&#8203;2220](mongodb/mongo-go-driver#2220)

#### New Contributors

- [@&#8203;NiteshSingh17](https://github.com/NiteshSingh17) made their first contribution in [#&#8203;2176](mongodb/mongo-go-driver#2176)
- [@&#8203;ggyuchive](https://github.com/ggyuchive) made their first contribution in [#&#8203;2220](mongodb/mongo-go-driver#2220)

**Full Changelog**: <mongodb/mongo-go-driver@v2.3.1...v2.4.0>

For a full list of tickets included in this release, please see the [list of fixed issues](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20fixVersion%3D2.4.0).

Documentation for the Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo?tab=doc) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson?tab=doc). For issues with, questions about, or feedback for the Go Driver, please look into our [support channels](https://www.mongodb.com/docs/manual/support/), including [StackOverflow](https://stackoverflow.com/questions/tagged/mongodb%20go?sort=Newest). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the Go Driver is greatly appreciated!

### [`v2.3.1`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.3.1): MongoDB Go Driver 2.3.1

[Compare Source](mongodb/mongo-go-driver@v2.3.0...v2.3.1)

The MongoDB Go Driver Team is pleased to release version 2.3.1 of the official MongoDB Go Driver.

#### Release Highlights

This release applies client-level timeouts for tailable/awaitData cursors, and fixes a bug that causes a tight loop when there are no selectable servers.

<!-- Release notes generated using configuration in .github/release.yml at v2.3.1 -->

#### What's Changed

##### 🐛 Fixed

- GODRIVER-3616 Apply client-level timeout to tailable cursors by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2174](mongodb/mongo-go-driver#2174)
- GODRIVER-3648 Make server selection block on topology updates. by [@&#8203;matthewdale](https://github.com/matthewdale) in [#&#8203;2211](mongodb/mongo-go-driver#2211)

##### 📝 Other Changes

- Merge release/1.17 into release/2.2 by [@&#8203;mongodb-drivers-pr-bot](https://github.com/mongodb-drivers-pr-bot)\[bot] in [#&#8203;2193](mongodb/mongo-go-driver#2193)
- Merge release/2.2 into release/2.3 by [@&#8203;mongodb-drivers-pr-bot](https://github.com/mongodb-drivers-pr-bot)\[bot] in [#&#8203;2204](mongodb/mongo-go-driver#2204)

**Full Changelog**: <mongodb/mongo-go-driver@v2.3.0...v2.3.1>

For a full list of tickets included in this release, please see the [list of fixed issues](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20fixVersion%3D2.3.1).

Documentation for the Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo?tab=doc) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson?tab=doc). For issues with, questions about, or feedback for the Go Driver, please look into our [support channels](https://www.mongodb.com/docs/manual/support/), including [StackOverflow](https://stackoverflow.com/questions/tagged/mongodb%20go?sort=Newest). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the Go Driver is greatly appreciated!

### [`v2.3.0`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.3.0): MongoDB Go Driver 2.3.0

[Compare Source](mongodb/mongo-go-driver@v2.2.3...v2.3.0)

The MongoDB Go Driver Team is pleased to release version 2.3.0 of the official MongoDB Go Driver.

#### Release Highlights

> \[!IMPORTANT]\
> Go Driver v2.3 will be the last release to support MongoDB 4.0. Go Driver v2.4 will require MongoDB 4.2 or newer.

> \[!IMPORTANT]\
> The minimum Go version for Go Driver v2.3 is Go 1.19.

This release improves BSON unmarshal performance to fix the regression in v2.0 and fixes bugs in logging truncation and cursor timeouts.

<!-- Release notes generated using configuration in .github/release.yml at v2.3.0 -->

#### What's Changed

##### 🐛 Fixed

- GODRIVER-3473 Short-cicruit cursor.next() on invalid timeouts by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2135](mongodb/mongo-go-driver#2135)
- GODRIVER-3605 Refactor StringN by [@&#8203;qingyang-hu](https://github.com/qingyang-hu) in [#&#8203;2128](mongodb/mongo-go-driver#2128)
- fix wiremessage oob in case of intmin by [@&#8203;kobrineli](https://github.com/kobrineli) in [#&#8203;2076](mongodb/mongo-go-driver#2076)

##### 📦 Dependency Updates

- GODRIVER-3515 Bump the minimum Go Version to 1.19 by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2054](mongodb/mongo-go-driver#2054)

##### 📝 Other Changes

- GODRIVER-3587 Use raw bytes in valueReader by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2120](mongodb/mongo-go-driver#2120)
- optimize allocations in redactStartedInformationCmd by [@&#8203;isopov](https://github.com/isopov) in [#&#8203;2129](mongodb/mongo-go-driver#2129)
- GODRIVER-3102: Perf comparison by [@&#8203;zhouselena](https://github.com/zhouselena) in [#&#8203;2134](mongodb/mongo-go-driver#2134)
- GODRIVER-3102: Perf comp PR comment pipeline by [@&#8203;zhouselena](https://github.com/zhouselena) in [#&#8203;2149](mongodb/mongo-go-driver#2149)
- Add CODEOWNERS file by [@&#8203;alcaeus](https://github.com/alcaeus) in [#&#8203;2018](mongodb/mongo-go-driver#2018)
- GODRIVER-3444 Adjust getMore maxTimeMS Calculation for tailable awaitData Cursors by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;1925](mongodb/mongo-go-driver#1925)
- DEVPROD-17319 - update perf.send command to new results end point by [@&#8203;MAhmadShah](https://github.com/MAhmadShah) in [#&#8203;2029](mongodb/mongo-go-driver#2029)
- GODRIVER-3550 Update Documentation for Go Driver Branching and Merge … by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2045](mongodb/mongo-go-driver#2045)
- GODRIVER-3361 Improve connection error message. by [@&#8203;qingyang-hu](https://github.com/qingyang-hu) in [#&#8203;2027](mongodb/mongo-go-driver#2027)
- Add configuration for automated release notes by [@&#8203;alcaeus](https://github.com/alcaeus) in [#&#8203;2047](mongodb/mongo-go-driver#2047)
- Update README.md by [@&#8203;rishitb-mongodb](https://github.com/rishitb-mongodb) in [#&#8203;2055](mongodb/mongo-go-driver#2055)
- GODRIVER-3494 Deprecate hedged read preference methods. by [@&#8203;matthewdale](https://github.com/matthewdale) in [#&#8203;2100](mongodb/mongo-go-driver#2100)
- GODRIVER-3457: Pilot using OpenSSF Scorecard by [@&#8203;zhouselena](https://github.com/zhouselena) in [#&#8203;2104](mongodb/mongo-go-driver#2104)
- GODRIVER-3457: Add OpenSSF Scorecard to README by [@&#8203;zhouselena](https://github.com/zhouselena) in [#&#8203;2105](mongodb/mongo-go-driver#2105)
- GODRIVER-3518: Test flexible numeric comparisons with $$lte by [@&#8203;zhouselena](https://github.com/zhouselena) in [#&#8203;2106](mongodb/mongo-go-driver#2106)
- drivertest: name an anonymous error by [@&#8203;mmcclimon](https://github.com/mmcclimon) in [#&#8203;2115](mongodb/mongo-go-driver#2115)
- GODRIVER-3397 Remove the MONGODB-CR auth mechanism. by [@&#8203;matthewdale](https://github.com/matthewdale) in [#&#8203;2103](mongodb/mongo-go-driver#2103)
- GODRIVER-3399: PoolClearedError should have TransientTransactionError label appended to it by [@&#8203;zhouselena](https://github.com/zhouselena) in [#&#8203;2114](mongodb/mongo-go-driver#2114)
- Add guidelines for contributing features to the Go Driver by [@&#8203;alcaeus](https://github.com/alcaeus) in [#&#8203;2125](mongodb/mongo-go-driver#2125)

#### New Contributors

- [@&#8203;MAhmadShah](https://github.com/MAhmadShah) made their first contribution in [#&#8203;2029](mongodb/mongo-go-driver#2029)
- [@&#8203;rishitb-mongodb](https://github.com/rishitb-mongodb) made their first contribution in [#&#8203;2055](mongodb/mongo-go-driver#2055)
- [@&#8203;mmcclimon](https://github.com/mmcclimon) made their first contribution in [#&#8203;2115](mongodb/mongo-go-driver#2115)

**Full Changelog**: <mongodb/mongo-go-driver@v2.2.3...v2.3.0>

For a full list of tickets included in this release, please see the [list of fixed issues](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20fixVersion%3D2.3.0).

Documentation for the Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo?tab=doc) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson?tab=doc). Questions and inquiries can be asked on the [MongoDB Developer Community](https://www.mongodb.com/community/forums/tag/golang). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the Go Driver is greatly appreciated!

### [`v2.2.3`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.2.3): MongoDB Go Driver 2.2.3

[Compare Source](mongodb/mongo-go-driver@v2.2.2...v2.2.3)

The MongoDB Go Driver Team is pleased to release version 2.2.3 of the official MongoDB Go Driver.

#### Release Notes

This release updates the `DefaultClient` to use a non-default global `DefaultTransport`. This way, the program will not panic if the user changes the global `http.DefaultTransport` variable. The client is created as needed.

***

For a full list of tickets included in this release, please see the [list of fixed issues](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20fixVersion%3D2.2.3).

**Full Changelog**: [v2.2.2...v2.2.3](mongodb/mongo-go-driver@v2.2.2...v2.2.3)

Documentation for the Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo?tab=doc) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson?tab=doc). Questions and inquiries can be asked on the [MongoDB Developer Community](https://www.mongodb.com/community/forums/tag/golang). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the Go Driver is greatly appreciated!

### [`v2.2.2`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.2.2): MongoDB Go Driver 2.2.2

[Compare Source](mongodb/mongo-go-driver@v2.2.1...v2.2.2)

The MongoDB Go Driver Team is pleased to release version 2.2.2 of the official MongoDB Go Driver.

#### Release Notes

This release resolves three bugs in the Go Driver: it removes a buggy and unnecessary connection liveness check that could run unexpectedly or fail intermittently when maxIdleTimeMS was set, and it fixes an issue in decoding to overwrite prepopulated slice. Also, a unmarshaler for gridfs.File is added.

***

For a full list of tickets included in this release, please see the [list of fixed issues](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20fixVersion%3D2.2.2).

**Full Changelog**: [v2.2.1...v2.2.2](mongodb/mongo-go-driver@v2.2.1...v2.2.2)

Documentation for the Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo?tab=doc) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson?tab=doc). Questions and inquiries can be asked on the [MongoDB Developer Community](https://www.mongodb.com/community/forums/tag/golang). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the Go Driver is greatly appreciated!

#### What's Changed

- Ignore unmaintained branches when merging up by [@&#8203;alcaeus](https://github.com/alcaeus) in [#&#8203;2062](mongodb/mongo-go-driver#2062)
- GODRIVER-3549 Fix timeouts in CSE custom endpoint test ([#&#8203;2028](mongodb/mongo-go-driver#2028)) ([#&#8203;2031](mongodb/mongo-go-driver#2031)) by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2061](mongodb/mongo-go-driver#2061)
- GODRIVER-3516 Remove isAlive by [@&#8203;linfeip](https://github.com/linfeip) in [#&#8203;2060](mongodb/mongo-go-driver#2060)
- GODRIVER-3560 Assume ec2 role explicitly in CI by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2080](mongodb/mongo-go-driver#2080)
- GODRIVER-3524 Sync updates to reflect showExpandedEvents omissions by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2084](mongodb/mongo-go-driver#2084)
- GODRIVER-3565 Add UnmarshalBSON to GridFSFile by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2077](mongodb/mongo-go-driver#2077)
- GODRIVER-3574 Align BSON interface slice decoding with json package. by [@&#8203;qingyang-hu](https://github.com/qingyang-hu) in [#&#8203;2075](mongodb/mongo-go-driver#2075)

#### New Contributors

- [@&#8203;linfeip](https://github.com/linfeip) made their first contribution in [#&#8203;2060](mongodb/mongo-go-driver#2060)

**Full Changelog**: <mongodb/mongo-go-driver@v2.2.1...v2.2.2>

### [`v2.2.1`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.2.1): MongoDB Go Driver 2.2.1

[Compare Source](mongodb/mongo-go-driver@v2.2.0...v2.2.1)

The MongoDB Go Driver Team is pleased to release version 2.2.1 of the official MongoDB Go Driver.

#### Release Notes

This release enhances BSON encoding performance by using `sync.Pool` for value writers and readers during encoding and decoding, leading to better memory allocation and improved efficiency. Note that further regressions from version 1 may be addressed in GODRIVER-3450, with this update focusing on reinstating optimizations removed in the version 2 implementation. Performance may not be  1-1 with v1 since v2 suggests using the `bufio` package for byte management rather than a raw byte slice.

#### What's Changed

- GODRIVER-3546 Fix timeouts in CSE custom endpoint test ([#&#8203;2028](mongodb/mongo-go-driver#2028)) by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2031](mongodb/mongo-go-driver#2031)
- GODRIVER-3533 Optimize value reader and writer ([#&#8203;2022](mongodb/mongo-go-driver#2022)) by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2030](mongodb/mongo-go-driver#2030)
- DEVPROD-17319 Update perf.send command to new results end point by [@&#8203;prestonvasquez](https://github.com/prestonvasquez) in [#&#8203;2032](mongodb/mongo-go-driver#2032)

**Full Changelog**: <mongodb/mongo-go-driver@v2.2.0...v2.2.1>
**JIRA Release Notes**: <https://jira.mongodb.org/projects/GODRIVER/versions/43096>

Documentation for the Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo?tab=doc) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson?tab=doc). Questions and inquiries can be asked on the [MongoDB Developer Community](https://www.mongodb.com/community/forums/tag/golang). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the Go Driver is greatly appreciated!

### [`v2.2.0`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.2.0): MongoDB Go Driver 2.2.0

[Compare Source](mongodb/mongo-go-driver@v2.1.0...v2.2.0)

The MongoDB Go Driver team is pleased to release version 2.2.0 of the official MongoDB Go Driver.

#### Release Notes

This release includes support for a global `omitempty` setting to omit empty values when encoding BSON, instead of requiring tagging on individual struct fields. We have implemented support for [`errors.Is`](https://pkg.go.dev/errors#Is) and [`errors.As`](https://pkg.go.dev/errors#As) in all stable public APIs for improved error management. Also included is support to configure the lifetime of the [Data Encryption Key (DEK)](https://www.mongodb.com/docs/manual/core/csfle/fundamentals/manage-keys/) cache as well as [Kubernetes Support for OIDC](https://www.mongodb.com/docs/drivers/go/current/fundamentals/enterprise-auth/#kubernetes).

Additionally **MongoDB Server Version 3.6** has been marked as end-of-life (EOL) and is no longer supported by the driver. Users are advised to upgrade to a supported version.

***

For a full list of tickets included in this release, please see the links below:

- [New Features](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3D%22new%20feature%22%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.2.0)
- [Improvements](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3Dimprovement%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.2.0)
- [Bugs](https://jira.mongodb.org/issues/?jql=project%3DGODRIVER%20and%20type%3DBug%20and%20status%3Dclosed%20and%20fixVersion%3D2.2.0)
- [Tasks](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3D%22task%22%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.2.0)

**Full Changelog**: [v2.1.0...v2.2.0](mongodb/mongo-go-driver@v2.1.0...v2.2.0)

**Note**: The Go Driver team has implemented a workflow action to automatically merge up PRs between v1 and master. This has resulted in an over-extended changelog for this version, including v1 commits for PRs that have already been cherry-picked to master. Please see the associated tickets for commits directly associated with this release.

Documentation for the MongoDB Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson). Questions and inquiries can be asked on the [MongoDB Developer Community](https://www.mongodb.com/community/forums/tag/golang). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the MongoDB Go Driver is greatly appreciated!

### [`v2.1.0`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.1.0): MongoDB Go Driver 2.1.0

[Compare Source](mongodb/mongo-go-driver@v2.0.1...v2.1.0)

The MongoDB Go Driver Team is pleased to release version 2.1.0 of the official MongoDB Go Driver.

#### Release Notes

This release adds support for the new bulk write API added in [MongoDB 8.0](https://www.mongodb.com/docs/manual/release-notes/8.0/#new-bulk-write-command) and the new BSON vector datatype used in [Atlas Vector Search](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/).

**Additionally, support for MongoDB 3.6 and below was deprecated in v2.0.0 and will be dropped in the next minor version release (v2.2.0).**

##### New BulkWrite API

The new [Client.BulkWrite](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo#Client.BulkWrite) method can perform many insert, update, and delete operations on multiple databases and collections in one request. In contrast, the existing [Collection.BulkWrite](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo#Collection.BulkWrite) method can only modify a single collection.

##### BSON Vector Datatype

The new [bson.Vector](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson#Vector) type makes inserting and querying vector data using [Atlas Vector Search](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/) easier and more efficient.

***

For a full list of tickets included in this release, please see the links below:

- [New Features](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3D%22new%20feature%22%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.1.0)
- [Improvements](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3Dimprovement%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.1.0)
- [Bugs](https://jira.mongodb.org/issues/?jql=project%3DGODRIVER%20and%20type%3DBug%20and%20status%3Dclosed%20and%20fixVersion%3D2.1.0)
- [Tasks](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3D%22task%22%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.1.0)

**Full Changelog**: [v2.0.1...v2.1.0](mongodb/mongo-go-driver@v2.0.1...v2.1.0)

Documentation for the MongoDB Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson). Questions and inquiries can be asked on the [MongoDB Developer Community](https://www.mongodb.com/community/forums/tag/golang). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the MongoDB Go Driver is greatly appreciated!

### [`v2.0.1`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.0.1): MongoDB Go Driver 2.0.1

[Compare Source](mongodb/mongo-go-driver@v2.0.0...v2.0.1)

The MongoDB Go Driver team is pleased to release version 2.0.1 of the official MongoDB Go Driver.

#### Release Notes

This release includes various bug fixes and improvements:

- Allows SRV hostnames with only a domain name and TLD (e.g. "service-name.tld").
- Detects joined errors correctly in [IsNetworkError](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo#IsNetworkError) and [WithTransaction](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo#Session.WithTransaction).
- Fixes a memory buffer reuse bug in [MarshalValue](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson#MarshalValue) that can cause marshaled bytes to become corrupted.
- No longer returns nil from [MergeClientOptions](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo/options#MergeClientOptions) when only one nil argument is passed.
- Skips calling [UnmarshalBSONValue](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson#ValueUnmarshaler.UnmarshalBSONValue) only if the associated BSON field value is null and the Go value is a pointer.

***

For a full list of tickets included in this release, please see the links below:

- [Bugs](https://jira.mongodb.org/issues/?jql=project%3DGODRIVER%20and%20type%3DBug%20and%20status%3Dclosed%20and%20fixVersion%3D2.0.1)
- [Tasks](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3D%22task%22%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.0.1)

**Full Changelog**: [v2.0.0...v2.0.1](mongodb/mongo-go-driver@v2.0.0...v2.0.1)

Documentation for the MongoDB Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson). Questions and inquiries can be asked on the [MongoDB Developer Community](https://www.mongodb.com/community/forums/tag/golang). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the MongoDB Go Driver is greatly appreciated!

### [`v2.0.0`](https://github.com/mongodb/mongo-go-driver/releases/tag/v2.0.0): MongoDB Go Driver 2.0.0

[Compare Source](mongodb/mongo-go-driver@v1.17.7...v2.0.0)

The MongoDB Go Driver Team is pleased to release version 2.0.0 of the official MongoDB Go driver.

#### Release Notes

This release includes a host of new features and several breaking changes. Below, we provide an overview of the key highlights, changes, and guidance for migrating from version 1.x to 2.0. See the [MongoDB docs](https://www.mongodb.com/docs/drivers/go/upcoming/whats-new/#what-s-new-in-2.0) for a complete list of breaking changes and additional information on what's new.

This release includes several breaking changes that users must account for when upgrading, including:

- **Options Package**: The approach to managing options has been restructured to use a builder pattern, changing how options are constructed and applied. This alteration allows for more flexible and dynamic option configurations, but may require changes to existing code that directly manipulates options objects.
- **Mongo Package**: The `Client.Connect()` method has been removed, favoring `mongo.Connect()` to streamline connection handling.
- **Event Package**: References to the `description` package have been transitioned to `event.ServerDescription` and `event.TopologyDescription`, impacting how server and topology details are accessed.
- **BSON Package Consolidation**: All previously separate BSON-related packages, including `bsoncodec`, `bsonoptions`, `bsonrw`, and `mgocompat`, have been merged into the single `bson` package. Many functionalities from these packages have been reorganized or renamed. For instance, `bson.NewRegistryBuilder` has been replaced with new APIs tailored for registry configuration, and interfaces like `ValueReader` and `ValueWriter` are now part of the consolidated `bson` package. This consolidation simplifies the package structure but requires updates to import paths and related logic.

To ease the transition to 2.0, **a comprehensive [migration guide](https://github.com/mongodb/mongo-go-driver/blob/master/docs/migration-2.0.md) has been provided**. This guide includes detailed instructions to navigate the changes, including the updated options pattern, altered imports, and revised method signatures.

Additionally, this release deprecates support for MongoDB server versions below 3.6. Support for MongoDB 3.6 will be dropped in a future update.

New features will no longer be added to the 1.x versions. However, critical bug fixes and CVE resolutions will continue to be back-ported to 1.x versions for one year until January 15, 2026. After that date, support for 1.x versions will be discontinued.

We express our gratitude to our contributors and the community for all the support in developing this release.

***

For a full list of tickets included in this release, please see the links below:

- [Projects](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3Depic%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.0.0)
- [New Features](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3D%22new%20feature%22%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.0.0)
- [Improvements](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3Dimprovement%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.0.0)
- [Bugs](https://jira.mongodb.org/issues/?jql=project%3DGODRIVER%20and%20type%3DBug%20and%20status%3Dclosed%20and%20fixVersion%3D2.0.0)
- [Tasks](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3D%22task%22%20and%20status%20%3D%20Closed%20and%20fixVersion%3D2.0.0)

**Full Changelog**: [v1.17.1...v2.0.0](mongodb/mongo-go-driver@v1.17.1...v2.0.0)

Documentation for the Go driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo?tab=doc) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/bson?tab=doc). Questions and inquiries can be asked on the [MongoDB Developer Community](https://community.mongodb.com/). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the Go driver is greatly appreciated!

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi45Mi4yIiwidXBkYXRlZEluVmVyIjoiNDIuOTIuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Co-authored-by: Renovate Bot <renovate@yourdomain.com>
Co-authored-by: riverajo <2325467+riverajo@users.noreply.github.com>
Reviewed-on: https://git.rivera.ninja/joe/fitness-app/pulls/29
Co-authored-by: renovate-bot <rivera.d.joseph@gmaill.com>
Co-committed-by: renovate-bot <rivera.d.joseph@gmaill.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-priority-urgent High Priority PR for Review: review immediately!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants