Commit Graph

7059 Commits

Author SHA1 Message Date
Waldemar Quevedo
dea7fc04f3 Fix nsc in nightly 2023-04-17 00:07:01 -07:00
Derek Collison
33f23be103 Update package dependencies (#4060)
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-16 16:54:11 -07:00
Derek Collison
a6029a090c Update pkg dependencies
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-16 14:25:33 -07:00
Derek Collison
6215ed9bc3 Update to Go 1.19.8 (#4059) 2023-04-16 13:08:44 -07:00
Byron Ruth
dea68595fd Update to Go 1.19.8
Signed-off-by: Byron Ruth <byron@nats.io>
2023-04-16 15:33:13 -04:00
Derek Collison
670da9f7a3 [IMPROVED] Recover on boundary conditions that could cause RAFT layer to spin. (#4058)
Reset our WAL on edge conditions instead of trying to recover.
Also if we are timing out and trying to become a candidate but are doing
a catchup check if we are stalled.

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-15 14:19:59 -07:00
Derek Collison
a5f5603645 Reset our WAL on edge conditions instead of trying to recover.
Also if we are timing out and trying to become a candidate but are doing a catchup check if we are stalled.

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-15 12:23:44 -07:00
Derek Collison
2ee73f8a38 [FIXED] Fix for a regression in behavior. (#4057)
When tracking information per subject went from >1 back to only 1 we
needed to make sure we cleared firstNeedsUpdate.

Thanks to @scottf for finding it.

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-15 10:47:13 -07:00
Derek Collison
034975e767 Fix for a regression in behavior, needed to make sure when we went back to 1 entry for a subject we cleared firstNeedsUpdate.
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-15 10:00:44 -07:00
Derek Collison
816cd82fc3 [FIXED] Do not spin on multi-leader with same term. (#4056)
If we see another leader with same term we should step down, otherwise
we could spin with catchups and WAL truncates.

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-14 16:43:50 -07:00
Derek Collison
66ca46e145 If we see another leader with same term we should step down
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-14 16:21:40 -07:00
Derek Collison
94e62cc30b Add server name / remote server name to routez (#4054)
Add server name to routez info:

```js
{
  "server_id": "NAXUYR7XZFPBQPJGV5HNWIXLOCLBSA2GOQEPGP47AFY62XHWPREKCXWL",
  "server_name": "nats-burn-0",
  "now": "2023-04-14T19:47:52.057269Z",
  "num_routes": 2,
  "routes": [ 
    {
      "rid": 51,
      "remote_id": "NACPYGKLPWMYM7YZA3NCYQ5HL2EKGVKFKNGGE6ECD5LMO26JC3T3TARR",
      "remote_name": "nats-burn-1",
      "did_solicit": true,
      "is_configured": true,
      "ip": "127.0.0.1",
      "port": 57889,
      "start": "2023-04-14T12:47:43.475646-07:00",
      "last_activity": "2023-04-14T19:47:51.983756Z",
      "rtt": "178µs",
      "uptime": "8s",
      "idle": "0s",
      "pending_size": 0,
      "in_msgs": 210,
      "out_msgs": 154,
      "in_bytes": 31854,
      "out_bytes": 15150,
      "subscriptions": 134
    },
    {
      "rid": 53,
      "remote_id": "NCTOFS2M5IVGKYRGYOWP3Q5SQNPGCPMCIIJWOEH5SOIH3XQKRBKP7ITJ",
      "remote_name": "nats-burn-2",
      "did_solicit": true,
      "is_configured": true,
      "ip": "127.0.0.1",
      "port": 57905,
      "start": "2023-04-14T12:47:44.275914-07:00",
      "last_activity": "2023-04-14T19:47:52.022301Z",
      "rtt": "152µs",
      "uptime": "7s",
      "idle": "0s",
      "pending_size": 0,
      "in_msgs": 179,
      "out_msgs": 48,
      "in_bytes": 25629,
      "out_bytes": 7573,
      "subscriptions": 100
    }
  ]
}
```
2023-04-14 13:09:43 -07:00
Waldemar Quevedo
d12152c48f Add server name / remote server name to routez
Signed-off-by: Waldemar Quevedo <wally@nats.io>
2023-04-14 12:47:00 -07:00
Derek Collison
2699465596 Fix stream sourcing & mirroring overlap errors (#4052)
When adding or updating sources/mirrors, server was checking if the
stream with a given name exists to check for subject overlaps, among
other things.
However, if sourced/mirrored stream was `External`, checks should not be
executed, as not only stream would never be found, but also, if
`External` stream had the same name as the sourcing stream, the check
would be wrongly performed against itself.

cc @jnmoyne 

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
2023-04-14 12:18:04 -07:00
Tomasz Pietrek
a66c67baa5 Fix stream sourcing & mirroring overlap errors
When adding or updating sources/mirrors, server was checking if the stream with
a given name exists to check for subject overlaps, among other things.
However, if sourced/mirrored stream was `External`, checks should
not be executed, as not only stream would never be found,
but also, if `External` stream had the same name as the sourcing stream,
the check would be wrongly performed against itself.

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
2023-04-14 21:00:11 +02:00
Derek Collison
e881656683 [IMPROVED] Use new server read locks. (#4053)
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-14 10:37:14 -07:00
Derek Collison
0fe48fe91e Use new server read locks now that we have them
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-14 10:11:40 -07:00
Derek Collison
89fc7e3203 Bump to 2.9.16-RC.8
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-13 21:04:33 -07:00
Derek Collison
89f6a5c547 [FIXED] The meta layer should snapshot if any outstanding entries are present. (#4050)
Fixes this test [TestJetStreamClusterDeleteAndRestoreAndRestart] which
would flap since it would not snapshot since hash was same but had
entries that would erase stream data.

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-13 20:59:00 -07:00
Derek Collison
093564f7e0 The meta layer should snapshot if any oustanding entries are present, regardless of hash.
Fixes this test [TestJetStreamClusterDeleteAndRestoreAndRestart] which would flap since it would not snapshot since hash was same but had entries that would erase stream data.

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-13 20:37:00 -07:00
Derek Collison
be4999a281 [IMPROVED] Consumer updates (#4049)
Make sure to process consumer entries on recovery in case state was not
committed.
And sync other consumers when taking over as leader but no need to
process snapshots when we are in fact the leader.
Do not let the consumer redelivered count go down on re-applying state
on restarts.

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-13 19:18:11 -07:00
Derek Collison
cc77d662bb Make sure to process consumer entries on recovery in case state was not committed.
Also sync other consumers when taking over as leader but no need to process snapshots when we are in fact the leader.

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-13 18:40:17 -07:00
Derek Collison
a77884e4ec Do not let the redelivered count go down on re-applying on restarts
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-13 18:40:15 -07:00
Derek Collison
bafd585ce4 Fix data race
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-13 18:40:06 -07:00
Derek Collison
3f8fc5c5b1 [FIXED] #4043 (#4048)
Improve performance on storing msgs when multiple subjects exists with
multiple messages and we have store limits that are being hit.

This will not fix any performance degradation per se when per subject
limits are being hit constantly across a vast array of keys. That will
be addressed more so in 2.10.

Resolves #4043 

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-13 17:31:49 -07:00
Waldemar Quevedo
3602b3882a Fix raft log debug reloading (#4047)
Fixes being able to reload debug logging for running raft groups.
2023-04-13 16:21:53 -07:00
Derek Collison
b597485102 Improve performance on storing msgs when multiple subjects exists with multiple messages and we have store limits that are being hit.
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-13 15:27:34 -07:00
Waldemar Quevedo
a4833d0889 Fix raft log debug reloading
Signed-off-by: Waldemar Quevedo <wally@nats.io>
2023-04-13 14:57:04 -07:00
Neil
96fe933846 Limit filestore block size to 2MB when encryption is enabled (#4046)
Some write operations in the filestore require re-encrypting the entire
block, so having large blocks can make these operations slow and hurt
performance.

Signed-off-by: Neil Twigg <neil@nats.io>
2023-04-13 17:24:30 +01:00
Neil Twigg
fc9b9004eb Limit filestore block size to 2MB when encryption is enabled
Some write operations in the filestore require re-encrypting the
entire block, so having large blocks can make these operations
slow and hurt performance.

Signed-off-by: Neil Twigg <neil@nats.io>
2023-04-13 16:56:21 +01:00
Derek Collison
69b427bc94 [FIXES/IMPROVED] Raft and filestore logic (#4045)
When failing to send a snapshot to a follower, in addition to stepping
down reset our state.
For a filestore when expiring messages on recovery make sure that the
first message is not a deleted message.
Fix a bad unlock of wrong type which could cause a crash during
shutdown.
Add in raft specific test framework.

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-13 07:53:13 -07:00
Derek Collison
e6eaed425f Make sure we have a correct next first after expiring on startup
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-12 14:57:13 -07:00
Derek Collison
2f4677d29e Delay a bit longer if we are not the actual leader, helpful for very large stream reports to avoid possible dupes
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-12 12:36:47 -07:00
Derek Collison
808a2e8c90 On failure to send snapshot to follower, also reset, and on reset make sure to reset term
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-12 11:48:22 -07:00
Derek Collison
a92bb9fe61 Fix bad unlock which could cause crash
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-12 11:48:22 -07:00
Derek Collison
f41e5d86e1 Add in raft test helper
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-12 11:48:22 -07:00
Derek Collison
340fcc90bc Basic raft tests
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-12 11:48:22 -07:00
Derek Collison
4fcc2ff418 Fix FirstSeq not being updated with filestore when purging subject (#4042)
Resolves https://github.com/nats-io/nats-server/issues/4041

Keeps `firstSeqNeedsUpdate` set if set previously, to ensure the
FirstSeq gets updated.
2023-04-12 11:43:50 -07:00
Tomasz Pietrek
2a03d9dff7 Fix consumer reply subject escaping (#4040)
If the Consumer had a name containing `%`, it could result in the reply
subject failing to format with `fmt.Sprintf`, as the `%` was not
properly escaped with `%%`.

Resolves #4038 

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
2023-04-12 13:27:52 +02:00
Maurice van Veen
1e2bba4c7b Fix FirstSeq not being updated with filestore when purging subject 2023-04-12 10:46:16 +02:00
Tomasz Pietrek
692f384f2d Fix consumer reply subject escaping
If the Consumer had a name containing `%`, it could result in
reply subject failing to format with `fmt.Sprintf`, as the `%`
was not properly escaped with `%%`.

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
2023-04-12 09:22:08 +02:00
Derek Collison
31a2269710 Bump to 2.9.16-RC.7
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-09 19:32:58 -07:00
Derek Collison
30b50870a1 [IMPROVED] Memory allocations and pressure in the raft layer. (#4036)
Improved some hot spots on the memory subsystem with sync.Pools.

Signed-off-by: Derek Collison <derek@nats.io>
2023-04-09 19:21:23 -07:00
Derek Collison
623f2d5289 Fix flapping test
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-09 08:13:20 -07:00
Derek Collison
80a57a3d51 Remove peers from string intern map
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-09 08:01:36 -07:00
Derek Collison
6fa55540a7 Better us of entryPool
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-09 07:48:31 -07:00
Derek Collison
aee73a9c77 Fix flapping test
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-08 21:58:54 -07:00
Derek Collison
313dd424a3 Optimize to not allocate converting strings to []byte
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-08 20:46:05 -07:00
Derek Collison
ad08ee3898 Remove unused function
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-08 20:28:44 -07:00
Derek Collison
722a48d726 Don't require lock for check no echo status
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-08 20:05:33 -07:00