36 Commits

Author SHA1 Message Date
Ivan Kozlovic
a84ce61a93 [FIXED] Account resolver lock inversion
There was a lock inversion but low risk since it happened during
server initialization. Still fixed it and added the ordering
in locksordering.txt file.

Also fixed multiple lock inversions that were caused by tests.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-09-25 15:09:11 -06:00
Derek Collison
0308cbb372 Fix for spelling
Signed-off-by: Derek Collison <derek@nats.io>
2023-09-12 07:52:17 -07:00
Derek Collison
8e2c30a75b Better fix for flapping test
Signed-off-by: Derek Collison <derek@nats.io>
2023-09-12 06:54:36 -07:00
Derek Collison
eed5fd8a73 Allow time for the 3rd replica to be current
Signed-off-by: Derek Collison <derek@nats.io>
2023-09-11 21:54:58 -07:00
Neil Twigg
8d194e8bf9 Tweak TestJetStreamClusterMetaSnapshotsMultiChange and TestJetStreamClusterStreamUpdateSyncBug
Signed-off-by: Neil Twigg <neil@nats.io>
2023-08-30 15:49:50 +01:00
Derek Collison
ecf0fff411 Merge branch 'main' into dev 2023-07-17 10:41:51 -07:00
Neil Twigg
6cdb0c7838 Wait for current in TestJetStreamClusterStreamUpdateSyncBug so in-flight state changes aren't lost
Signed-off-by: Neil Twigg <neil@nats.io>
2023-07-14 17:03:21 +01:00
Neil Twigg
1527000d1f Use crypto/rand.Read instead of math/rand.Read
As of Go 1.20, `math/rand.Read` is deprecated. In addition to that, it also
isn't recommended for use in combination with anything cryptographic.

I haven't replaced all `math/rand` with `crypto/rand` imports because there
are still some legitimate uses for the `math/rand` package in some places.

Signed-off-by: Neil Twigg <neil@nats.io>
2023-07-13 12:04:58 +01:00
Derek Collison
a319d24345 Merge branch 'main' into dev 2023-04-13 21:03:05 -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
dfeac4a214 Merge branch 'main' into dev 2023-04-09 19:31:01 -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
48a5d270b2 Merge branch 'main' into dev 2023-04-02 04:23:52 -07:00
Derek Collison
299d9b28a9 Add original message timestamp to republished message headers (#3933)
Adds original message timestamp to republished message as
"Nats-Time-Stamp" header

 - [ ] Link to issue, e.g. `Resolves #NNN`
 - [ ] Documentation added (if applicable)
 - [x] Tests added
- [x] Branch rebased on top of current main (`git pull --rebase origin
main`)
- [x] Changes squashed to a single commit (described
[here](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html))
 - [ ] Build is green in Travis CI
- [x] You have certified that the contribution is your original work and
that you license the work to the project under the [Apache 2
license](https://github.com/nats-io/nats-server/blob/main/LICENSE)

Resolves #

### Changes proposed in this pull request:

- Add original message timestamp to republished message as header
"Nats-Time-Stamp"
 -
 -
2023-04-02 04:05:53 -07:00
Derek Collison
e2839e9ec1 Fix for flapper
Signed-off-by: Derek Collison <derek@nats.io>
2023-04-02 03:52:43 -07:00
Derek Collison
625ffa8685 Merge branch 'main' into dev 2023-03-29 17:19:45 -07:00
Derek Collison
e97ddcd14f Tweak tests due to changes, make test timeouts uniform.
Signed-off-by: Derek Collison <derek@nats.io>
2023-03-29 12:43:59 -07:00
Andres Morey
2d4c12c5dd added original message timestamp to republished message headers 2023-03-01 22:08:52 +03:00
Derek Collison
538c6d0797 Merge branch 'main' into dev 2023-02-23 22:47:04 -08:00
Derek Collison
45859e6476 Make sure preferred peer for stepdown is healthy.
Signed-off-by: Derek Collison <derek@nats.io>
2023-02-23 13:06:13 -08:00
Derek Collison
42cdc4e39d Merge branch 'main' into dev 2023-01-31 10:10:29 -08:00
Derek Collison
390fd02918 Updates to tests for updated Go client changes
Signed-off-by: Derek Collison <derek@nats.io>
2023-01-31 09:47:36 -08:00
Derek Collison
aaacca8549 Merge branch 'main' into dev 2023-01-30 19:54:37 -08:00
Derek Collison
6058056e3b Minor fixes and optimizations for snapshots.
We were snappshotting more then needed, so double check that we should be doing this at the stream and consumer level.
At the raft level, we should have always been compacting the WAL to last+1, so made that consistent. Also fixed bug that would not skip last if more items behind the snapshot.

Signed-off-by: Derek Collison <derek@nats.io>
2023-01-30 17:54:18 -08:00
Derek Collison
11ffd69575 Merge branch 'main' into dev 2023-01-27 13:41:48 -08:00
Derek Collison
64096e5ef5 Fix for flapping test
Signed-off-by: Derek Collison <derek@nats.io>
2023-01-27 13:19:44 -08:00
Neil Twigg
4f45df6186 Allow editing of RePublish on an existing stream 2023-01-25 09:57:02 +00:00
Derek Collison
ad53d455f8 When migrating leaders off a server when the leafnode is not connected, also ensure leaders can not return until reconnected.
Signed-off-by: Derek Collison <derek@nats.io>
2023-01-05 08:02:50 -08:00
Marco Primi
f8a030bc4a Use testing.TempDir() where possible
Refactor tests to use go built-in temporary directory utility for tests.

Also avoid binding to default port (which may be in use)
2022-12-12 13:18:44 -08:00
Ivan Kozlovic
1b892837cb [FIXED] JetStream: Account max streams/consumers not always honoured
This could happen during concurrent requests where the assignments
are not yet fully processed.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-11-09 17:29:20 -07:00
Ivan Kozlovic
f8aa3ac11d [FIXED] JetStream: "first sequence mismatch" error on catchup with message expiration
When a server was restarted and expired messages, but the leader had a snapshot that
still had the old messages we would reset complete follower stream state, this fix
just skips over the expired as we prepare the request to the leader.

Resolves #3516

Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-10-17 17:02:08 -06:00
Ivan Kozlovic
5df93f9c81 Fix a test that would sometimes fail
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-10-17 11:35:47 -06:00
Ivan Kozlovic
3fadccab38 Move new test to new jetstream_cluster_3_test.go file
Since the second batch was already past the 5min mark and a bit
longer than the first batch, it is a good opportunity to add
this new test in a new file. Updated runTestsOnTravis and travis.yml
accordingly.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-09-15 12:13:00 -06:00
Ivan Kozlovic
f113163b9f Change ByID boolean to Peer string and add Peer id in replicas output
The CLI will now be able to display the peer IDs in MetaGroupInfo
if it choses to do so, and possibly help user select the peer ID
from a list with a new command to remove by peer ID instead of
by server name.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-09-15 10:39:23 -06:00
Ivan Kozlovic
e1f0361b98 [ADDED] JetStream: ability to remove a server by peer ID instead of name
This can be helpful after a partial cluster restart since in that
case the server name may not be known. However "server report jetstream"
would report the peer ID that then can be used.

For instance here is the output after a cluster restart where server "C"
is not restarted.

```
nats -s nats://sys:pwd@localhost:4222 server report jetstream
...
╭────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                  RAFT Meta Group Information                                   │
├─────────────────────────────────────────────────────┬────────┬─────────┬────────┬────────┬─────┤
│ Name                                                │ Leader │ Current │ Online │ Active │ Lag │
├─────────────────────────────────────────────────────┼────────┼─────────┼────────┼────────┼─────┤
│ A                                                   │ yes    │ true    │ true   │ 0.00s  │ 0   │
│ B                                                   │        │ true    │ true   │ 0.53s  │ 0   │
│ Server name unknown at this time (peerID: jZ6RvVRH) │        │ false   │ false  │ 0.00s  │ 0   │
╰─────────────────────────────────────────────────────┴────────┴─────────┴────────┴────────┴─────╯
```

With a change to the NATS CLI we could have something like:
```
nats -s nats://sys:pwd@localhost:4222 server raft peer-remove jZ6RvVRH --by_id
```

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-09-14 18:10:26 -06:00
Ivan Kozlovic
29224c8ea9 Split more tests to speed up Travis run
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-09-09 12:45:48 -06:00