Commit Graph

163 Commits

Author SHA1 Message Date
R.I.Pienaar
76ab1b8d17 attempt to improve UX of the error system
Previously we had a few confusing functions like NewT
and similar that were quite fragile to use due to minimal
validation and a panic in go stdlib string Replacer.

Now we generate helper methods for every string, these
are used to access errors, fill in templates and conditional
returns of error type using the new Unless() option

We now get compile time errors for some common mistakes
and have better IDE helpers for arguments etc

Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-08-10 16:08:28 +02:00
Derek Collison
925a6fe6b2 Fix for #2388. Leafnodes with no JS can seamlessly access a HUB with JS.
This is the reverse of the early work to have LNs extend a non-JS cluster.
Also have mixed mode tests as well.

Signed-off-by: Derek Collison <derek@nats.io>
2021-08-01 14:57:47 -07:00
Derek Collison
f13fa767c2 Remove the swapping of accounts during processing of service imports.
When processing service imports we would swap out the accounts during processing.
With the addition of internal subscriptions and internal clients publishing in JetStream we had an issue with the wrong account being used.
This was specific to delyaed pull subscribers trying to unsubscribe due to max of 1 while other JetStream API calls were running concurrently.
2021-07-26 07:57:10 -07:00
Derek Collison
99fed910f0 Improvements to large numbers of JetStream R1 consumers per stream.
1. We were holding open FDs longer than we should for consumers causing issues with open FD limits. We now do not hold them open and cap updates a bit better.

2. When doing a stream delete, consumer delete was repeating alot of work that was not necessary, causing longer delays. This has been optimized a bit, still more improvements to be made.

3. We cover all JS under a single export, but that was also trapping GetNext for pull based consumers, and since this was a no-op (is handled at user account level) we were creating alot of garbage service import responses and reverse map entries that had to be garbage collected. We have a fix in to avoind this but still looking for a better one.

4. Still had some lingering references to all exports vs single JS export.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-29 05:45:55 -07:00
Derek Collison
bf6335dff9 Add in ability to have encrypted JetStream filestores.
This supports XChaChaPoly1305 for Seal and Open and ChaCha20 for our message blocks which use highway hashes and sequence numbers for authenticity.
We support snapshot and restore as well.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-21 19:28:10 -07:00
dtest11
a268905cd5 remove config !nil check,beacuse the if branch is always not nil 2021-06-18 18:02:45 +08:00
Derek Collison
08cdb2d2ea Make filtered consumers in large mixed streams more efficient.
Allow wider scoped filtered subjects.

We introduce a per subject information tracking to filestore to optimize for large mux'd streams and more efficient filtered consumers.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-15 04:44:05 -07:00
Derek Collison
ceebc3ae07 When checking limits we would check total ask against the server limits if limits were not set.
We were also dynamically setting account limits based on a single server limit.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-12 10:27:43 -07:00
Matthias Hanel
2caf2303f2 [adding] jetstream info to statsz (#2269)
* [adding] jetstream info to statsz

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-06-10 11:54:56 -04:00
Derek Collison
30fae4f960 Changes to leafnodes to support multiple domains where the hub is JetStream enabled but the hub account is not, and the leafnode is.
We were incorrectly shutting things down via deny clauses when detecting the remote side/hub had JetStream capabilities.
This change moves that logic to the remote side and is signalled off the connect message which let's the remote side know
if the local leafnode account has JetStream enabled.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-07 08:39:11 -07:00
R.I.Pienaar
ee9d10f40b restore old error constants for backwards compat
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-05-26 08:04:50 +02:00
R.I.Pienaar
0d391b02eb richer api errors proposal
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-05-26 08:04:50 +02:00
Derek Collison
0d6b022780 Fix for varz JetStream usage showing total account usage vs server usage.
Signed-off-by: Derek Collison <derek@nats.io>
2021-05-24 14:05:42 -07:00
Matthias Hanel
748b7c32f4 [fixed] deletion of js mappings on account jwt update
fixed by moving setting of the mappings into a common function that is
also called when the jwt is updated

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-05-24 16:44:14 -04:00
Derek Collison
a27b0dd673 Move default file and dir perms
Signed-off-by: Derek Collison <derek@nats.io>
2021-05-19 14:46:07 -07:00
Derek Collison
592066ed0b Fixed issue that we would stage snapshot restore in temporary storage.
This did not work when using our default docker image which does not have /tmp by default.

Signed-off-by: Derek Collison <derek@nats.io>
2021-05-19 11:36:20 -07:00
Ivan Kozlovic
a294517946 No need to fetch account if we detect that it is valid NKEY
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2021-05-12 15:57:26 -06:00
Phil Pennock
452bec8e42 Don't fix dir perms yet, punt to separate issue 2021-05-12 13:16:10 -04:00
Phil Pennock
408e009ebb Error-checking, resilience & perms for JetStream move
Jetstream movement can fail, so return that error and abort start-up if there's
a failure in moving precious data, rather than serve without it.

Create the jetstream directory if needed.

Create directories for private data mode 0750 not 0755.

This does not handle a directory layout made with 2.2.3, but does support a
2.2.2 to 2.2.4 migration.  The empty directories made under 2.2.3 will still
hinder the renames we do here.
2021-05-12 12:32:21 -04:00
Derek Collison
58344c666a Update based on feedback.
Only log when actually moving an account in case other files start polluting the directory.
When failing to look up an account and we have a resolver check to see if its a valid account name before attempting lookup.

Signed-off-by: Derek Collison <derek@nats.io>
2021-05-11 07:54:10 -07:00
Derek Collison
bad9fba8ec Fix for store directory on disk prior to 2.2.3 without the 'jetstream' directory.
Signed-off-by: Derek Collison <derek@nats.io>
2021-05-10 19:24:58 -07:00
Ivan Kozlovic
19e07f7b97 Extend stream/consumer name validation to include more characters
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2021-05-07 16:50:29 -06:00
R.I.Pienaar
b5f846a719 add domain in JS advisories
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-05-07 19:35:46 +02:00
R.I.Pienaar
cc9b6735a5 remove . from domain names
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-05-07 14:46:22 +02:00
R.I.Pienaar
0bc6ac2e14 small tweaks to domains
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-05-07 11:03:23 +02:00
Derek Collison
c2fcc114a5 Update based on PR feedback, moved to validateOptions
Signed-off-by: Derek Collison <derek@nats.io>
2021-05-06 20:10:44 -07:00
Derek Collison
0c74a850b5 Make storedir consistent with mix of flags etc 2021-05-06 18:46:32 -06:00
Derek Collison
ea5cddd590 Moved the JetStream logic for solicited leafnodes to after we receive first info.
We needed access to the other side's JetStream status.

Signed-off-by: Derek Collison <derek@nats.io>
2021-05-06 18:46:32 -06:00
Derek Collison
8499376575 Add in support for JetStream domains.
This allows a domain to be set in the JetStream server block that sets a domain name.
Once set this signals that any leafnode connections should operate as separate JetStream domains.
Each domain <NAME> is accessible via "$JS.<NAME>.API.>", even when connected to the same domain.
Also for mixed mode you can set a jetstream block now that defines a domain but specifies "enabled: false".

Signed-off-by: Derek Collison <derek@nats.io>
2021-05-06 18:46:32 -06:00
Derek Collison
0bd92e85da Add in formal support for multiple JetStream domains across leafnodes.
This CL adds in support for multiple JetStream domains using mapped subjects.
Mapping subjects aligns well with the JetStream context APIPrefix in clients.

Signed-off-by: Derek Collison <derek@nats.io>
2021-05-06 18:45:27 -06:00
Derek Collison
bd9a782701 Fixed issue when limiting bytes with an unlimited account that would always fail.
Signed-off-by: Derek Collison <derek@nats.io>
2021-05-05 07:04:24 -07:00
Derek Collison
d10b054f43 Update comment per feedback
Signed-off-by: Derek Collison <derek@nats.io>
2021-04-30 18:20:29 -07:00
Derek Collison
d43c818bf8 Make sure when we extend the JetStream domain with a single server leafnode we can place things there.
Signed-off-by: Derek Collison <derek@nats.io>
2021-04-30 18:18:16 -07:00
Derek Collison
8bf99224c5 This adds ability to have a single node server with a system leafnode expand an existing JetStream cluster domain.
Signed-off-by: Derek Collison <derek@nats.io>
2021-04-30 16:20:32 -07:00
scottf
486df98373 close tempfiles, fix path print 2021-04-22 12:47:21 -04:00
Waldemar Quevedo
c9ab7ce8a1 Fix for data race when disabling JS running out of resources
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-04-21 14:26:52 -07:00
Derek Collison
c0e8590c0f During startup each filtered consumer could do a linear scan of the stream
to determine number of messages pending. This improves that with a startup cache.

Signed-off-by: Derek Collison <derek@nats.io>
2021-04-07 09:15:01 -07:00
Derek Collison
c05ff97d09 Fixes based on PR feedback
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-25 18:09:35 -07:00
Derek Collison
da7b7f9f85 Make sure to configure global account for reload
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-25 18:06:14 -07:00
Derek Collison
e53caee5e8 Enforce server limits even when dynamic limits for accounts in play.
We were not properly enforcing server limits. This commit will allow a server to enforce limits but still remain functional even at the JetStream level.
Also fixed a bug for RAFT replay that could cause instability.

Signed-off-by: Derek Collison <derek@nats.io>
2021-03-25 16:06:27 -07:00
Derek Collison
2ed53035ed Reworked flow control for sources and mirrors.
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-24 07:07:33 -07:00
Derek Collison
d9b78b8bc4 Update info status for JetStream when disabling and restarting
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-20 09:07:47 -07:00
Derek Collison
cfe2f448ad Fix for when gateways were dropped and we did not detect interest returning.
Fix for leaked subscription when retrying the source consumers.
Better suppression of old messages from old direct consumers.

Signed-off-by: Derek Collison <derek@nats.io>
2021-03-20 08:44:18 -07:00
Derek Collison
61771e88f8 In operator mode with JetStream we want to load accounts that have stable storage.
Also if an account was registered but not JetStream enabled, update it vs error.

Signed-off-by: Derek Collison <derek@nats.io>
2021-03-20 06:53:13 -07:00
Derek Collison
8eefff2b3b Make sure the jetstream accounts use the name as the key to the map.
This prevents possible double adds under reload or restart scenarios.

Signed-off-by: Derek Collison <derek@nats.io>
2021-03-18 17:29:26 -07:00
R.I.Pienaar
ac70abdcf3 update banner url
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-03-17 16:39:24 +01:00
Derek Collison
2e9ae92bb5 Fix for #2011 and atomics on 32bit systems.
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-16 13:57:28 -07:00
Derek Collison
e530c98ebe We no longer force remove our peer on out of space.
We also delay restarting JetStream to make sure accounts are enabled.

Signed-off-by: Derek Collison <derek@nats.io>
2021-03-14 17:01:38 -07:00
Waldemar Quevedo
775afd01e7 Fix for JS reload and exports
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2021-03-14 15:16:56 -07:00
Derek Collison
e74eaa02c4 Suppress multiple out of space warnings
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-13 16:30:57 -05:00