Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1b98f18
vendor: upgrade to go driver v2
mmcclimon Jan 28, 2026
4ca2fc1
Update to driver v2 in all import statements
mmcclimon Jan 21, 2026
3f18415
Translate primitive -> bson throughout
mmcclimon Jan 21, 2026
c7de26a
bsonutil: replace use of bson.D.Map()
mmcclimon Jan 22, 2026
82c1131
Upgrade writeconcern stuff to v2 (broken)
mmcclimon Jan 23, 2026
93d27c6
client opts: use new interfaces
mmcclimon Jan 23, 2026
64e8106
bulk inserter: fix BypassEmptyTsReplacement
mmcclimon Jan 23, 2026
e8fc717
common: tweaks to fix fallout from driver upgrade
mmcclimon Jan 29, 2026
978dd11
mongofiles: make it compile again
mmcclimon Jan 21, 2026
1f21c55
mongorestore: comment out uncompiling code
mmcclimon Jan 27, 2026
c90f339
mongostat: upgrade to driver v2 method name
mmcclimon Jan 27, 2026
18dd1c0
mongodump tests: make them compile
mmcclimon Jan 27, 2026
4c00474
mongorestore tests: make them compile
mmcclimon Jan 27, 2026
a9ed249
mongorestore: fix marshaling of writeconcern
mmcclimon Jan 28, 2026
03905d2
mongoimport tests: make them compile/pass
mmcclimon Jan 27, 2026
b2eaa5f
json decoder: bypass v2 unmarshaling of bson.D
mmcclimon Jan 27, 2026
bd2d1e5
writeconcern tests: make them compile/pass
mmcclimon Jan 27, 2026
d9e7f5a
Fix breakage from v2 bson default decode to bson.D
mmcclimon Jan 27, 2026
9a056c3
lint: check two errors from internal driver options
mmcclimon Jan 28, 2026
9690b3c
mongodump test: fix an unrelated race condition
mmcclimon Jan 28, 2026
a11fc0e
writeconcern: wrap the driver's writeconcern
mmcclimon Jan 28, 2026
6d3a65b
common/db: parse wtimeout from --writeConcern option
mmcclimon Jan 28, 2026
276dd1a
mongofiles: use context to replace WTimeout functionality
mmcclimon Jan 28, 2026
bf3e0cd
mongorestore: use context to replace WTimeout
mmcclimon Jan 28, 2026
be4c33d
tests: ensure non-nil ToolOptions.WriteConcern
mmcclimon Jan 29, 2026
a54671d
bulk inserter: take a context argument throughout
mmcclimon Jan 29, 2026
f383967
client opts: do not call SetTimeout with SocketTimeout
mmcclimon Feb 2, 2026
34cc992
Update ssdlc stuff for new code
mmcclimon Jan 28, 2026
ad26093
Remove todo comments with writeconcern
mmcclimon Feb 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
125 changes: 66 additions & 59 deletions THIRD-PARTY-NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -4632,38 +4632,6 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


----------------------------------------------------------------------
License notice for github.com/golang/snappy (LICENSE)
----------------------------------------------------------------------

Copyright (c) 2011 The Snappy-Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

----------------------------------------------------------------------
License notice for github.com/google/go-cmp (LICENSE)
----------------------------------------------------------------------
Expand Down Expand Up @@ -5170,6 +5138,71 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

----------------------------------------------------------------------
License notice for github.com/klauspost/compress/s2 (LICENSE)
----------------------------------------------------------------------

Copyright (c) 2011 The Snappy-Go Authors. All rights reserved.
Copyright (c) 2019 Klaus Post. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

----------------------------------------------------------------------
License notice for github.com/klauspost/compress/snappy (LICENSE)
----------------------------------------------------------------------

Copyright (c) 2011 The Snappy-Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

----------------------------------------------------------------------
License notice for github.com/klauspost/compress/zstd/internal/xxhash (LICENSE.txt)
----------------------------------------------------------------------
Expand Down Expand Up @@ -5510,32 +5543,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

----------------------------------------------------------------------
License notice for github.com/montanaflynn/stats (LICENSE)
----------------------------------------------------------------------

The MIT License (MIT)

Copyright (c) 2014-2023 Montana Flynn (https://montanaflynn.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

----------------------------------------------------------------------
License notice for github.com/nsf/termbox-go (LICENSE)
----------------------------------------------------------------------
Expand Down Expand Up @@ -6702,7 +6709,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
----------------------------------------------------------------------
License notice for go.mongodb.org/mongo-driver (LICENSE)
License notice for go.mongodb.org/mongo-driver/v2 (LICENSE)
----------------------------------------------------------------------

Apache License
Expand Down
2 changes: 1 addition & 1 deletion bsondump/bsondump.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/mongodb/mongo-tools/common/log"
"github.com/mongodb/mongo-tools/common/options"
"github.com/mongodb/mongo-tools/common/util"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)

// 16kb + 16mb - This is the maximum size we would get when dumping the
Expand Down
2 changes: 1 addition & 1 deletion bsondump/bsondump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/mongodb/mongo-tools/common/testtype"
"github.com/mongodb/mongo-tools/common/testutil"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)

func TestBsondump(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions common/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"io"

"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore"
)

// NamespaceHeader is a data structure that, as BSON, is found in archives where it indicates
Expand All @@ -40,7 +40,7 @@ func (nh NamespaceHeader) MarshalBSON() ([]byte, error) {
AppendValue(
"CRC",
bsoncore.Value{
Type: bson.TypeInt64,
Type: bsoncore.Type(bson.TypeInt64),
Data: binary.LittleEndian.AppendUint64(nil, nh.CRC),
},
).Build()
Expand Down
2 changes: 1 addition & 1 deletion common/archive/demultiplexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/mongodb/mongo-tools/common/intents"
"github.com/mongodb/mongo-tools/common/log"
"github.com/mongodb/mongo-tools/common/util"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)

// DemuxOut is a Demultiplexer output consumer
Expand Down
2 changes: 1 addition & 1 deletion common/archive/multiplexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/mongodb/mongo-tools/common/db"
"github.com/mongodb/mongo-tools/common/intents"
"github.com/mongodb/mongo-tools/common/log"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)

// bufferSize enables or disables the MuxIn buffering
Expand Down
2 changes: 1 addition & 1 deletion common/archive/multiplexer_roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/mongodb/mongo-tools/common/testtype"
. "github.com/smartystreets/goconvey/convey"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)

const testDocCount = 10000
Expand Down
2 changes: 1 addition & 1 deletion common/archive/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/mongodb/mongo-tools/common/testtype"
. "github.com/smartystreets/goconvey/convey"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)

type testConsumer struct {
Expand Down
2 changes: 1 addition & 1 deletion common/archive/prelude.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/mongodb/mongo-tools/common/intents"
"github.com/mongodb/mongo-tools/common/log"
"github.com/mongodb/mongo-tools/common/util"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)

// MetadataFile implements intents.file.
Expand Down
2 changes: 1 addition & 1 deletion common/archive/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"hash/crc64"

"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/v2/bson"
)

// SimpleArchive represents an entire archive. This is useful for synthesizing
Expand Down
4 changes: 2 additions & 2 deletions common/auth/auth_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

"github.com/mongodb/mongo-tools/common/db"
"github.com/mongodb/mongo-tools/common/util"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
)

// GetAuthVersion gets the authentication schema version of the connected server
Expand Down
42 changes: 25 additions & 17 deletions common/bsonutil/bsonutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import (
"github.com/mongodb/mongo-tools/common/json"
"github.com/mongodb/mongo-tools/common/util"
errors2 "github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/v2/bson"
)

var ErrNoSuchField = errors.New("no such field")
Expand Down Expand Up @@ -165,6 +164,15 @@ func RemoveKey(key string, document *bson.D) (interface{}, bool) {
return nil, false
}

// ToMap converts a bson.D to a bson.M.
func ToMap(in bson.D) bson.M {
m := make(bson.M, len(in))
for _, e := range in {
m[e.Key] = e.Value
}
return m
}

// ParseSpecialKeys takes a JSON document and inspects it for any extended JSON
// type (e.g $numberLong) and replaces any such values with the corresponding
// BSON type. (uses legacy extJSON parser).
Expand All @@ -173,7 +181,7 @@ func ParseSpecialKeys(special interface{}) (interface{}, error) {
var doc map[string]interface{}
switch v := special.(type) {
case bson.D:
doc = v.Map()
doc = ToMap(v)
case map[string]interface{}:
doc = v
default:
Expand All @@ -187,7 +195,7 @@ func ParseSpecialKeys(special interface{}) (interface{}, error) {
case string:
return util.FormatDate(v)
case bson.D:
asMap := v.Map()
asMap := ToMap(v)
if jsonValue, ok := asMap["$numberLong"]; ok {
n, err := parseNumberLongField(jsonValue)
if err != nil {
Expand Down Expand Up @@ -229,7 +237,7 @@ func ParseSpecialKeys(special interface{}) (interface{}, error) {
if jsonValue, ok := doc["$code"]; ok {
switch v := jsonValue.(type) {
case string:
return primitive.JavaScript(v), nil
return bson.JavaScript(v), nil
default:
return nil, errors.New("expected $code field to have string value")
}
Expand All @@ -238,7 +246,7 @@ func ParseSpecialKeys(special interface{}) (interface{}, error) {
if jsonValue, ok := doc["$oid"]; ok {
switch v := jsonValue.(type) {
case string:
return primitive.ObjectIDFromHex(v)
return bson.ObjectIDFromHex(v)
default:
return nil, errors.New("expected $oid field to have string value")
}
Expand Down Expand Up @@ -268,7 +276,7 @@ func ParseSpecialKeys(special interface{}) (interface{}, error) {
case map[string]interface{}:
tsDoc = internalDoc
case bson.D:
tsDoc = internalDoc.Map()
tsDoc = ToMap(internalDoc)
default:
return nil, errors.New("expected $timestamp key to have internal document")
}
Expand All @@ -292,36 +300,36 @@ func ParseSpecialKeys(special interface{}) (interface{}, error) {
return nil, errors.New("expected $timestamp to have 'i' field")
}
// see BSON spec for details on the bit fiddling here
return primitive.Timestamp{T: ts.Seconds, I: ts.Increment}, nil
return bson.Timestamp{T: ts.Seconds, I: ts.Increment}, nil
}

if jsonValue, ok := doc["$numberDecimal"]; ok {
switch v := jsonValue.(type) {
case string:
return primitive.ParseDecimal128(v)
return bson.ParseDecimal128(v)
default:
return nil, errors.New("expected $numberDecimal field to have string value")
}
}

if _, ok := doc["$undefined"]; ok {
return primitive.Undefined{}, nil
return bson.Undefined{}, nil
}

if _, ok := doc["$maxKey"]; ok {
return primitive.MaxKey{}, nil
return bson.MaxKey{}, nil
}

if _, ok := doc["$minKey"]; ok {
return primitive.MinKey{}, nil
return bson.MinKey{}, nil
}

case 2: // document has two fields
if jsonValue, ok := doc["$code"]; ok {
code := primitive.CodeWithScope{}
code := bson.CodeWithScope{}
switch v := jsonValue.(type) {
case string:
code.Code = primitive.JavaScript(v)
code.Code = bson.JavaScript(v)
default:
return nil, errors.New("expected $code field to have string value")
}
Expand All @@ -344,7 +352,7 @@ func ParseSpecialKeys(special interface{}) (interface{}, error) {
}

if jsonValue, ok := doc["$regex"]; ok {
regex := primitive.Regex{}
regex := bson.Regex{}

switch pattern := jsonValue.(type) {
case string:
Expand Down Expand Up @@ -378,7 +386,7 @@ func ParseSpecialKeys(special interface{}) (interface{}, error) {
}

if jsonValue, ok := doc["$binary"]; ok {
binary := primitive.Binary{}
binary := bson.Binary{}

switch data := jsonValue.(type) {
case string:
Expand Down Expand Up @@ -454,7 +462,7 @@ func Bson2Float64(data interface{}) (float64, bool) {
return float64(v), true
case float64:
return v, true
case primitive.Decimal128:
case bson.Decimal128:
if bi, _, err := v.BigInt(); err == nil {
intVal := bi.Int64()
return float64(intVal), true
Expand Down
Loading