Skip to content

Commit 883ad72

Browse files
authored
Merge pull request #943 from percona/release-2.5.0
Release 2.5.0
2 parents 883fd63 + 0d1a4ce commit 883ad72

File tree

919 files changed

+45958
-28544
lines changed

Some content is hidden

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

919 files changed

+45958
-28544
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727

2828
jobs:
2929
test:
30-
runs-on: ubuntu-20.04
30+
runs-on: ubuntu-latest
3131
timeout-minutes: 120
3232
strategy:
3333
fail-fast: false
@@ -36,30 +36,30 @@ jobs:
3636
test: [logical, physical, incremental, external]
3737
env:
3838
PBM_BRANCH: ${{ github.event.inputs.pbm_branch || 'main' }}
39-
GO_VER: ${{ github.event.inputs.go_ver || '1.19-bullseye' }}
39+
GO_VER: ${{ github.event.inputs.go_ver || 'bullseye' }}
4040
PR_NUMBER: ${{ github.event.number|| github.event.inputs.pr_ver }}
4141

4242
steps:
4343
- name: Checkout testing repo
44-
uses: actions/checkout@v3
44+
uses: actions/checkout@v4
4545
with:
4646
repository: Percona-QA/psmdb-testing
4747
ref: ${{ github.event.inputs.tests_ver || 'main'}}
4848
path: psmdb-testing
4949

5050
- name: Setup environment with PSMDB ${{ matrix.psmdb }} for PBM PR/branch ${{ github.event.pull_request.title || env.PR_NUMBER || env.PBM_BRANCH }}
5151
run: |
52-
PSMDB=percona/percona-server-mongodb:${{ matrix.psmdb }} docker-compose build
53-
docker-compose up -d
52+
PSMDB=percona/percona-server-mongodb:${{ matrix.psmdb }} docker compose build
53+
docker compose up -d
5454
working-directory: psmdb-testing/pbm-functional/pytest
5555

5656
- name: Test ${{ matrix.test }} backup/restore on PSMDB ${{ matrix.psmdb }} for PBM PR/branch ${{ github.event.pull_request.title || env.PR_NUMBER || env.PBM_BRANCH }}
5757
run: |
58-
docker-compose run test pytest -s --junitxml=junit.xml -k ${{ matrix.test }}
58+
docker compose run test pytest -s --junitxml=junit.xml -k ${{ matrix.test }}
5959
working-directory: psmdb-testing/pbm-functional/pytest
6060

6161
- name: Publish Test Report
62-
uses: mikepenz/action-junit-report@v3
62+
uses: mikepenz/action-junit-report@v4
6363
if: success() || failure()
6464
with:
6565
report_paths: "**/junit.xml"

.github/workflows/reviewdog.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@ jobs:
55
name: runner / go-test
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v3
8+
- uses: actions/checkout@v4
99
- uses: actions/setup-go@v4
1010
with:
11-
go-version: "1.19"
11+
go-version: "1.22"
1212
- name: test
1313
run: go test -v ./...
1414

1515
shellcheck:
1616
name: runner / shellcheck
1717
runs-on: ubuntu-latest
18+
if: ${{ github.event.pull_request.changed_files < 301 }}
1819
steps:
19-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2021
- name: spellcheck
2122
uses: reviewdog/action-shellcheck@v1
2223
with:
@@ -30,8 +31,9 @@ jobs:
3031
misspell:
3132
name: runner / misspell
3233
runs-on: ubuntu-latest
34+
if: ${{ github.event.pull_request.changed_files < 301 }}
3335
steps:
34-
- uses: actions/checkout@v3
36+
- uses: actions/checkout@v4
3537
- name: misspell
3638
uses: reviewdog/action-misspell@v1
3739
with:
@@ -45,8 +47,9 @@ jobs:
4547
alex:
4648
name: runner / alex
4749
runs-on: ubuntu-latest
50+
if: ${{ github.event.pull_request.changed_files < 301 }}
4851
steps:
49-
- uses: actions/checkout@v3
52+
- uses: actions/checkout@v4
5053
- name: alex
5154
uses: reviewdog/action-alex@v1
5255
with:
@@ -56,10 +59,10 @@ jobs:
5659
name: runner / golangci-lint
5760
runs-on: ubuntu-latest
5861
steps:
59-
- uses: actions/checkout@v3
62+
- uses: actions/checkout@v4
6063
- uses: actions/setup-go@v4
6164
with:
62-
go-version: "1.19"
65+
go-version: "1.22"
6366
- name: golangci-lint
6467
uses: reviewdog/action-golangci-lint@v2
6568
with:
@@ -70,12 +73,12 @@ jobs:
7073
name: runner / gofmt
7174
runs-on: ubuntu-latest
7275
steps:
73-
- uses: actions/checkout@v3
76+
- uses: actions/checkout@v4
7477
- uses: actions/setup-go@v4
7578
with:
76-
go-version: "1.19"
79+
go-version: "1.22"
7780
- run: go install golang.org/x/tools/cmd/goimports@latest
78-
- run: go install mvdan.cc/gofumpt@v0.5.0
81+
- run: go install mvdan.cc/gofumpt@latest
7982
- run: goimports -w -local "github.com/percona" $(find . -not -path "*/vendor/*" -name "*.go")
8083
- run: gofumpt -w -extra $(find . -not -path "*/vendor/*" -name "*.go")
8184
- uses: reviewdog/action-suggester@v1
@@ -86,10 +89,10 @@ jobs:
8689
name: runner / shfmt
8790
runs-on: ubuntu-latest
8891
steps:
89-
- uses: actions/checkout@v3
92+
- uses: actions/checkout@v4
9093
- uses: actions/setup-go@v4
9194
with:
92-
go-version: "1.19"
95+
go-version: "1.22"
9396
- run: go install mvdan.cc/sh/v3/cmd/shfmt@latest
9497
- run: shfmt -f . | grep -v 'vendor' | xargs shfmt -w -s
9598
- name: suggester / shfmt

.github/workflows/trivy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout code
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414

1515
- name: Run Trivy vulnerability scanner in repo mode
1616
uses: aquasecurity/trivy-action@master

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @defbin
1+
* @defbin @boris-ilijic

cmd/pbm-agent/agent.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,33 @@ type Agent struct {
4646
}
4747

4848
func newAgent(ctx context.Context, leadConn connect.Client, uri string, dumpConns int) (*Agent, error) {
49-
m, err := connect.MongoConnect(ctx, uri, &connect.MongoConnectOptions{Direct: true})
49+
nodeConn, err := connect.MongoConnect(ctx, uri, connect.Direct(true))
5050
if err != nil {
5151
return nil, err
5252
}
5353

54-
info, err := topo.GetNodeInfo(ctx, m)
54+
info, err := topo.GetNodeInfo(ctx, nodeConn)
5555
if err != nil {
5656
return nil, errors.Wrap(err, "get node info")
5757
}
5858

59-
mongoVersion, err := version.GetMongoVersion(ctx, m)
59+
mongoVersion, err := version.GetMongoVersion(ctx, nodeConn)
6060
if err != nil {
6161
return nil, errors.Wrap(err, "get mongo version")
6262
}
6363

6464
a := &Agent{
6565
leadConn: leadConn,
6666
closeCMD: make(chan struct{}),
67+
nodeConn: nodeConn,
68+
brief: topo.NodeBrief{
69+
URI: uri,
70+
SetName: info.SetName,
71+
Me: info.Me,
72+
},
73+
mongoVersion: mongoVersion,
74+
dumpConns: dumpConns,
6775
}
68-
a.nodeConn = m
69-
a.brief = topo.NodeBrief{
70-
URI: uri,
71-
SetName: info.SetName,
72-
Me: info.Me,
73-
}
74-
a.mongoVersion = mongoVersion
75-
a.dumpConns = dumpConns
7676
return a, nil
7777
}
7878

@@ -103,6 +103,9 @@ func (a *Agent) Start(ctx context.Context) error {
103103
logger := log.FromContext(ctx)
104104
logger.Printf("pbm-agent:\n%s", version.Current().All(""))
105105
logger.Printf("node: %s/%s", a.brief.SetName, a.brief.Me)
106+
logger.Printf("conn level ReadConcern: %v; WriteConcern: %v",
107+
a.leadConn.MongoOptions().ReadConcern.Level,
108+
a.leadConn.MongoOptions().WriteConcern.W)
106109

107110
c, cerr := ctrl.ListenCmd(ctx, a.leadConn, a.closeCMD)
108111

cmd/pbm-agent/delete.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ func deleteChunks(ctx context.Context, m connect.Client, stg storage.Storage, ch
336336
{"end_ts", chnk.EndTS},
337337
},
338338
)
339-
340339
if err != nil {
341340
return errors.Wrap(err, "delete pitr chunk metadata")
342341
}

cmd/pbm-agent/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func runAgent(mongoURI string, dumpConns int) error {
8686
ctx, cancel := context.WithCancel(context.Background())
8787
defer cancel()
8888

89-
leadConn, err := connect.Connect(ctx, mongoURI, &connect.ConnectOptions{AppName: "pbm-agent"})
89+
leadConn, err := connect.Connect(ctx, mongoURI, "pbm-agent")
9090
if err != nil {
9191
return errors.Wrap(err, "connect to PBM")
9292
}

cmd/pbm-speed-test/b_test.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

cmd/pbm-speed-test/main.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import (
44
"context"
55
"fmt"
66
stdlog "log"
7-
"math/rand"
87
"os"
98
"time"
109

1110
"github.com/alecthomas/kingpin"
12-
"go.mongodb.org/mongo-driver/bson/primitive"
1311
"go.mongodb.org/mongo-driver/mongo"
1412

1513
"github.com/percona/percona-backup-mongodb/pbm/compress"
@@ -63,8 +61,6 @@ func main() {
6361
*sampleSizeF = 1
6462
}
6563

66-
rand.Seed(time.Now().UnixNano())
67-
6864
switch cmd {
6965
case compressionCmd.FullCommand():
7066
fmt.Print("Test started ")
@@ -90,7 +86,7 @@ func testCompression(mURL string, compression compress.CompressionType, level *i
9086
var cn *mongo.Client
9187

9288
if collection != "" {
93-
cn, err := connect.MongoConnect(ctx, mURL, &connect.MongoConnectOptions{Direct: true})
89+
cn, err := connect.MongoConnect(ctx, mURL, connect.Direct(true))
9490
if err != nil {
9591
stdlog.Fatalln("Error: connect to mongodb-node:", err)
9692
}
@@ -112,23 +108,19 @@ func testCompression(mURL string, compression compress.CompressionType, level *i
112108
}
113109

114110
func testStorage(mURL string, compression compress.CompressionType, level *int, sizeGb float64, collection string) {
115-
ctx := context.Background()
116-
117-
sess, err := connect.MongoConnect(ctx, mURL, &connect.MongoConnectOptions{Direct: true})
111+
sess, err := connect.MongoConnect(context.Background(), mURL, connect.Direct(true))
118112
if err != nil {
119113
stdlog.Fatalln("Error: connect to mongodb-node:", err)
120114
}
121-
defer sess.Disconnect(ctx) //nolint:errcheck
115+
defer sess.Disconnect(context.Background()) //nolint:errcheck
122116

123-
client, err := connect.Connect(ctx, mURL, &connect.ConnectOptions{AppName: "pbm-speed-test"})
117+
client, err := connect.Connect(context.Background(), mURL, "pbm-speed-test")
124118
if err != nil {
125119
stdlog.Fatalln("Error: connect to mongodb-pbm:", err)
126120
}
127-
defer client.Disconnect(ctx) //nolint:errcheck
121+
defer client.Disconnect(context.Background()) //nolint:errcheck
128122

129-
l := log.FromContext(ctx).
130-
NewEvent("", "", "", primitive.Timestamp{})
131-
stg, err := util.GetStorage(ctx, client, l)
123+
stg, err := util.GetStorage(context.Background(), client, log.DiscardEvent)
132124
if err != nil {
133125
stdlog.Fatalln("Error: get storage:", err)
134126
}

cmd/pbm-speed-test/speedt.go

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ import (
44
"context"
55
"fmt"
66
"io"
7-
"reflect"
87
"strings"
98
"time"
10-
"unsafe"
11-
12-
"github.com/percona/percona-backup-mongodb/pbm/compress"
139

1410
"go.mongodb.org/mongo-driver/bson"
1511
"go.mongodb.org/mongo-driver/mongo"
1612

13+
"github.com/percona/percona-backup-mongodb/pbm/compress"
1714
"github.com/percona/percona-backup-mongodb/pbm/errors"
18-
1915
"github.com/percona/percona-backup-mongodb/pbm/storage"
2016
)
2117

@@ -54,20 +50,25 @@ func (b Byte) String() string {
5450
}
5551

5652
type Rand struct {
57-
size Byte
53+
size Byte
54+
dataset [][]byte
5855
}
5956

6057
func NewRand(size Byte) *Rand {
6158
r := &Rand{
62-
size: size,
59+
size: size,
60+
dataset: make([][]byte, len(dataset)),
61+
}
62+
for i, s := range dataset {
63+
r.dataset[i] = []byte(s)
6364
}
6465
return r
6566
}
6667

6768
func (r *Rand) WriteTo(w io.Writer) (int64, error) {
6869
var written int64
6970
for i := 0; written < int64(r.size); i++ {
70-
n, err := w.Write(StringToBytes(dataset[i%len(dataset)]))
71+
n, err := w.Write(r.dataset[i%len(dataset)])
7172
if err != nil {
7273
return written, err
7374
}
@@ -87,10 +88,11 @@ func NewCollection(size Byte, cn *mongo.Client, namespace string) (*Collection,
8788
return nil, errors.New("namespace should be in format `database.collection`")
8889
}
8990

90-
return &Collection{
91+
r := &Collection{
9192
size: size,
9293
c: cn.Database(ns[0]).Collection(ns[1]),
93-
}, nil
94+
}
95+
return r, nil
9496
}
9597

9698
func (c *Collection) WriteTo(w io.Writer) (int64, error) {
@@ -104,7 +106,7 @@ func (c *Collection) WriteTo(w io.Writer) (int64, error) {
104106

105107
var written int64
106108
for cur.Next(ctx) {
107-
n, err := w.Write([]byte(cur.Current))
109+
n, err := w.Write(cur.Current)
108110
if err != nil {
109111
return written, errors.Wrap(err, "write")
110112
}
@@ -149,11 +151,3 @@ func doTest(
149151

150152
return r, nil
151153
}
152-
153-
// StringToBytes converts given string to the slice of bytes
154-
// without allocations
155-
func StringToBytes(s string) []byte {
156-
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
157-
bh := reflect.SliceHeader{sh.Data, sh.Len, sh.Len}
158-
return *(*[]byte)(unsafe.Pointer(&bh)) //nolint:govet
159-
}

0 commit comments

Comments
 (0)