Commit Graph

6000 Commits

Author SHA1 Message Date
Derek Collison
f2abdaeb43 Make sure to protect against mset == nil
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-21 06:53:26 -07:00
Matthias Hanel
51b6d5233f Fix raft issue where pindex of follower was off by 1 (#3277)
introduced by 57395bba02

Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-21 00:51:26 +02:00
Ivan Kozlovic
45b1490362 Merge pull request #2363 from neilalexander/neilalexander/wasmjs
Stubs for WebAssembly
2022-07-20 13:26:56 -06:00
Matthias Hanel
62bf8ce7e9 fix jwt unit test by ensuring activation issue time is bigger than expiration (#3275)
Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-19 21:38:58 +02:00
Todd Beets
302f85dcc2 Merge pull request #3271 from nats-io/repub-fix-srcignored
Fix and test for RePub src ignored at runtime.
2022-07-18 15:02:09 -07:00
Todd Beets
6de64667bc follow convention (_EMPTY_, fwcs). Add special case short-circuit to skip unnecessary tokenization and transform. 2022-07-18 14:20:10 -07:00
Matthias Hanel
e753e897cf Bump version to 2.9.0-beta.8 (#3274)
Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-18 19:40:31 +02:00
Matthias Hanel
89b5e872ac Move and cancel fixes (#3270)
The Move/Cancel/Downscale mechanism did not take into account that
the consumer's replica count can be set independently.

This also alters peer selection to have the ability to skip 
unique tag prefix check for server that will be replaced.
Say you have 3 az, and want to add another server to az:1, 
in order to replace a server that is the same zone.
Without this change, uniqueTagPrefix check would filter 
the server to replace with and cause a failure.

The cancel move response could not be received due to 
the wrong account name.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-18 18:42:03 +02:00
Todd Beets
7a47631051 optimize for > or empty src (any subject) 2022-07-17 13:45:05 -07:00
Todd Beets
ae9f872ef5 Fix static code check violation on two unit tests and normalize unit test values to ADR-28. 2022-07-15 21:25:29 -07:00
Ivan Kozlovic
2c7d04f075 Merge pull request #3269 from nats-io/js_reject_stream_mirror_updates
[FIXED] JetStream: stream mirror updates not rejected in standalone
2022-07-15 15:21:22 -06:00
Todd Beets
b145952e78 Fix and test for RePub src ignored at runtime. 2022-07-15 13:50:35 -07:00
Ivan Kozlovic
0887f3d66a Check for mirror configuration
With the previous commit, this should no longer be possible, but
otherwise we got report of a panic when accessing the mirror configuration.
The following test would be able to produce the panic:

```
	s := RunBasicJetStreamServer()
	if config := s.JetStreamConfig(); config != nil {
		defer removeDir(t, config.StoreDir)
	}
	defer s.Shutdown()

	nc, js := jsClientConnect(t, s)
	defer nc.Close()

	_, err := js.AddStream(&nats.StreamConfig{Name: "SOURCE"})
	require_NoError(t, err)

	cfg := &nats.StreamConfig{
		Name:   "M",
		Mirror: &nats.StreamSource{Name: "SOURCE"},
	}
	_, err = js.AddStream(cfg)
	require_NoError(t, err)

	err = js.DeleteStream("SOURCE")
	require_NoError(t, err)

	cfg.Mirror = nil
	_, err = js.UpdateStream(cfg)
	require_NoError(t, err)

	time.Sleep(5 * time.Second)
```

Again, now that we reject the mirror config update, the panic
should no longer happen, but adding preventive code in case we
allow in the future.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-15 11:18:23 -06:00
Ivan Kozlovic
5f0ee2344a [FIXED] JetStream: stream mirror updates not rejected in standalone
Updates to stream mirror config are rejected in cluster mode, but
were not in standalone. This PR adds the check in standalone mode.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-15 10:51:57 -06:00
Ivan Kozlovic
00a38dc98e Merge pull request #3263 from nats-io/update_deps
[UPDATED] Compression library
2022-07-14 10:57:55 -06:00
Ivan Kozlovic
dac8b0959b [UPDATED] Compression library
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-14 10:33:38 -06:00
Matthias Hanel
95caa6ba36 bump version to 2.9.0-beta.7 (#3259)
Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-12 22:41:52 +02:00
Matthias Hanel
023500e1da add the ability to cancel a move in progress (#3253)
* add the ability to cancel a move in progress

Move to individual subjects for move and cancel_move

New subjects are:
$JS.API.ACCOUNT.STREAM.MOVE.*.*
$JS.API.ACCOUNT.STREAM.CANCEL_MOVE.*.*

last and second to last token are account and stream name

Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-12 21:54:18 +02:00
Matthias Hanel
d53d2d0484 [Added] account specific monitoring endpoint(s) (#3250)
Added http monitoring endpoint /accstatz
It responds with a list of statz for all accounts with local connections
the argument "unused=1" can be provided to get statz for all accounts
This endpoint is also exposed as nats request under:

This monitoring endpoint is exposed via the system account.
$SYS.REQ.ACCOUNT.*.STATZ
Each server will respond with connection statistics for the requested
account. The format of the data section is a list (size 1) identical to the event
$SYS.ACCOUNT.%s.SERVER.CONNS which is sent periodically as well as on
connect/disconnect. Unless requested by options, server without the account,
or server where the account has no local connections, will not respond.

A PING endpoint exists as well. The response format is identical to
$SYS.REQ.ACCOUNT.*.STATZ
(however the data section will contain more than one account, if they exist)
In addition to general filter options the request takes a list of accounts and
an argument to include accounts without local connections (disabled by default)
$SYS.REQ.ACCOUNT.PING.STATZ

Each account has a new system account import where the local subject
$SYS.REQ.ACCOUNT.PING.STATZ essentially responds as if
the importing account name was used for $SYS.REQ.ACCOUNT.*.STATZ

The only difference between requesting ACCOUNT.PING.STATZ from within
the system account and an account is that the later can only retrieve
statz for the account the client requests from.

Also exposed the monitoring /healthz via the system account under
$SYS.REQ.SERVER.*.HEALTHZ
$SYS.REQ.SERVER.PING.HEALTHZ
No dedicated options are available for these.
HEALTHZ also accept general filter options.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-12 21:50:32 +02:00
Ivan Kozlovic
520d323ea5 Merge pull request #3258 from nats-io/js_detect_as_orphans
[FIXED] JetStream: servers may be reported as orphaned
2022-07-12 10:26:38 -06:00
Ivan Kozlovic
39a0cfccca [FIXED] JetStream: servers may be reported as orphaned
In some situations, a server may report that a remote server is
detected as orphaned (and the node is marked as offline). This is
because the orphaned detection relies on conns update to be received,
however, servers would suppress the update if an account does not
have any connections attached.

This PR ensures that the update is sent regardless if the account
is JS configured (not necessarily enabled at the moment).

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-11 16:15:01 -06:00
Jean-Noël Moyne
23a9036b9b Improves error handling for subject mapping destination mustache functions (#3255) 2022-07-11 14:56:34 -07:00
Matthias Hanel
988629a1ed enhanced unit test to check for leader post move (#3257)
Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-11 20:35:04 +02:00
Ivan Kozlovic
f241a92963 Merge pull request #3256 from nats-io/fix_test_causing_flappers
Fixed a test that was causing others to flap
2022-07-11 10:26:50 -06:00
Ivan Kozlovic
50c561a040 Fixed a test that was causing others to flap
The test was lowering the eventsHBInterval to low value but not
restoring its original value. This would cause some servers to
be considered "orphan" and the shutdown event sent causing their
raft node to be considered "offline", which then would result
in some tests failing with "insufficient resources".

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-11 10:00:03 -06:00
Derek Collison
da305f2044 Merge pull request #3252 from nats-io/stream_direct_update
Allow stream and mirror direct get to be updated
2022-07-08 07:54:33 -07:00
Derek Collison
7ff534d1da Allow get next for json stream get version
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-08 07:19:15 -07:00
Derek Collison
59a0a3ba5c Allow stream and mirror direct get abilities to be updated.
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-08 07:13:34 -07:00
Derek Collison
61fe6bcffb Bump to 2.9.0-beta.5
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-07 17:54:46 -07:00
Derek Collison
85123861d4 Merge pull request #3249 from nats-io/catchup_eof
Fix for stalled catchup in endless cycle on EOF
2022-07-07 17:54:07 -07:00
Matthias Hanel
9c55e67a35 Merge pull request #3248 from nats-io/fix-uniqe-tag-stream-update
Fix unique_tag issue with stream replica increase
2022-07-08 02:23:59 +02:00
Derek Collison
333e2fc2f1 Fix for stalled catchup in endless cycle on EOF trying to retrieve catchup msg.
A customer experienced and endless failure to have a stream cacthup. The current leader was being asked for a message from a snapshot that was larger then what we had, resulting in EOF which silently failed.
We now detect this and signal end of catchup and redo the bad snapshot if possible.

Signed-off-by: Derek Collison <derek@nats.io>
2022-07-07 13:42:41 -07:00
Matthias Hanel
f0ee56cf0a Fix unique_tag issue with stream replica increase
When increasing the replica count unique tags for already existing peers
where ignored, which could lead to bad placement

Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-07 21:22:55 +02:00
Ivan Kozlovic
7ab256185e Merge pull request #3038 from nats-io/js_expected_last_seq_zero
[CHANGED] JetStream: accept "Nats-Expected-Last-Sequence" with "0"
2022-07-07 10:36:52 -06:00
Derek Collison
c49d081341 Fix data race
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-07 09:05:50 -07:00
Derek Collison
be789c620d Bump to 2.9.0-beta.4
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-07 08:46:18 -07:00
Ivan Kozlovic
be8734e32b [CHANGED] JetStream: accept "Nats-Expected-Last-Sequence" with "0"
We use to ignore if the seq was 0, but now would treat it as
a requirement that the stream be empty if header is present but
set to 0.

This relates to client PR: https://github.com/nats-io/nats.go/pull/958

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-07-07 09:44:27 -06:00
Derek Collison
b4aaec3417 Also wait on consumer
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-06 21:00:15 -07:00
Derek Collison
05e8d82c50 Allow retries on connect
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-06 20:54:13 -07:00
Derek Collison
69f522cb9f Make sure to clean up client connection
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-06 19:29:32 -07:00
Matthias Hanel
a831185a47 Merge pull request #3234 from nats-io/stream-move-fix-first-commit-only
fixes peer removal, simplifies move, more tests
2022-07-07 03:54:10 +02:00
Matthias Hanel
509eec4baa bump server version to 2.9.0-beta.3
Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-07 03:36:19 +02:00
Derek Collison
16f788adce Consumer isFiltered could crash if the stream was a mirror with no direct subjects but it was in interest or workqueue retention mode.
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-07 03:35:41 +02:00
Matthias Hanel
70be4b77f9 fixes peer removal, simplifies move, more tests
Make sure when processing a peer removal that the stream assignment agrees.
When a new leader takes over it can resend a peer removal, and if the stream/consumer really was rescheduled we could remove by accident.

Also need to make sure that when we remove a stream we remove the node as part of the stream assignment.
If we didn't, if the same asset returned to this server we would not start up the monitoring loop.

Simplify migration logic in monitorStream, to be driven by leader only

Improved unit tests

Added failure when server not in peer list

Move command does not require server anymore

Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-07-07 03:32:13 +02:00
Derek Collison
de3a90cbc8 Merge pull request #3247 from nats-io/get_direct_next
Allows direct get to also do get next for subject with starting sequence
2022-07-06 16:46:46 -07:00
Derek Collison
f8939b40bc Do not unsubscribe from direct access on leader stepdown, only stopping.
Also wait for stream to have replicas and leader for test.

Signed-off-by: Derek Collison <derek@nats.io>
2022-07-06 16:20:12 -07:00
Derek Collison
1ea608eabf Allows direct get to also do get next for subject with starting sequence
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-06 14:22:28 -07:00
Derek Collison
94c526f54c Merge pull request #3246 from nats-io/sys_group
Reserve a system queue group
2022-07-06 13:29:08 -07:00
Derek Collison
5690059dac Reserve a system queue group
Signed-off-by: Derek Collison <derek@nats.io>
2022-07-06 13:16:13 -07:00
Ivan Kozlovic
697811cd9b Merge pull request #3242 from nats-io/fix_3239
[ADDED] Symlink for deb/rpm packages
2022-07-06 12:04:50 -06:00