Skip to content

Commit f9f8312

Browse files
authored
Merge pull request #2 from mongodb/release/1.17
Release/1.17
2 parents 7118ed2 + 7d03307 commit f9f8312

File tree

106 files changed

+10651
-2832
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+10651
-2832
lines changed

.evergreen/config.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,17 @@ functions:
615615
bash etc/run_docker.sh
616616
TOPOLOGY=sharded_cluster bash etc/run_docker.sh test-short
617617
618+
run-goleak-test:
619+
- command: shell.exec
620+
type: test
621+
params:
622+
shell: "bash"
623+
working_dir: src/go.mongodb.org/mongo-driver
624+
include_expansions_in_env: ["MONGODB_URI"]
625+
script: |
626+
${PREPARE_SHELL}
627+
bash etc/run-goleak-test.sh
628+
618629
run-valid-ocsp-server:
619630
- command: shell.exec
620631
params:
@@ -1420,6 +1431,26 @@ tasks:
14201431
- func: bootstrap-mongo-orchestration
14211432
- func: run-docker-test
14221433

1434+
- name: test-goroutine-leaks-replicaset
1435+
tags: ["goleak"]
1436+
commands:
1437+
- func: bootstrap-mongo-orchestration
1438+
vars:
1439+
TOPOLOGY: "replica_set"
1440+
AUTH: "noauth"
1441+
SSL: "nossl"
1442+
- func: run-goleak-test
1443+
1444+
- name: test-goroutine-leaks-sharded
1445+
tags: ["goleak"]
1446+
commands:
1447+
- func: bootstrap-mongo-orchestration
1448+
vars:
1449+
TOPOLOGY: "sharded_cluster"
1450+
AUTH: "noauth"
1451+
SSL: "nossl"
1452+
- func: run-goleak-test
1453+
14231454
- name: test-load-balancer-noauth-nossl
14241455
tags: ["load-balancer"]
14251456
commands:
@@ -2539,6 +2570,16 @@ buildvariants:
25392570
tasks:
25402571
- name: "test-docker-runner"
25412572

2573+
- name: goroutine-leaks-test
2574+
tags: ["pullrequest"]
2575+
display_name: "Goroutine Leaks Test"
2576+
run_on:
2577+
- ubuntu2204-large
2578+
expansions:
2579+
GO_DIST: "/opt/golang/go1.22"
2580+
tasks:
2581+
- name: ".goleak"
2582+
25422583
- matrix_name: "tests-rhel-36-with-zlib-support"
25432584
tags: ["pullrequest"]
25442585
matrix_spec: { version: ["3.6"], os-ssl-32: ["rhel87-64"] }

.evergreen/run-fuzz.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ do
3535
done
3636
fi
3737

38-
go test ${PARENTDIR} -run=${FUNC} -fuzz=${FUNC} -fuzztime=${FUZZTIME} || true
38+
GOMAXPROCS=2 go test ${PARENTDIR} -run=${FUNC} -fuzz=${FUNC} -fuzztime=${FUZZTIME} || true
3939

4040
# Check if any new corpus files were generated for the fuzzer. If there are new corpus files, move them
4141
# to $PROJECT_DIRECTORY/fuzz/$FUNC/* so they can be tarred up and uploaded to S3.

.github/reviewers.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
qingyang-hu
22
matthewdale
33
prestonvasquez
4-
blink1073

.github/workflows/merge-up.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Merge up
2+
3+
on:
4+
push:
5+
branches:
6+
- release/*.*
7+
- v*
8+
9+
permissions:
10+
id-token: write
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
merge-up:
16+
name: Create merge up pull request
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
21+
with:
22+
app_id: ${{ vars.PR_APP_ID }}
23+
private_key: ${{ secrets.PR_APP_PRIVATE_KEY }}
24+
# Make sure to include fetch-depth 0 so all branches are fetched, not
25+
# just the current one
26+
fetch-depth: 0
27+
28+
- name: Create pull request
29+
id: create-pull-request
30+
uses: alcaeus/automatic-merge-up-action@main
31+
with:
32+
ref: ${{ github.ref_name }}
33+
branchNamePattern: 'release/<major>.<minor>'
34+
devBranchNamePattern: 'v<major>'
35+
fallbackBranch: 'master'
36+
enableAutoMerge: true

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ repos:
5151
exclude: ^(vendor)
5252

5353
- repo: https://github.com/golangci/golangci-lint
54-
rev: v1.59.1
54+
rev: v1.60.1
5555
hooks:
5656
- id: golangci-lint

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fmt:
7272

7373
.PHONY: install-golangci-lint
7474
install-golangci-lint:
75-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1
75+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1
7676

7777
# Lint with various GOOS and GOARCH targets to catch static analysis failures that may only affect
7878
# specific operating systems or architectures. For example, staticcheck will only check for 64-bit
@@ -106,7 +106,7 @@ test-race:
106106

107107
.PHONY: test-short
108108
test-short:
109-
go test $(BUILD_TAGS) -timeout 60s -short ./...
109+
go test $(BUILD_TAGS) -timeout 60s -short -race ./...
110110

111111
### Local FaaS targets. ###
112112
.PHONY: build-faas-awslambda

bson/bson_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"go.mongodb.org/mongo-driver/bson/bsoncodec"
2020
"go.mongodb.org/mongo-driver/bson/bsonoptions"
2121
"go.mongodb.org/mongo-driver/bson/bsontype"
22+
"go.mongodb.org/mongo-driver/bson/primitive"
2223
"go.mongodb.org/mongo-driver/internal/assert"
2324
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
2425
)
@@ -226,11 +227,20 @@ func TestMapCodec(t *testing.T) {
226227
}
227228

228229
func TestExtJSONEscapeKey(t *testing.T) {
229-
doc := D{{Key: "\\usb#", Value: int32(1)}}
230+
doc := D{
231+
{
232+
Key: "\\usb#",
233+
Value: int32(1),
234+
},
235+
{
236+
Key: "regex",
237+
Value: primitive.Regex{Pattern: "ab\\\\\\\"ab", Options: "\""},
238+
},
239+
}
230240
b, err := MarshalExtJSON(&doc, false, false)
231241
noerr(t, err)
232242

233-
want := "{\"\\\\usb#\":1}"
243+
want := `{"\\usb#":1,"regex":{"$regularExpression":{"pattern":"ab\\\\\\\"ab","options":"\""}}}`
234244
if diff := cmp.Diff(want, string(b)); diff != "" {
235245
t.Errorf("Marshaled documents do not match. got %v, want %v", string(b), want)
236246
}

bson/bsoncodec/default_value_decoders.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,18 @@ func (dvd DefaultValueDecoders) ValueUnmarshalerDecodeValue(_ DecodeContext, vr
15211521
return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val}
15221522
}
15231523

1524+
// If BSON value is null and the go value is a pointer, then don't call
1525+
// UnmarshalBSONValue. Even if the Go pointer is already initialized (i.e.,
1526+
// non-nil), encountering null in BSON will result in the pointer being
1527+
// directly set to nil here. Since the pointer is being replaced with nil,
1528+
// there is no opportunity (or reason) for the custom UnmarshalBSONValue logic
1529+
// to be called.
1530+
if vr.Type() == bsontype.Null && val.Kind() == reflect.Ptr {
1531+
val.Set(reflect.Zero(val.Type()))
1532+
1533+
return vr.ReadNull()
1534+
}
1535+
15241536
if val.Kind() == reflect.Ptr && val.IsNil() {
15251537
if !val.CanSet() {
15261538
return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val}

bson/bsonrw/extjson_writer.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,13 @@ func (ejvw *extJSONValueWriter) WriteRegex(pattern string, options string) error
468468
return err
469469
}
470470

471+
options = sortStringAlphebeticAscending(options)
471472
var buf bytes.Buffer
472473
buf.WriteString(`{"$regularExpression":{"pattern":`)
473474
writeStringWithEscapes(pattern, &buf, ejvw.escapeHTML)
474-
buf.WriteString(`,"options":"`)
475-
buf.WriteString(sortStringAlphebeticAscending(options))
476-
buf.WriteString(`"}},`)
475+
buf.WriteString(`,"options":`)
476+
writeStringWithEscapes(options, &buf, ejvw.escapeHTML)
477+
buf.WriteString(`}},`)
477478

478479
ejvw.buf = append(ejvw.buf, buf.Bytes()...)
479480

bson/unmarshal.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ type ValueUnmarshaler interface {
4141
// Unmarshal parses the BSON-encoded data and stores the result in the value
4242
// pointed to by val. If val is nil or not a pointer, Unmarshal returns
4343
// InvalidUnmarshalError.
44+
//
45+
// When unmarshaling BSON, if the BSON value is null and the Go value is a
46+
// pointer, the pointer is set to nil without calling UnmarshalBSONValue.
4447
func Unmarshal(data []byte, val interface{}) error {
4548
return UnmarshalWithRegistry(DefaultRegistry, data, val)
4649
}

bson/unmarshal_value_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"go.mongodb.org/mongo-driver/bson/bsoncodec"
1515
"go.mongodb.org/mongo-driver/bson/bsontype"
1616
"go.mongodb.org/mongo-driver/internal/assert"
17+
"go.mongodb.org/mongo-driver/internal/require"
1718
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
1819
)
1920

@@ -93,6 +94,29 @@ func TestUnmarshalValue(t *testing.T) {
9394
})
9495
}
9596

97+
func TestInitializedPointerDataWithBSONNull(t *testing.T) {
98+
// Set up the test case with initialized pointers.
99+
tc := unmarshalBehaviorTestCase{
100+
BSONValuePtrTracker: &unmarshalBSONValueCallTracker{},
101+
BSONPtrTracker: &unmarshalBSONCallTracker{},
102+
}
103+
104+
// Create BSON data where the '*_ptr_tracker' fields are explicitly set to
105+
// null.
106+
bytes := docToBytes(D{
107+
{Key: "bv_ptr_tracker", Value: nil},
108+
{Key: "b_ptr_tracker", Value: nil},
109+
})
110+
111+
// Unmarshal the BSON data into the test case struct. This should set the
112+
// pointer fields to nil due to the BSON null value.
113+
err := Unmarshal(bytes, &tc)
114+
require.NoError(t, err)
115+
116+
assert.Nil(t, tc.BSONValuePtrTracker)
117+
assert.Nil(t, tc.BSONPtrTracker)
118+
}
119+
96120
// tests covering GODRIVER-2779
97121
func BenchmarkSliceCodecUnmarshal(b *testing.B) {
98122
benchmarks := []struct {

0 commit comments

Comments
 (0)