MongoDB Go Driver v2.7.0 - Session Writes and BSON Fixes


MongoDB Go Driver v2.7.0 was published on June 18, 2026, with write support for afterClusterTime in causally consistent sessions as the main data path change. For services that mix reads and writes inside session scoped workflows, the release narrows a consistency gap that can matter in ETL workers, API backends, and queue consumers that write after a causally linked read. It is a regular release, not a prerelease.

The full release notes and downloads are on the GitHub release page.

The most relevant change is PR 2412, which sends afterClusterTime on writes in causally consistent sessions. The release notes describe it as alignment between read and write behavior. That is the right frame for data services that use MongoDB as a state store, not just an object lookup layer.

A worker that reads source state, computes a derived document, and writes a result depends on the ordering model around that session. Before this change, a pipeline could be using causal consistency for reads while writes did not carry the same cluster time signal. The new behavior makes the driver less surprising for session based workflows, especially when retry logic and replica set lag are already in the picture.

The release also adds a prose test for database.ListCollection routing in PR 2390. That is not a runtime feature, but it does protect routing behavior around collection metadata calls, which show up in schema discovery jobs and migration tooling.

For bulk load and sync jobs, PR 2397 is the fix to read. The driver now splits write batches by wire message size rather than document payload size. That distinction matters because the wire message has overhead beyond the raw document bytes. A batch that looks valid at the BSON payload level can still exceed the actual protocol envelope.

The release also fixes bson.Raw.Validate on zero length BSON documents in PR 2418. A validation path should return an error for bad data, not panic the caller. That is especially important in web processing and ingest code where BSON may be assembled from external JSON, message payloads, or archive replay.

Collection.Clone now propagates BSONOptions through PR 2364. If a service relies on specific encoding or decoding behavior, cloned collection handles should not silently lose those options. This is a small fix, but it removes a class of configuration drift inside shared data access helpers.

Change stream users should note PR 2424, which fixes batch size handling for a nil cursor. The release notes do not describe a broad change stream redesign. This is a targeted correctness fix around cursor state, useful for consumers that keep streams open as part of CDC style processing.

Error surfaces also get practical fixes. PR 2420 fixes mongo.ErrorCodes() with ClientBulkWriteException, which helps bulk write handlers classify failures without special parsing. PR 2430 corrects misleading type information in a rewrap function, and PR 2423 fixes argument formatting. These are not large feature items, but they reduce time spent reading vague logs during failed ingest runs.

The release continues API cleanup. PR 2416 deprecates the experimental x/mongo/driver/session package. PR 2411 deprecates AggregateOptions Custom functionality as internal only. Neither item is presented as a breaking change in the notes, but both are migration signals.

Projects using only the public mongo package surface should see this as housekeeping. Projects that reached into experimental or internal only areas should remove those dependencies before a later major cleanup turns deprecation into removal. This is also a good moment to scan wrappers around aggregate calls and session helpers.

Build and test hygiene changed as well. The lint install script moves away from curl | sh toward go install in etc/golangci-lint.sh, and format checking moved into internal/cmd/check-fmt. The release also expands format coverage for _example_test.go and _examples_test.go. These items mostly affect contributors and downstream packagers who run the driver test tree.