Commit Graph

6070 Commits

Author SHA1 Message Date
Derek Collison
8ae0757e91 Merge pull request #3320 from nats-io/kv_improvements
[IMPROVED] Speed of storing new keys with a large number of pre-existing keys.
2022-08-02 09:15:06 -07:00
Derek Collison
6450301cfc Improved speed of storing new messages when lots of messages are present in KV mode.
Signed-off-by: Derek Collison <derek@nats.io>
2022-08-01 14:02:19 -07:00
Derek Collison
903a06a5b4 Bump to 2.9.0-beta.17
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-31 11:44:15 -07:00
Ivan Kozlovic
b6b746095b Merge pull request #3315 from nats-io/fix_3313
[FIXED] MQTT: Possible panic when clients misbehave
2022-07-31 12:43:28 -06:00
Derek Collison
588a8fcca9 Merge pull request #3314 from nats-io/enc_dsnap_bug
[FIXED] Instability with encrypted systems
2022-07-31 11:43:17 -07:00
Ivan Kozlovic
6460519cf5 [FIXED] MQTT: Possible panic when clients misbehave
If a client with a given client ID is connected and while connected
another client tries to reuse the same client ID, the spec says that
the old client be closed and the new one accepted.
However, the server protects from this flapping happening all the time
by rejecting new clients that try to connect at a very fast pace.

However, the server was closing a misbehaving client after a second
delay (to prevent immediate reconnect if the client library does that)
but was not blocking the read loop and the compounding issue was that
if that misbehaving client is REALLY misbehaving and not waiting for
the CONNACK to send more protocols (for instance SUB) the server would
panic because the client was not fully configured.

To prevent that, the server will now "block" this misbehaving client
in its readLoop before closing the connection, preventing processing
of possible protocols that follow the CONNECT.

Resolves #3313

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-31 12:20:38 -06:00
Derek Collison
717969510d Make sure to reset block encryption counter when clearing block but holding state for tracking sequences.
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-31 07:59:19 -07:00
Derek Collison
8dc1e4b6de When compact would reclaim head of block space, we needed to update block key for counter for new writes.
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-30 13:05:41 -07:00
Ivan Kozlovic
32ffc0257b Merge pull request #3311 from nats-io/fix_nightly_docker
Replace "go get" with "go install"
2022-07-29 17:25:18 -06:00
Ivan Kozlovic
f397e15896 Replace "go get" with "go install"
[ci skip]

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-29 17:23:58 -06:00
Ivan Kozlovic
05a7aaff45 Merge pull request #3310 from nats-io/update_nightly_go_version
Update nightly to Go 1.18
2022-07-29 17:17:50 -06:00
Derek Collison
e4ef3e4b09 Bump to 2.9.0-beta.16
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-29 16:16:14 -07:00
Derek Collison
5dfa7dcb40 Merge pull request #3309 from nats-io/remove_panic
General stability improvements
2022-07-29 16:15:52 -07:00
Ivan Kozlovic
ab1b86ef96 Update nightly to Go 1.18
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-29 17:15:12 -06:00
Derek Collison
5e98263de8 General stability improvements
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-29 16:02:31 -07:00
Ivan Kozlovic
465db58b44 Merge pull request #3302 from bruth/update-max-waiting
[FIXED] Reject update of pull consumer MaxWaiting since it is not supported
2022-07-29 13:14:44 -06:00
Byron Ruth
095cfef9eb Add check and test to prevent updating consumer MaxWaiting
Signed-off-by: Byron Ruth <b@devel.io>
2022-07-29 15:05:00 -04:00
Derek Collison
8aee7d5e51 Bump to 2.9.0-beta.15
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-29 09:30:07 -07:00
Derek Collison
43871300a3 Merge pull request #3308 from nats-io/encrypt_updates
Encrypt meta and raft states.
2022-07-29 09:25:55 -07:00
Derek Collison
259d1a1b9e Merge pull request #3307 from nats-io/raft_improvements
Improvements to raft layer with snapshots on catchup.
2022-07-29 09:12:24 -07:00
Derek Collison
27d87a68a4 Improvements to raft layer with snapshots on catchup.
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-29 09:01:03 -07:00
Derek Collison
50a25881e2 Encrypt meta and raft states.
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-29 08:10:57 -07:00
Ivan Kozlovic
7bf34d8623 Merge pull request #3304 from nats-io/tls_check_for_compliant_on_macOS
Fixed TLS test so it passes on macOS
2022-07-28 18:23:08 -06:00
Ivan Kozlovic
746b44a020 Fixed TLS test so it passes on macOS
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-28 17:58:25 -06:00
Ivan Kozlovic
58a3b2040a Merge pull request #3303 from nats-io/revert_jnm_changes_to_main
Revert direct changes to main
2022-07-28 17:36:27 -06:00
Ivan Kozlovic
f19908979f Revert direct changes to main
This reverts commit cf784c19f0.
This reverts commit c269a1ca09.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-28 17:25:37 -06:00
jnmoyne
cf784c19f0 - Adds new subject mapping functions:
{{SplitFromLeft(wildcard index, position)}}
{{SplitFromRight(wildcard index, position)}}
{{SliceFromLeft(wildcard index, slice size)}}
{{SliceFromRight(wildcard index, slice size)}}
{{Split(wildcard index, deliminator)}}

Examples:
	shouldMatch("*", "{{splitfromleft(1,3)}}", "12345", "123.45")
	shouldMatch("*", "{{SplitFromRight(1,3)}}", "12345", "12.345")
	shouldMatch("*", "{{SliceFromLeft(1,3)}}", "1234567890", "123.456.789.0")
	shouldMatch("*", "{{SliceFromRight(1,3)}}", "1234567890", "1.234.567.890")
	shouldMatch("*", "{{split(1,-)}}", "-abc-def--ghi-", "abc.def.ghi")
	shouldMatch("*.*", "{{split(2,-)}}.{{splitfromleft(1,2)}}", "foo.-abc-def--ghij-", "abc.def.ghij.fo.o")

- Subject mapping functions can now be all lower case or Pascal case (or a combination): e.g. splitfromleft, SplitFromLeft, splitFromleft, etc...
2022-07-28 12:53:14 -07:00
jnmoyne
c269a1ca09 New expendable implementation of subject mapping destinations to transform processing 2022-07-28 12:30:22 -07:00
Ivan Kozlovic
6631bf7bd7 Merge pull request #3300 from nats-io/pdp/certs-reissuance
Test-data certs reissuance (SHA1 -> SHA256)
2022-07-28 10:43:54 -06:00
Derek Collison
4b9e94d4a1 Merge pull request #3301 from nats-io/update_tests
Update tests to check last sequence state
2022-07-28 09:36:42 -07:00
Ivan Kozlovic
427e52dba2 Removed export GODEBUG="x509sha1=1" from runTestsOnTravis.sh
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-28 09:19:57 -06:00
Derek Collison
e120bb86a9 Update tests to check last seq
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-28 07:23:39 -07:00
Phil Pennock
e38419e09e testdata: regenerate X509 certs with new script 2022-07-28 02:52:56 -04:00
Phil Pennock
3f760760de test data: x509 cert reissuance script
We had some certs which used SHA1 still; this top-level script is a bit rough,
but works to recreate all the top-level certs, using a common CA.

RSA 2048 bits with SHA256.

I've put the IPv6 localhost IP into the certs too, wherever the IPv4 localhost
IP was present, as this might improve test-runner resilience in some
situations.  Seems like a good idea, can't think of a reason not to.
2022-07-28 02:52:36 -04:00
Ivan Kozlovic
725c1949e6 Bump version to 2.9.0-beta.14
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-27 19:06:12 -06:00
Ivan Kozlovic
258bd4240b Merge pull request #3297 from nats-io/js_fix_panic
Fixed a panic when consumer is closed
2022-07-27 18:50:53 -06:00
Ivan Kozlovic
5786d2d9d6 Changed "return" to "continue"
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-27 18:23:54 -06:00
Ivan Kozlovic
38727417df Moving super-cluster tests from cluster tests file to supercluster file
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-27 17:14:19 -06:00
Ivan Kozlovic
88203dd5d5 Fixed a panic when consumer is closed
Panic was:
```
=== RUN   TestJetStreamClusterDelete
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xcec8fb]
goroutine 1761 [running]:
github.com/nats-io/nats-server/v2/server.(*stream).config(0x0)
	/home/travis/gopath/src/github.com/nats-io/nats-server/server/stream.go:1192 +0x5b
github.com/nats-io/nats-server/v2/server.(*consumer).replica(0xc000101400)
	/home/travis/gopath/src/github.com/nats-io/nats-server/server/jetstream_cluster.go:3580 +0xea
github.com/nats-io/nats-server/v2/server.(*jetStream).monitorConsumer(0xc0001d2790, 0xc000101400, 0xc0004df0e0)
	/home/travis/gopath/src/github.com/nats-io/nats-server/server/jetstream_cluster.go:3733 +0xe06
github.com/nats-io/nats-server/v2/server.(*jetStream).processClusterCreateConsumer.func1()
	/home/travis/gopath/src/github.com/nats-io/nats-server/server/jetstream_cluster.go:3445 +0x4d
created by github.com/nats-io/nats-server/v2/server.(*Server).startGoRoutine
	/home/travis/gopath/src/github.com/nats-io/nats-server/server/server.go:3057 +0x85
FAIL	github.com/nats-io/nats-server/v2/server	9.911s
```

Seem to have been introduced in #3282

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-27 16:51:10 -06:00
Ivan Kozlovic
23c475e0d2 Merge pull request #3296 from nats-io/js_fix_subj_string_race
Fixed data race between UpdateConfif() and subjString
2022-07-27 16:19:56 -06:00
Ivan Kozlovic
d0ee9a1252 Add comment that this is to silence the race detector.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-27 15:43:38 -06:00
Ivan Kozlovic
880e854637 Fixed data race between UpdateConfif() and subjString
A message block is checking the filestore's cfg.Subjects to see
if it can "intern" the subject or not. The problem is that this
is done under the message block's lock, but not the filestore.
However, during a stream configuration update, the filestore's
cfg field is switched to a new one, causing the datarace.

By making sure we do the switch under all message blocks lock,
we remove the data race (that could be reproduce by running th
test TestJetStreamClusterMoveCancel with -count=10).

We investigating the use of a string interning library but it
showed a little performance degradation that this approach does
not suffer from.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-27 14:39:34 -06:00
Derek Collison
15382d9796 Bump to 2.9.0-beta.12
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-26 18:57:41 -07:00
Matthias Hanel
3358205de3 add implementation for consumer replica change (#3293)
* add implementation for consumer replica change

fixes #3262

also check peer list on every update

Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-27 03:56:28 +02:00
Derek Collison
5f12c244ab Bump to 2.9.0-beta.11
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-26 17:25:28 -07:00
Matthias Hanel
04ffed48b0 fix peer tracking by removing peers before scaledown (#3289)
in doRemovePeerAsLeader the leader also records the removed peer in the removed set

Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-26 22:01:03 +02:00
Matthias Hanel
6212087feb fix race by locking arround o.isLeader (#3291)
Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-26 21:49:04 +02:00
Ivan Kozlovic
fe370955c8 Merge pull request #3288 from nats-io/debug_test_failure
[FIXED] JetStream: Some scaling up issues
2022-07-26 08:57:17 -06:00
Ivan Kozlovic
cb97cbea4a Merge pull request #3287 from nats-io/js_streams_limit
[FIXED] JetStream/Cluster: Stream names/infos would return bad response
2022-07-25 18:45:01 -06:00
Ivan Kozlovic
1a6c5f1c90 [FIXED] JetStream: Some scaling up issues
- Send snapshot only if leader
- When processing snapshot, start with a smaller inactivity interval
  that will double up to 10sec or use 10sec directly once we get a
  message. Reason for that is that it is possible that the request
  for snapshot is sent while the leader has not yet setup the subscription
  that receives the requests (or subscription has not fully reached the
  cluster).
- Don't remember snapfile on err.
- Do not consider current if we have not had any activity.
- Stabilize stream scale up under active heavy publishing.
- Due to the publish pressure move the check for followers direct subs spinning up til after we stop publishing.

Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-25 18:44:18 -06:00