Commit Graph

1317 Commits

Author SHA1 Message Date
Derek Collison
d9bf0fda64 Bump version [ci ckip]
Signed-off-by: Derek Collison <derek@nats.io>
2019-11-16 18:34:46 -08:00
Derek Collison
7b1bea61e2 Merge pull request #1192 from nats-io/load_account
Do not fetch accounts on system events.
2019-11-16 18:33:23 -08:00
Derek Collison
f60266bc2e Merge pull request #1190 from nats-io/import_reply
Introduced wildcard handling of _R_ mapped replies.
2019-11-16 18:07:18 -08:00
Derek Collison
093b57ed40 Do not fetch accounts on system events.
Noticed we would lookup accounts, but would also fetch them when tracking remote connections, etc.

Signed-off-by: Derek Collison <derek@nats.io>
2019-11-16 18:05:42 -08:00
Ivan Kozlovic
263d3d868e Use special client to send route interest on wildcard _R_
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-16 18:56:59 -07:00
Derek Collison
b2cbde2616 Match comment about hash size
Signed-off-by: Derek Collison <derek@nats.io>
2019-11-16 17:56:06 -08:00
Ivan Kozlovic
0bfd03091b Clean tmp accounts map when race gets duplicate
Added check to the test to ensure that tmp map is empty.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-16 18:14:23 -07:00
Ivan Kozlovic
9b837813b1 Process service replies in gateway inbound
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-16 17:43:44 -07:00
Ivan Kozlovic
3e1728d623 [FIXED] Some accounts locking issues
- Risk of deadlock when checking if issuer claim are trusted. There
  was a RLock() in one thread, then a request for Lock() in another
  that was waiting for RLock() to return, but the first thread was
  then doing RLock() which was not acquired because this was blocked
  by the Lock() request (see e2160cc571)

- Use proper account/locking mode when checking if stream/service
  exports/signer have changed.

- Account registration race (regression from https://github.com/nats-io/nats-server/pull/890)

- Move test from #890 to "no race" test since only then could it detect
  the double registration.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-16 16:59:38 -07:00
Derek Collison
abc7074d86 Fix race
Signed-off-by: Derek Collison <derek@nats.io>
2019-11-16 14:03:03 -08:00
Derek Collison
747ba1dc09 Change , remove T placeholder, 8 to 6 on hash len
Signed-off-by: Derek Collison <derek@nats.io>
2019-11-16 13:06:56 -08:00
Derek Collison
6ad8287bbe Introduced wildcard handling of _R_ mapped replies.
We had too much special processing, so reduced to a single wildcard
which will propagate across routes and gateways and is consistent
with gateway handling of globally routed subjects and timeouts.

Signed-off-by: Derek Collison <derek@nats.io>
2019-11-16 12:50:53 -08:00
Derek Collison
d5a8f0ef24 Merge pull request #1189 from nats-io/panic
Fix possible panic on nil sublist.
2019-11-15 17:51:34 -08:00
Derek Collison
954a780421 Fix possible panic on nil sublist.
We may have the case that the account is held in tmpAccounts but does not have a sublist. When this happens if we process as RS+ and do LookupAccount and get it from the tmpAccount and before it was registered the route code could try to do an insert on the sl.

Signed-off-by: Derek Collison <derek@nats.io>
2019-11-15 17:11:52 -08:00
Ivan Kozlovic
d85f9a9388 Fixed bug with duplicate route and GW replies
When a duplicate route is detected and closed, we need to clear
the route's hash in order to prevent the removal from the
server's routeByHash map.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-15 17:24:50 -07:00
Ivan Kozlovic
d046f7945f Bump defaultGatewayRecentSubExpiration and RC2
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-15 10:06:38 -07:00
Ivan Kozlovic
c2d1b0becd Merge pull request #1186 from nats-io/invoke_shutdown_on_ctrl_c
Shutdown on Ctrl+C
2019-11-14 20:12:58 -07:00
Ivan Kozlovic
bdf5cf63b3 Shutdown on Ctrl+C
Changed code on Windows to not use svc code if running in interactive
mode. The original code was running svc.debug.Run() which uses service
code (Execute()) but from the command line. We don't need that.

Also reduced salt on bcrypt password for a config file that started
to cause failures due to test taking too long to finish.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-14 20:05:32 -07:00
Derek Collison
afeaebb676 Bumped to 2.1.1-RC1 [ci ckip]
Signed-off-by: Derek Collison <derek@nats.io>
2019-11-14 16:29:28 -08:00
Derek Collison
c2d2307670 Some tweaks for performance
Signed-off-by: Derek Collison <derek@nats.io>
2019-11-14 14:19:50 -08:00
Derek Collison
3330820502 Fixed a bug where we leaked service imports. Also prior this would have leaked subscriptions as well.
Signed-off-by: Derek Collison <derek@nats.io>
2019-11-14 13:29:17 -08:00
Ivan Kozlovic
3e5ede1d64 Relax check on reserved GW prefix for system clients
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-11 17:43:14 -07:00
Ivan Kozlovic
b561bde366 Alternate approach to GW reply mapping expiration
Use centralized sync map to gather *client that have GW replies.
Tested with concurrent receiving clients and perf is as good as
with timer per client but reduces need of that timer per client
object.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-11 13:36:24 -07:00
Ivan Kozlovic
cacfb4a08c Fix some gateway tests
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-08 19:07:57 -07:00
Ivan Kozlovic
8a8695d07c Backward compatibility with previous servers
Want to keep this commit separate so that we can easily remove
when we no longer want to support both prefixes.

- If this server receives a "$GR." message, it takes the subject
  and tries to process this locally. If there is no cluster race
  reply may be received ok (like before).
- If this server sends a routed reply, it detects if sending to
  an older server (then uses $GR.) or not (then uses $GNR)
- Gateway INFO has a new field that indicates if the server is
  using the new prefix.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-08 16:22:34 -07:00
Ivan Kozlovic
9b7dab0548 Updates based on code review
- Add atomic in client to skip check in processInboundClientMsg()
  if value is 0. Avoids getting the lock in fast path if not needed.
- Have a timer per client instead of the global server list that
  was expiring: noticed a lot of contention there when running
  some perf/profiling tests. The timer is also not reset for
  every timestamp that is not yet expired since this too affects
  performance. Instead fires are regular interval and cleared
  when map is empty after a cycle.
- Move processing of gw map rely on its own function (in inbound msg).
  I have verified that this is inlined same way as when code was
  directly in processInboundClientMsg.
- Use string(subj[]) for prefix detection: I have verified that
  it is actually faster.
- Builds the RMSG with appends to local buffer in handleGatewayReply()
  instead of using fmt.Sprintf().

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-08 15:56:28 -07:00
Ivan Kozlovic
aa843945c9 Work on Gateways reply mapping
- New prefix that includes origin server for the request
- Mapping done if request is service import or requestor has
  recent subscription
- Subscription considered recent if less than 250ms
- Destination server strip GW prefix before giving to client
  and restore when getting a reply on that subject
- Mapping removed aftert 250ms
- Server rejects client publish on "$GNR." (the new prefix)
- Cluster and server hash are now 8 chars long and from base 62
  alphabets
- Mapped replies need to be sent to leafnode servers due to race
  (cluster B sends RS+ on GW inbound then RMSG on outbound, the
  RS+ may be processed later and cluster A may have given message
  to LN before RS+ on reply subject. So LN needs to accept the
  mapped reply but will strip to give to client and reassemble
  before sending it back)

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-11-06 16:06:49 -07:00
Derek Collison
8a69c5cb71 Updates to benchmarks
Allow disabling of short first ping timer for clients.
Adjust names so that full test suite results are aligned.
Removed the account lookup, we use sync.Map but also a no-lock cache.

Signed-off-by: Derek Collison <derek@nats.io>
2019-11-02 08:04:22 -07:00
Derek Collison
f0f807f99a After speaking with Ivan we are taking a better approach for initial RTT.
Ivan had the idea of using the CONNECT to establish a first estimate of RTT
without additional PING/PONGs.

Signed-off-by: Derek Collison <derek@nats.io>
2019-10-31 14:01:55 -07:00
Derek Collison
13f217635f Wait on requestor RTT when tracking latency.
If a client RTT for a requestor is longer than a service RTT, the requestor latency was often zero.
We now wait for the RTT (if zero) before sending out the metric.

Signed-off-by: Derek Collison <derek@nats.io>
2019-10-31 08:02:45 -07:00
Ivan Kozlovic
eb1c2ab72a Merge pull request #1175 from nats-io/fix_1174
[FIXED] Server should not send RTT PING before sending initial PONG
2019-10-30 20:36:07 -06:00
Ivan Kozlovic
2706a15590 Merge pull request #1177 from nats-io/prevent_ln_update_before_all_subs_sent
Some update to leafnode subscription handling
2019-10-30 20:35:07 -06:00
Ivan Kozlovic
0da1afaf88 Fixed data race
Resolves #1176

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-30 20:10:37 -06:00
Ivan Kozlovic
cbbc21ac25 Some update to leafnode subscription handling
- Send all subs in place if smap is small
- Skip sending update until after sendAllLeafSubs() is done

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-30 20:01:49 -06:00
Ivan Kozlovic
17a7d0d866 [FIXED] Server should not send RTT PING before sending initial PONG
As soon as server has processed a client CONNECT, it was possible
that if Connz() or other was requested, the server will send a
PING to compute the RTT. This would cause clients that expect
the first PONG as part of synchronous CONNECT logic to fail.

Make sure that we delay the first RTT ping to after sending the
first PONG, or if client does not send PING as part of the CONNECT,
after 2 seconds have elapsed since the tcp connection was accepted.

Resolves #1174

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-30 19:50:19 -06:00
Ivan Kozlovic
51f83220c6 Fix race introduced in #1170
Code for leafnode loop detection had a data race.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-29 19:09:21 -06:00
Ivan Kozlovic
6bcb717722 Updates following code review
- Make "lds." a constant
- Create remote's get/reset functions for loop delay
- Bump loop delay to 30 seconds

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-29 17:59:15 -06:00
Ivan Kozlovic
279cab2aaf [FIXED] Detect loop between LeafNode servers
This is achieved by subscribing to a unique subject. If the LS+
protocol is coming back for the same subject on the same account,
then this indicates a loop.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-29 16:14:35 -06:00
Ivan Kozlovic
e126a1f9d8 Merge pull request #1169 from nats-io/fix_monitor_link
[UPDATED] Link to monitoring page in new doc [ci skip]
2019-10-29 15:07:52 -06:00
Ivan Kozlovic
280c432787 [UPDATED] Link to monitoring page in new doc [ci skip]
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-29 14:48:12 -06:00
Ivan Kozlovic
07bf4a499e Issue with multiple users in Leafnode authorization
This was introduced in master #1147, not in any public release.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-29 13:34:30 -06:00
Ivan Kozlovic
d20f76cbaa Merge pull request #1166 from nats-io/add_servername_to_routestat
[ADDED] Server name in the RouteStat for statsz
2019-10-28 13:19:53 -06:00
Ivan Kozlovic
5a44e3b4c6 Changes on how tests can override route protocol
I may need to introduce a new route protocol version for an upcoming
PR and realized that this needed some cleaning.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-26 10:12:30 -06:00
Ivan Kozlovic
12eb1f5b00 [ADDED] Server name in the RouteStat for statsz
Add the remote server name for a route in the statsz event

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-25 16:34:07 -06:00
Ivan Kozlovic
75ec78c232 [FIXED] Explicit gateway not using discovered URLs
If cluster A configures a gateway to cluster B, the server on A
tries to connect to that server URL. If there is no server on B
at that address, but a server on B with different address connects
to server on cluster A, that server should be able to create its
outbound connection in response.
That was not the case because the configured URLs were snapshot
before the loop of trying to connect. When accepting an inbound
connection and updating the array, this new URL was not being used.

The issue is only if the server on A had no outbound connection
at that time.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-24 16:40:38 -06:00
Ivan Kozlovic
27ee8b80e3 Fixed nil dereference reported by staticcheck
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-24 15:07:06 -06:00
Derek Collison
daabd4dfde Merge pull request #1158 from ripienaar/1153.hostname
Allows a descriptive server_name to be set
2019-10-17 10:31:41 -07:00
R.I.Pienaar
bcf96fa1de Allows a descriptive server_name to be set
This adds a new config option server_name that
when set will be exposed in varz, events and more
as a descriptive name for the server.

If unset though the server_name will default to the pk

Signed-off-by: R.I.Pienaar <rip@devco.net>
2019-10-17 18:51:19 +02:00
Derek Collison
35758ef7d4 Update the test CA and certs.
Expiration is now Oct 14 14:30:41 2029 GMT

Signed-off-by: Derek Collison <derek@nats.io>
2019-10-17 07:33:08 -07:00
Derek Collison
9192a1f43c Fix for panic on #1159, do not allow wildcards in stream import prefix
Signed-off-by: Derek Collison <derek@nats.io>
2019-10-16 10:29:13 -07:00