Commit Graph

5289 Commits

Author SHA1 Message Date
Derek Collison
7dc99c3840 Merge from main
Signed-off-by: Derek Collison <derek@nats.io>
2022-01-13 10:01:33 -08:00
Ivan Kozlovic
c9c603b7a0 Merge pull request #2573 from julius-welink/implement-rate-limiting
[ADDED] TLS connection rate limiter
2022-01-13 10:35:19 -07:00
Derek Collison
6619e7f13d Merge branch 'main' into pull-consumer 2022-01-13 09:14:33 -08:00
Derek Collison
165895906b Merge pull request #2781 from nats-io/rebuild-deadlock
When rebuilding the complete filestore state we need to do this in a go routine.
2022-01-13 08:05:56 -08:00
Waldemar Quevedo
0885ba247f Merge pull request #2782 from nats-io/js-and-monitoring
Start monitoring before JetStream during startup.
2022-01-13 07:13:39 -08:00
Waldemar Quevedo
ce4e4b5d47 Start monitoring before JetStream
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2022-01-12 21:38:22 -08:00
Matthias Hanel
3fa7adbc43 Merge pull request #2779 from nats-io/max-bytes
[Adding] support for JS MaxBytesRequired
2022-01-12 23:31:42 -05:00
Derek Collison
420a2ef514 When rebuilding the complete state need to do this in a go routine.
We did this properly above but forgot this one.

Signed-off-by: Derek Collison <derek@nats.io>
2022-01-12 20:19:45 -08:00
Derek Collison
103f710479 Fixed consumer info num pending bug.
Under load we could have a message committed to the underlying store when a consumer was being created and then it increase num pending again when the stream signals the consumers.
This fix just remembers the last seq of the state when we calculate sgap and test before adding in the stream code.

Signed-off-by: Derek Collison <derek@nats.io>
2022-01-12 20:03:26 -08:00
Ivan Kozlovic
d63bc726c9 Merge pull request #2780 from nats-io/raft_updates
[IMPROVED] JetStream clustering with lots of streams/consumers
2022-01-12 21:02:49 -07:00
Matthias Hanel
78bbcd791f [Adding] support for JS MaxBytesRequired
Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-01-12 22:57:34 -05:00
Ivan Kozlovic
a7554bd5dd Merge pull request #2777 from hooksie1/2754
[ADDED] Ability to express the max_file_store and max_memory_store as a string (100M, etc..)
2022-01-12 20:41:38 -07:00
Ivan Kozlovic
ffe50d8573 [IMPROVED] JetStream clustering with lots of streams/consumers
Some operations could cause the route to block due to lock being
held during store operations. On macOS, having lots of streams/consumers
and restarting the cluster would cause lots of concurrent IO that
would cause lock to be held for too long, causing head-of-line
blocking in processing of messages from a route.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-01-12 20:37:00 -07:00
Derek Collison
43eff407b8 Add in explicit subscription for import responses when bound to a leafnode.
When we want to track service import response interest across a leafnode we need to send sub and unsub for all response _R_ subjects versus using a wildcard.

Signed-off-by: Derek Collison <derek@nats.io>
2022-01-12 18:24:03 -08:00
John Hooks
0b77d51905 Remove switch
Removes switch statement and uses map for finding correct multiple

Also uses ParseInt instead of Atoi for getting string integer.
2022-01-12 21:07:07 -05:00
John Hooks
4aa6c62bbc Fix non used error 2022-01-12 18:03:24 -05:00
John Hooks
d956d6d398 Review
Rename function
More easily read math
merged functions together
Changed from predefining error
Fix empty string issue
use same function for max mem store
2022-01-12 17:55:57 -05:00
Derek Collison
32c3c9ecfb Track interest properly across accounts for pull consumers
Signed-off-by: Derek Collison <derek@nats.io>
2022-01-12 12:16:53 -08:00
John Hooks
12f8179fd8 Add parsing of string for sizes
Checks the suffix of the string to create the size of the int64
2022-01-11 22:13:20 -05:00
John Hooks
d10c306585 Check if value is string or int64 2022-01-11 21:06:26 -05:00
Julius Žaromskis
a47e5e045c [ADDED] TLS connection rate limiter 2022-01-11 16:57:19 +02:00
Derek Collison
279f31ecb5 Add in ability to have ephemeral pull based consumers
Signed-off-by: Derek Collison <derek@nats.io>
2022-01-10 20:42:39 -08:00
Derek Collison
e12c8cda92 Add in ability to limit aspects of a pull request, specifically batch size and expiration.
Signed-off-by: Derek Collison <derek@nats.io>
2022-01-10 17:29:04 -08:00
Derek Collison
5592d923c4 Updated pull consumers.
Cleaned up code, made more consistent, utilize loopAndGather.
Allow pull consumers to have AckAll as well as AckExplicit.

Signed-off-by: Derek Collison <derek@nats.io>
2022-01-10 16:59:01 -08:00
Derek Collison
42818f06c1 Update client
Signed-off-by: Derek Collison <derek@nats.io>
2022-01-10 16:58:52 -08:00
Derek Collison
08ff14a24e Merge pull request #2771 from nats-io/overflow
Implement overflow placement for JetStream streams.
2022-01-07 11:03:15 -08:00
Derek Collison
d02ad88297 Only report peers that we have seen a stats/usage update for
Signed-off-by: Derek Collison <derek@nats.io>
2022-01-07 10:42:06 -08:00
Derek Collison
16f5c95785 Update atomics placements based on feedback
Signed-off-by: Derek Collison <derek@nats.io>
2022-01-07 09:50:19 -08:00
Derek Collison
de5022ad7e Make cluster placement log more detailed
Signed-off-by: Derek Collison <derek@nats.io>
2022-01-07 07:44:30 -08:00
Derek Collison
52da55c8c6 Implement overflow placement for JetStream streams.
This allows stream placement to overflow to adjacent clusters.
We also do more balanced placement based on resources (store or mem). We can continue to expand this as well.
We also introduce an account requirement that stream configs contain a MaxBytes value.

We now track account limits and server limits more distinctly, and do not reserver server resources based on account limits themselves.

Signed-off-by: Derek Collison <derek@nats.io>
2022-01-06 19:33:08 -08:00
Ivan Kozlovic
ccc9e1621d Merge pull request #2769 from nats-io/ws_x_forwarded_for_changes
Add X-Forwarded-For IP to the client's remote address
2022-01-04 10:14:49 -07:00
Ivan Kozlovic
8d6eacc245 Add X-Forwarded-For IP to the client's remote address
Instead of replacing connection's host with value specified by
this header, we will simply add the address to the logging only.
So instead of having something like:
```
192.168.1.1:5678 - wid:10 - Client connection created
```
we could have:
```
1.2.3.4/192.168.1.1:5678 - wid:10 - Client connection created
```
As seen above, this PR simply prefixes the connection's remote address
with the header's value (if a valid IP).

Related to #2734
Resolves #2767

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-01-03 11:56:12 -07:00
Derek Collison
fbcf1aba30 Merge pull request #2766 from kfabryczny/fix_doc_link
FIX: Fix broken link to monitoring documentation
2021-12-30 08:38:25 -08:00
Klaudiusz Fabryczny
b2b33110e2 FIX: Fix broken link to monitoring documentation 2021-12-30 14:04:12 +01:00
Derek Collison
4c640113bb Merge pull request #2765 from nats-io/race-usage
Avoid race condition
2021-12-29 15:09:57 -08:00
Derek Collison
5932fa1852 Avoid deadlock, release js lock
Signed-off-by: Derek Collison <derek@nats.io>
2021-12-29 10:46:53 -08:00
Derek Collison
1a37f0963a Avoid race condition
Signed-off-by: Derek Collison <derek@nats.io>
2021-12-29 08:26:10 -08:00
Derek Collison
bd495f3b18 Merge pull request #2764 from nats-io/issue-2742
Large number of ephemeral consumers could exhaust Go runtime's max OS threads.
2021-12-29 07:42:30 -08:00
Derek Collison
c5fbb63614 JetStream ephemeral consumers could create a situation where the server would exhaust the OS thread limit - default 10k.
Under certain situations large number of consumers that are racing to update state or delete their stores during a delete
would start taking up OS threads due to blocking disk IO. When this happened and their were a bunch of Go routines becoming
runnable the Go runtime would create extra OS threads to fill in the runnable pool and would exhaust the max thread setting.

This code places a channel as a simple semaphore to limit the number of disk IO blocking OS threads.

Signed-off-by: Derek Collison <derek@nats.io>
2021-12-29 07:05:34 -08:00
Derek Collison
36d34492cd Bump to 2.7.0-beta
Signed-off-by: Derek Collison <derek@nats.io>
2021-12-27 12:04:39 -08:00
Derek Collison
34555aecca Merge pull request #2761 from nats-io/fs_partial_err
Fix for when consumer would stop working due to errPartialCache returned from fileStore.
2021-12-27 12:03:31 -08:00
Derek Collison
b7c61cd0bf Stabilize filstore to eliminate sporadic errPartialCache errors under certain situations. Related to #2732
The filestore would release a msgBlock lock while trying to load a cache block if it thought it needed to flush pending data.
With async false, this should be very rare but was possible after careful inspection.

I constructed an artificial test with sleeps throughout the filestore code to reproduce.
It involved having 2 Go routines that were through and waiting on the last msg block, and another one that was writing.
After the write, but before we flushed after releasing the lock we would also artificially sleep.
This would lead to the second read seeing the cache load was already in progress and return no error.
If the load was for a sequence before the current write sequence, and async was false, the cache fseq would be higher than what was requested.
This would cause the errPartialCache to be returned.

Once returned to the consumer level in loopAndGather, it would exit that Go routine and the consumer would cease to function.

This change removed the unlock of a msgBlock to perform and flush, ensuring that two cacheLoads would not yield the errPartialCache.

I also updated the consumer in the case this does happen in the future to not exit the loopAndGather Go routine.

Signed-off-by: Derek Collison <derek@nats.io>
2021-12-27 09:54:02 -08:00
Matthias Hanel
42ae3f5325 Merge pull request #2757 from nats-io/sys-acc-err
Fixed system account issue where the wrong struct got updated
2021-12-23 12:13:25 -05:00
Derek Collison
89b94ae650 Improved selectMsgBlock with lots of messages. Also have fetchMsg return hint about clearing cache.
Signed-off-by: Derek Collison <derek@nats.io>
2021-12-22 17:45:12 -08:00
Matthias Hanel
fe5f47f43b Fixed system account issue where the wrong struct got updated
s.fetchAccount should not be used for the system account,
 as it creates a new struct

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-12-22 16:18:00 -05:00
Derek Collison
91042b399f Merge pull request #2755 from nats-io/acc_config_limits
Added in ability to have account limits configured in server config.
2021-12-21 19:50:38 -08:00
Derek Collison
3619241326 Merge pull request #2756 from nats-io/xacc_interest
Added test to show cross account interest for push consumers works.
2021-12-21 19:49:25 -08:00
Derek Collison
c4198d603c Added test to show cross account interest for push consumers works
Signed-off-by: Derek Collison <derek@nats.io>
2021-12-21 19:30:35 -08:00
Derek Collison
b43cb5b352 Added in ability to have account limits configured in server config.
Signed-off-by: Derek Collison <derek@nats.io>
2021-12-21 18:31:07 -08:00
Ivan Kozlovic
8203a083d6 Merge pull request #2753 from nats-io/fs_remove_last
[FIXED] JetStream: stream first/last sequence possibly reset
2021-12-21 09:15:55 -07:00