Commit Graph

1435 Commits

Author SHA1 Message Date
Matthias Hanel
bf952a3807 Adding option to enable tracing the system account. (default: false)
Use sys_trace option in config file or --sys_trace on the command line

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-03-01 19:42:40 -05:00
Derek Collison
087854c9d8 Rename to ClientIP for INFO
Signed-off-by: Derek Collison <derek@nats.io>
2020-02-29 13:23:22 -08:00
Derek Collison
d521e1594d Place server's version of client IP in INFO
Signed-off-by: Derek Collison <derek@nats.io>
2020-02-28 18:27:08 -08:00
Ivan Kozlovic
7ab9c76f2b Fixed benchmark tests to be able to run with Go 1.13+
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-02-26 12:12:18 -07:00
Matthias Hanel
2754968e33 Renaming IsErr to ErrorIs
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-25 19:53:09 -05:00
Matthias Hanel
b6d5906154 Only use errors.Is backwards compatibility code, delete gobackcomp pkg
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-25 19:26:17 -05:00
Matthias Hanel
b57ea29002 Add missing delete from rename
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-25 18:35:11 -05:00
Matthias Hanel
5b8e7c1a41 Deleting dead code
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-25 18:16:50 -05:00
Matthias Hanel
d8297ddf41 Adding a go version compatibility package.
Currently enables Errors.Is functionality as ErrorsIs.
Using this functionality in errors.go and unit tests.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-25 18:08:04 -05:00
Matthias Hanel
c18a5a2582 Fixing typos, copyright date and changed type in log.go/Error func
added comment and changed type Error(c,sc)

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-24 19:37:25 -05:00
Matthias Hanel
d1d34d2638 Suggestion to improve tracing in nats-server through wrapping errors
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-24 16:00:46 -05:00
Ivan Kozlovic
62bacf1044 Merge pull request #1283 from nats-io/fix_flappers
Fixed flappers
2020-02-19 19:32:29 -07:00
Ivan Kozlovic
37291df206 Fixed yet another flapper
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-02-19 17:33:16 -07:00
Ivan Kozlovic
156bf7b381 Updates based on code review
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-02-19 16:52:41 -07:00
Ivan Kozlovic
8e4b449119 Fixed flappers
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-02-19 13:19:08 -07:00
Matthias Hanel
329cc7225b Use constant for error
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-18 10:54:12 -05:00
Matthias Hanel
82a275943e Fix unreliable test
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-17 20:22:52 -05:00
Matthias Hanel
db83b8a55a Avoid all else and adhere to general style. Adding Flush as requested.
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-17 16:52:13 -05:00
Matthias Hanel
f7a84e3662 Removed unnecessary else
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-17 14:03:30 -05:00
Matthias Hanel
3fbf8cac2e parse ping_interval as duration, else assume seconds and warn
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-17 12:59:34 -05:00
Ivan Kozlovic
c22b2c097d Merge pull request #1276 from nats-io/fix_lame_duck_mode_shutdown
[FIXED] Server that is sent the lame duck mode signal does not exit
2020-02-10 18:13:49 -07:00
Ivan Kozlovic
a6874b2107 [FIXED] Server that is sent the lame duck mode signal does not exit
Resolves #1275

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-02-10 17:35:40 -07:00
Matthias Hanel
c7e4d261f4 recover from error during parsing or reload will cause a crash
Keep track of the last token used.
When recovering from a panic, create a configErr use that token.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-02-10 18:51:12 -05:00
Matthias Hanel
82ebe084c9 recover from error during parsing or reload will cause a crash
This will also result in a line number where the issue is
2020-02-07 18:18:22 -05:00
Ivan Kozlovic
7208e7f817 [ADDED] Ability to specify TLS configuration for account resolver
A new config section allows to specify specific TLS parameters for
the account resolver:
```
resolver_tls {
  cert_file: ...
  key_file: ...
  ca_file: ...
}
```

Resolves #1271

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-02-03 14:35:05 -07:00
Ivan Kozlovic
2e2f94edea Release 2.1.4
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-29 16:35:59 -07:00
Ivan Kozlovic
27ae160f75 Use CID and LeafNodeURLs as an indicator connected to proper port
First, the test should be done only for the initial INFO and only
for solicited connections. Based on the content of INFO coming
from different "listen ports", use the CID and LeafNodeURLs for
the indication that we are connected to the proper port.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-29 14:43:41 -07:00
Waldemar Quevedo
ecb5008fe3 Add check prevent leafnode connecting to client port
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2020-01-28 12:43:27 -08:00
Ivan Kozlovic
47b08335a4 [FIXED] Reset of tlsName only for x509.HostnameError
For issue #1256, we cleared the possibly saved tlsName on Hanshake failure.
However, this meant that for normal use cases, if a reconnect failed for
any reason we would not be able to reconnect if it is an IP until we get
back to the URL that contained the hostname.

We now clear only if the handshake error is of x509.HostnameError type,
which include errors such as:
```
"x509: Common Name is not a valid hostname: <x>"
"x509: cannot validate certificate for <x> because it doesn't contain any IP SANs"
"x509: certificate is not valid for any names, but wanted to match <x>"
"x509: certificate is valid for <x>, not <y>"
```

Applied the same logic to solicited gateway connections, and fixed the fact
that the tlsConfig should be cloned (since we set the ServerName).

I have also made a change for leafnode connections similar to what we are
doing for gateway connections, which is to use the saved tlsName only if
tlsConfig.ServerName is empty, which may not be the case for users that
embed NATS Server and pass directly tls configuration. In other words,
if the option TLSConfig.ServerName is not empty, always use this value.

Relates to #1256

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-28 13:16:38 -07:00
Derek Collison
b1fc364a6c Merge pull request #1261 from nats-io/mixed
Fix for #1256
2020-01-22 12:01:38 -08:00
Derek Collison
643e73c0c5 Fix for #1256, mixed IP and DNS for cluster and TLS with leafnodes
Signed-off-by: Derek Collison <derek@nats.io>
2020-01-22 11:25:09 -08:00
Ivan Kozlovic
20768b72c3 [FIXED] Display of connections address when using IPv6
When the server logs information related to a connection, it uses
the connection IP and remote port as a prefix. When it was an IPv6
address, the square brackets would be missing.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-22 09:12:39 -07:00
Ivan Kozlovic
e94f1b7afb Remove debug trace in writeLoop
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-17 12:09:39 -07:00
Ivan Kozlovic
bd28a015b1 [FIXED] Sublist isSubsetMatch to handle empty tokens
If a subject has empty tokens, returns false.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-14 18:28:14 -07:00
Ivan Kozlovic
1f91dab547 Bump version to 2.1.3-RC04
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-10 16:21:26 -07:00
Ivan Kozlovic
85a4c6d17a Updates based on code review
- Use const maxWait=3sec that is used to create and reset the timer
- Remove the lastReport check

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-10 15:58:58 -07:00
Ivan Kozlovic
0e4369cb6a Replace sync.Cond with go channel for writeLoop notification
Also make the wait bound to 3secs after which writeLoop will attempt
to flush. Will log if it timed out on the wait and entering with
fsp > 0. Limit the report to once every 10 minutes

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-10 14:19:10 -07:00
Ivan Kozlovic
971d2350ed Fixed client stalled duration computation and added back Gosched()
This related to PR #1233.

The computation of the time to stall a fast producer was bogus. Fixed
that and added a unit test for the function computing this stalled
duration.

Also, in PR #1233, I had removed Gosched() when a call to flushOutbound()
realizes that the flag is already set. It was forgetting that readLoop
in some cases will call flushOutbound() in place. So there is still
value in unlock/gosched/lock again in that function.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-10 11:21:38 -07:00
Ivan Kozlovic
c097357b52 [FIXED] More than expected switch to Interest-Only mode for account
When an account is switched to interest-only mode due to no interest,
it was not possible to switch that account more than once. But the
function switchAccountToInterestMode() that triggers a switch could
possibly doing it more than once. This should not cause problems
but increased the number of traces in a big super cluster.

Also fixed some flappers and a data race.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-09 13:35:08 -07:00
Ivan Kozlovic
0335f1dee5 Bump to version 2.1.3-RC03
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-07 14:59:10 -07:00
Ivan Kozlovic
8abc508574 Merge pull request #1233 from nats-io/all_writes_from_write_loop
[UPDATED] TCP Write and SlowConsumer handling
2020-01-07 12:12:28 -07:00
Ivan Kozlovic
b42856afa2 Set expectConnect flag for CLIENT only if auth required
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-07 10:48:11 -07:00
Ivan Kozlovic
c73be88ac0 Updated based on comments
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-06 16:57:48 -07:00
Ivan Kozlovic
99d8eb4c55 [FIXED] Do not check URL account resolver reachability on reload
On config reload, the URL account resolver was recreated and a
Fetch() with empty account was done. Move the empty fetch test
in NewServer() instead.
Added a test that shows that fetch is no longer invoked on reload
but server reports failure on startup.

Resolves #1229

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-01-06 13:47:39 -07:00
Ivan Kozlovic
947798231b [UPDATED] TCP Write and SlowConsumer handling
- All writes will now be done by the writeLoop, unless when the
  writeLoop has not been started yet (likely in connection init).
- Slow consumers for non CLIENT connections will be reported but
  not failed. The idea is that routes, gateway, etc.. connections
  should stay connected as much as possible. However if a flush
  operation times out and no data at all has been written, the
  connection will be closed (regardless of type).
- Slow consumers due to max pending is only for CLIENT connections.
  This allows sending of SUBs through routes, etc.. to not have
  to be chunked.
- The backpressure to CLIENT connections is increased (up to 1sec)
  based on the sub's connection pending bytes level.
- Connection is flushed on close from the writeLoop as to not block
  the "fast path".

Some tests have been fixed and adapted since now closeConnection()
is not flushing/closing/removing connection in place.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-12-31 15:06:27 -07:00
Derek Collison
773fc16cfd Remove unused input variable
Signed-off-by: Derek Collison <derek@nats.io>
2019-12-16 17:50:16 -06:00
Derek Collison
4a4e122291 Fix to testing for equal stream imports
Signed-off-by: Derek Collison <derek@nats.io>
2019-12-16 17:47:22 -06:00
Derek Collison
a2ebf08593 Should allow multiple stream imports on same subject
Signed-off-by: Derek Collison <derek@nats.io>
2019-12-14 17:06:14 -08:00
Ivan Kozlovic
1b2754475b Refactor async client tests
Updated all tests that use "async" clients.
- start the writeLoop (this is in preparation for changes in the
  server that will not do send-in-place for some protocols, such
  as PING, etc..)
- Added missing defers in several tests
- fixed an issue in client.go where test was wrong possibly causing
  a panic.
- Had to skip a test for now since it would fail without server code
  change.

The next step will be ensure that all protocols are sent through
the writeLoop and that the data is properly flushed on close (important
for -ERR for instance).

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-12-12 11:58:24 -07:00
Derek Collison
ffc3c0da70 Fixed #1144, qsub performance improvements
Signed-off-by: Derek Collison <derek@nats.io>
2019-12-09 22:08:59 +01:00