Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-picks for 2.10.23-RC.11 #6222

Merged
merged 6 commits into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ module github.com/nats-io/nats-server/v2
go 1.21.0

require (
github.com/goccy/go-json v0.10.3
github.com/klauspost/compress v1.17.11
github.com/minio/highwayhash v1.0.3
github.com/nats-io/jwt/v2 v2.5.8
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q=
4 changes: 2 additions & 2 deletions server/accounts_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2024 The NATS Authors
// Copyright 2018-2023 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -15,6 +15,7 @@ package server

import (
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"strconv"
@@ -24,7 +25,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
"github.com/nats-io/nkeys"
4 changes: 2 additions & 2 deletions server/auth_callout_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2024 The NATS Authors
// Copyright 2022-2023 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -16,6 +16,7 @@ package server
import (
"bytes"
"crypto/x509"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
@@ -28,7 +29,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
"github.com/nats-io/nkeys"
2 changes: 1 addition & 1 deletion server/auth_test.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ package server

import (
"context"
"encoding/json"
"fmt"
"net"
"net/url"
@@ -24,7 +25,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
)
2 changes: 1 addition & 1 deletion server/certidp/certidp.go
Original file line number Diff line number Diff line change
@@ -17,12 +17,12 @@ import (
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/json"
"fmt"
"net/url"
"strings"
"time"

"github.com/goccy/go-json"
"golang.org/x/crypto/ocsp"
)

2 changes: 1 addition & 1 deletion server/client.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import (
"bytes"
"crypto/tls"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"io"
@@ -32,7 +33,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/klauspost/compress/s2"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats-server/v2/internal/fastrand"
7 changes: 4 additions & 3 deletions server/client_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012-2024 The NATS Authors
// Copyright 2012-2022 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -16,7 +16,7 @@ package server
import (
"bufio"
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"math"
@@ -31,7 +31,8 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"crypto/tls"

"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
"github.com/nats-io/nkeys"
2 changes: 1 addition & 1 deletion server/consumer.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package server
import (
"bytes"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"math/rand"
@@ -27,7 +28,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/nats-server/v2/server/avl"
"github.com/nats-io/nuid"
"golang.org/x/time/rate"
3 changes: 2 additions & 1 deletion server/events.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import (
"compress/gzip"
"crypto/sha256"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"math/rand"
@@ -29,8 +30,8 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/klauspost/compress/s2"

"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats-server/v2/server/certidp"
"github.com/nats-io/nats-server/v2/server/pse"
2 changes: 1 addition & 1 deletion server/events_test.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ package server
import (
"bytes"
"crypto/sha256"
"encoding/json"
"errors"
"fmt"
"math/rand"
@@ -29,7 +30,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
"github.com/nats-io/nkeys"
6 changes: 4 additions & 2 deletions server/filestore.go
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ import (
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"hash"
@@ -39,7 +40,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/klauspost/compress/s2"
"github.com/minio/highwayhash"
"github.com/nats-io/nats-server/v2/server/avl"
@@ -8157,8 +8157,10 @@ func (fs *fileStore) flushStreamStateLoop(qch, done chan struct{}) {
defer close(done)

// Make sure we do not try to write these out too fast.
// Spread these out for large numbers on a server restart.
const writeThreshold = 2 * time.Minute
t := time.NewTicker(writeThreshold)
writeJitter := time.Duration(mrand.Int63n(int64(30 * time.Second)))
t := time.NewTicker(writeThreshold + writeJitter)
defer t.Stop()

for {
4 changes: 3 additions & 1 deletion server/filestore_test.go
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ import (
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io"
@@ -38,7 +39,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/klauspost/compress/s2"
"github.com/nats-io/nuid"
)
@@ -1483,6 +1483,8 @@ func TestFileStoreMeta(t *testing.T) {
if err := json.Unmarshal(buf, &oconfig2); err != nil {
t.Fatalf("Error unmarshalling: %v", err)
}
// Since we set name we will get that back now.
oconfig.Name = oname
if !reflect.DeepEqual(oconfig2, oconfig) {
t.Fatalf("Consumer configs not equal, got %+v vs %+v", oconfig2, oconfig)
}
3 changes: 1 addition & 2 deletions server/gateway.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import (
"cmp"
"crypto/sha256"
"crypto/tls"
"encoding/json"
"fmt"
"math/rand"
"net"
@@ -27,8 +28,6 @@ import (
"sync"
"sync/atomic"
"time"

"github.com/goccy/go-json"
)

const (
5 changes: 2 additions & 3 deletions server/gateway_test.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"fmt"
"net"
"net/url"
@@ -30,12 +31,10 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
. "github.com/nats-io/nats-server/v2/internal/ocsp"
"github.com/nats-io/nats-server/v2/logger"
"github.com/nats-io/nats.go"
"golang.org/x/crypto/ocsp"

. "github.com/nats-io/nats-server/v2/internal/ocsp"
)

func init() {
2 changes: 1 addition & 1 deletion server/jetstream.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import (
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"encoding/json"
"fmt"
"math"
"os"
@@ -29,7 +30,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/minio/highwayhash"
"github.com/nats-io/nats-server/v2/server/sysmem"
"github.com/nats-io/nkeys"
4 changes: 2 additions & 2 deletions server/jetstream_api.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2024 The NATS Authors
// Copyright 2020-2023 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -16,6 +16,7 @@ package server
import (
"bytes"
"cmp"
"encoding/json"
"errors"
"fmt"
"math/rand"
@@ -29,7 +30,6 @@ import (
"time"
"unicode"

"github.com/goccy/go-json"
"github.com/nats-io/nuid"
)

14 changes: 10 additions & 4 deletions server/jetstream_cluster.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import (
"cmp"
crand "crypto/rand"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"math"
@@ -31,7 +32,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/klauspost/compress/s2"
"github.com/minio/highwayhash"
"github.com/nats-io/nuid"
@@ -9099,20 +9099,26 @@ func (mset *stream) runCatchup(sendSubject string, sreq *streamSyncRequest) {
for ; seq <= last && atomic.LoadInt64(&outb) <= maxOutBytes && atomic.LoadInt32(&outm) <= maxOutMsgs && s.gcbBelowMax(); seq++ {
var sm *StoreMsg
var err error
// Is we should use load next do so here.
// If we should use load next do so here.
if useLoadNext {
var nseq uint64
sm, nseq, err = mset.store.LoadNextMsg(fwcs, true, seq, &smv)
if err == nil && nseq > seq {
// If we jumped over the requested last sequence, clamp it down.
// Otherwise, we would send too much to the follower.
if nseq > last {
nseq = last
sm = nil
}
dr.First, dr.Num = seq, nseq-seq
// Jump ahead
seq = nseq
} else if err == ErrStoreEOF {
dr.First, dr.Num = seq, state.LastSeq-seq
dr.First, dr.Num = seq, last-seq
// Clear EOF here for normal processing.
err = nil
// Jump ahead
seq = state.LastSeq
seq = last
}
} else {
sm, err = mset.store.LoadMsg(seq, &smv)
Loading