Commit Graph

398 Commits

Author SHA1 Message Date
Tomasz Pietrek
af338d0d59 Add multiple subject filters 2023-02-13 09:38:40 +01:00
Derek Collison
3fe85e6cc4 Merge branch 'main' into dev 2023-02-06 21:57:49 +04:00
Derek Collison
b611e37e95 For updating a consumer filter subject make sure locking ordere correct and that our sublist is present.
Signed-off-by: Derek Collison <derek@nats.io>
2023-02-06 21:34:48 +04:00
Derek Collison
f7615acb7d Merge branch 'main' into dev 2023-02-04 22:23:50 -08:00
Derek Collison
b22ed47a26 Use fast state in case many interior deletes and small fix for staticcheck
Signed-off-by: Derek Collison <derek@nats.io>
2023-02-04 13:55:41 -08:00
Derek Collison
2c4ec09cc7 Merge branch 'main' into dev 2023-02-02 11:01:50 -07:00
Tomasz Pietrek
46af979871 Fix current consumers not getting messages after purge
Until now, purge updated all consumers sequences
even if purge subject was only a subset of given consumer filter.
Because of that, even messages from not purged subjects were not fetched
or properly accounted for existing consumers.

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
2023-02-02 16:27:32 +01:00
Derek Collison
2d6b316efd Merge branch 'main' into dev 2023-01-30 20:07:26 -08:00
Derek Collison
1252653c16 Merge pull request #3829 from nats-io/jarema/fix-message-after-update
Fix Consumer not getting messages after filter update
2023-01-30 19:59:32 -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
Tomasz Pietrek
836848ca64 Fix Consumer not getting messages after filter update
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
2023-01-30 20:47:17 +01:00
Jean-Noël Moyne
3518c9460a Small formatting improvements 2023-01-28 12:59:36 -08:00
Jean-Noël Moyne
ccc492bdce Improve checking that subject filters and destination transforms are valid subjects.
Improve error messages when bad filters/transforms are encountered.
Cover all cases of updating an existing stream's subject transform or sources
2023-01-27 17:54:37 -08:00
Derek Collison
11ffd69575 Merge branch 'main' into dev 2023-01-27 13:41:48 -08:00
Derek Collison
f4e6481ce7 Allow report cycles between source streams if subjects truly form a cycle.
Signed-off-by: Derek Collison <derek@nats.io>
2023-01-27 13:03:24 -08:00
Derek Collison
b9f220ec80 Merge pull request #3823 from ripienaar/mappings_breaking_changes
Mappings breaking changes
2023-01-27 07:48:04 -08:00
R.I.Pienaar
348c84a469 restore public APIs and fix breaking interface renames
Signed-off-by: R.I.Pienaar <rip@devco.net>
2023-01-27 12:36:15 +01:00
Tomasz Pietrek
9ab52d4ba9 Add metadata to StreamConfig and ConsumerConfig
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
2023-01-27 07:27:25 +01:00
Derek Collison
c2d3d9c467 Merge pull request #3814 from nats-io/jnm/streamsourcetransform
[ADDED] Stream subject mapping transforms
2023-01-26 14:09:52 -08:00
Jean-Noël Moyne
ddce3ce037 Rename StreamConfig's InputSubjectTransform (and therefore StreamSource's SubjectTransform) 2023-01-26 12:26:34 -08:00
Derek Collison
469116deae Merge branch 'main' into dev 2023-01-26 09:39:32 -08:00
Jean-Noël Moyne
4fbe13ec1b Change test to use require_NoError instead of explicitly checking err and calling Fatalf throughout all the tests in the file
Improvements to readability
2023-01-26 00:31:17 -08:00
Jean-Noël Moyne
e2561a6d54 rebase fix 2023-01-25 12:30:26 -08:00
Jean-Noël Moyne
a953e84437 Add stream input subject transform functionality
Extract subject transformation code out of accounts.go
Stream sources can now have a subject mapping transform
You can source the same stream more than once
Remove limitation that the subject filter for a source, mirror or consumer must have an overlap with the sourced/mirrored's stream or the stream's subjects
2023-01-25 12:25:51 -08:00
Neil Twigg
4f45df6186 Allow editing of RePublish on an existing stream 2023-01-25 09:57:02 +00:00
Derek Collison
f62d929018 Consumer must match replica of parent stream if interest based policy.
Signed-off-by: Derek Collison <derek@nats.io>
2023-01-23 20:16:42 -08:00
Derek Collison
a3365abef0 Merge branch 'main' into dev 2023-01-23 17:30:08 -08:00
Derek Collison
f4ee6530a0 When updating a stream to Direct Gets we were not spinning up subscription endpoint properly.
Signed-off-by: Derek Collison <derek@nats.io>
2023-01-23 16:51:07 -08:00
Derek Collison
3171309c87 Merge branch 'main' into dev 2022-12-16 13:28:12 -08:00
Todd Beets
c463b398db Validate no overlapping stream subscriptions on update config (non-clustered jetstream) 2022-12-16 12:58:59 -08:00
Derek Collison
c90fe9a2fa Improve performance and latency with large number of sparse consumers.
When a stream had a large number of consumers on a server that were sparse, the signaling mechanism would do a linear scan to signal matching consumers. As usage patterns have continued to have more consumers that are filteres and sparse, meaning a message is destined for a single or small number of consumers.

This change moves selection to a sublist that tracks only active consumer leaders for selection, which optimizes selection of consumers to signal when the number of consumers is large.

Signed-off-by: Derek Collison <derek@nats.io>
2022-12-13 15:25:55 -08:00
Derek Collison
855f790e3c Improve performance and latency with large number of sparse consumers.
When a stream had a large number of consumers on a server that were sparse, the signaling mechanism would do a linear scan to signal matching consumers. As usage patterns have continued to have more consumers that are filteres and sparse, meaning a message is destined for a single or small number of consumers.

This change moves selection to a sublist that tracks only active consumer leaders for selection, which optimizes selection of consumers to signal when the number of consumers is large.

Signed-off-by: Derek Collison <derek@nats.io>
2022-12-13 10:09:59 -08:00
R.I.Pienaar
e234e773ab Rate limit frequent debug log lines
With the increase use of subject based limits not being able
to store due to limits exceeded happens frequently and makes
running the server in debug quite noisy, so we rate limit this
log line even in debug

Signed-off-by: R.I.Pienaar <rip@devco.net>
2022-12-09 11:53:52 +01:00
Derek Collison
5f7c8e21a2 Fixed issues with multiple concurrent stream create requests.
First issue was applications not getting any response.
However, there was also a more serious issue that would create multiple raft groups for each concurrent request.
The servers would only run one stream monitor loop, however they would update the state to the new raft group's name, so on server restart the stream would be using a different raft group then existing servers.

Signed-off-by: Derek Collison <derek@nats.io>
2022-12-04 19:13:51 -08:00
Ivan Kozlovic
74a16b0097 Merge pull request #3640 from nats-io/fix_3639
[FIXED] JetStream: WorkQueue not preventing overlapping consumers
2022-11-16 17:22:35 -07:00
Ivan Kozlovic
49faba9e33 [FIXED] JetStream: WorkQueue not preventing overlapping consumers
A stream with a WorkQueue retention policy is supposed to allow
more than one consumer if they user filtered subjects, but those
subjects should not overlap.

There was an issue that if a new consumer had a filter subject
"wider" than an existing one, the error was not detected and
the new consumer was incorrectly accepted.

Resolves #3639

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-11-16 17:09:30 -07:00
Derek Collison
e4b5b7ec64 Make mirror consumers use filtered version of consumer create like source consumers.
Signed-off-by: Derek Collison <derek@nats.io>
2022-11-16 15:12:14 -08:00
Derek Collison
9f241f3322 Offload signaling to consumers when number is large.
Signed-off-by: Derek Collison <derek@nats.io>
2022-11-15 11:25:07 -08:00
Derek Collison
b6ef2c8910 Auto cleanup dangling messages from interest policy streams on server start.
Signed-off-by: Derek Collison <derek@nats.io>
2022-11-14 15:02:22 -08:00
Ivan Kozlovic
c16ccd34c3 [FIXED] JetStream: Sources with OptStartTime gets redelivered
If start by time is before what we remember during recovery use that instead

Resolves #3559

Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-11-03 16:09:06 -06:00
Ivan Kozlovic
3c7aa554f7 [FIXED] JetStream: return error on negative replicas count
If a stream is created or updated with a negative replicas count,
and error is now returned. Same for consumers.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-10-10 12:32:41 -06:00
Derek Collison
91edd1a8d0 With snapshots both streams are present on restart so sources or mirrors that have a subject change from the origin would not recover.
We now suppress that if we know we are recovering an existing stream.

Signed-off-by: Derek Collison <derek@nats.io>
2022-09-29 09:17:15 -06:00
Derek Collison
61a3cff274 Also require MaxMsgsPerSubject to be set per peer review feedback.
Signed-off-by: Derek Collison <derek@nats.io>
2022-09-22 06:56:32 -07:00
Derek Collison
2d737edba6 Allow discard new per subject for certain KV type scenarios. Requires general DiscardNewPolicy.
Signed-off-by: Derek Collison <derek@nats.io>
2022-09-22 06:38:29 -07:00
Derek Collison
8b2315eadd When filtering a source stream use new consumer create API subject.
Signed-off-by: Derek Collison <derek@nats.io>
2022-09-16 14:45:33 -07:00
Ivan Kozlovic
170ff49837 [ADDED] JetStream: peer (the hash of server name) in statsz/jsz
A request to `$SYS.REQ.SERVER.PING.JSZ` would now return something
like this:
```
...
    "meta_cluster": {
      "name": "local",
      "leader": "A",
      "peer": "NUmM6cRx",
      "replicas": [
        {
          "name": "B",
          "current": true,
          "active": 690369000,
          "peer": "b2oh2L6w"
        },
        {
          "name": "Server name unknown at this time (peerID: jZ6RvVRH)",
          "current": false,
          "offline": true,
          "active": 0,
          "peer": "jZ6RvVRH"
        }
      ],
      "cluster_size": 3
    }
```
Note the "peer" field following the "leader" field that contains
the server name. The new field is the node ID, which is a hash of
the server name.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-09-16 15:31:37 -06:00
Ivan Kozlovic
dc2e4b714a Merge pull request #3473 from nats-io/js_raft_remove_by_peer_id
[ADDED] JetStream: ability to remove a server by peer ID instead of name
2022-09-15 13:52:20 -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
Derek Collison
2aaf22b0de For ackMsg, make sure sequence is still relevant as well.
Signed-off-by: Derek Collison <derek@nats.io>
2022-09-14 16:47:35 -07:00