Commit Graph

390 Commits

Author SHA1 Message Date
Ivan Kozlovic
3850b05388 Fix data race
When processing a connect request, there was a risk of race condition
when the server was being shutdown. Capture fields that are checked
under lock and lock when setting the route's remote ID.

Resolves #255
2016-04-22 17:28:41 -06:00
Ivan Kozlovic
3a999c1299 Add tracking of most go routines started by the server
Refactor the way client is initialized. We need to ensure that
clients are not added to the clients map and readLoop started if
the server is in the process of being shutdown otherwise there
is a chance that the server already gathered the list of connections
to close and this one would not be included, leaving a readLoop
running.
Same occurs for routes, with the complexity that the readLoop is
started well before the route connection is added to the server
routes' list. We need a temporary map that contains those connections
to be able to close them on server Shutdown.

Fixed some flapping tests.
2016-04-21 11:48:39 -06:00
Ivan Kozlovic
3aa09ecc01 Ensure Shutdown() waits for outstanding routes go routines
We need to make sure that when Shutdown() returns, routes go routines
that try to connect or reconnect have returned. Otherwise, this may
affect tests running one after the other (a server from one test
may connect to a server in the next test).
2016-04-21 11:48:39 -06:00
Derek Collison
5bea74c2ed Rename and move some things around 2016-04-21 09:33:26 -07:00
Derek Collison
6004a4e528 Update copyright 2016-04-18 20:31:56 -07:00
Derek Collison
34a75bbe15 Merge pull request #249 from nats-io/win-pse
Windows procUsage implementation and test
2016-04-18 20:30:46 -07:00
Derek Collison
f60119d332 Add in auto release builds, matrix and coverage for only one run 2016-04-18 20:00:02 -07:00
Colin Sullivan
b40cb9704d Use Argv[0] to get process ID, test updates, increase coverage. 2016-04-18 15:40:00 -06:00
Colin Sullivan
be6416c832 Windows PS Emulation and Test 2016-04-18 10:09:00 -06:00
Derek Collison
0cb85b18ec remove need for atomic 2016-04-15 18:32:19 -07:00
Derek Collison
b3388db53f Enable dynamic write buffers for client connections 2016-04-15 18:16:13 -07:00
Derek Collison
4f333416bb Revert race on interest graph since it could cause dropped interest propogation, fix test instead 2016-04-15 15:46:29 -07:00
Derek Collison
3e2c3714bc Fix race in interest propogation to new routes 2016-04-15 13:16:13 -07:00
Derek Collison
433d62ec0a Parse IPs and raw strings in arrays properly 2016-04-07 08:36:57 -07:00
Justin Nuß
e4d111fa0a Remove allocation when inserting into sublist 2016-04-06 14:15:26 +02:00
Justin Nuß
4bf0b47e74 Remove unnecessary string allocation 2016-04-05 15:25:55 +02:00
Derek Collison
0bb362601e Revert back to ps callout.
Going back to ps callout on MacOSX to avoid cgo for pending
changes to release process.
2016-04-04 18:50:13 -07:00
Derek Collison
6ce89066fb race fix 2016-04-03 14:40:45 -07:00
Derek Collison
768f23b5b4 dynamic read buffers 2016-04-03 14:30:17 -07:00
Derek Collison
96d9ce5048 Queue subscriber performance
Reworked sublist to sort out normal subscribers from queue subscribers into
a result set that can be cached and easily iterated over.
2016-04-03 13:04:06 -07:00
Derek Collison
d0a9a47ea3 L1 client cache for sublist and accounting optimizations 2016-04-03 05:41:45 -07:00
Derek Collison
df02bc0bcf Removed sublist, hash and hashmap, no longer needed. 2016-04-02 12:52:48 -07:00
Derek Collison
f23f55518c gosimple fixes 2016-03-31 07:28:40 -07:00
Ivan Kozlovic
76324844a9 Fixed handling of unprompted PONG protocols
- The number of outstanding PINGs is now reset whenever the server
receives a PONG from the client.
- Updated parser test to check c.pout.
- Added a test to check for unprompted PONGs.

Resolves issue: https://github.com/nats-io/gnatsd/issues/168
2016-03-23 14:30:44 -07:00
Derek Collison
3dd490a449 Go Report Card fixes 2016-03-20 16:06:28 -10:00
Derek Collison
50a14ac1d5 Modified debug and server id 2016-03-20 15:57:43 -10:00
Colin Sullivan
2baac47820 Address issues found by golint.
* No functional changes
* Did not address the ALL_CAPS issues
* Did not modify public APIs and field names.
2016-03-15 15:21:13 -06:00
Ivan Kozlovic
6263c66a40 Fixed code and tests to run on Windows
Mainly tests, but also a fix in route.go to reject a route when the
server is being shutdown.
2016-03-07 18:47:20 -07:00
Derek Collison
0a02aab703 simplify and test for non-optimization 2016-03-07 06:58:48 +00:00
Derek Collison
d09b6bdcf7 Optimize last activity and revert queue performance to alleviate normal sub performance hit 2016-03-07 06:24:23 +00:00
Derek Collison
49a7f2295a gofmt -s fixes 2016-02-29 22:08:49 -08:00
Ivan Kozlovic
3ea412798a Optimizations
-No need to store ip url string in c.route and resolve remote IP
 when forwarding the INFO to known servers.
-When checking if a route is explicit, use strings.ToLower() once
 for the url being checked.
2016-02-25 20:00:21 -07:00
Ivan Kozlovic
7c0a3b49a6 Fix cluster formation when servers connect quickly
Both seed and chained cases are now handled properly when servers
connect quickly and concurrently to one another.
When accepting a route, the server will forward the new route INFO
protocol to its known routes. In turn those routes will connect
to the new server (if not already connected).
A retry for implicit route was introduced to mitigate the issue
with two servers connecting to each other and electing the opposite
connection as the winner, resulting in both connections being dropped.
The server with smaller ID will try once to reconnect.
Some tests were fixed to handle possible extra INFO protocol.
New tests added.

Fix issue: https://github.com/nats-io/gnatsd/issues/206
2016-02-24 19:44:25 -07:00
Derek Collison
7a7cbfa80b Merge pull request #214 from nats-io/nuid
nuid
2016-02-24 10:33:14 -08:00
Derek Collison
b34d6eac1e ID prefix, print debug server ID on startup, bumped version 2016-02-24 09:38:28 -08:00
Derek Collison
8e5f925b87 Bumped version for nuid 2016-02-24 09:23:10 -08:00
Derek Collison
81ae341c2c Use nuid for ID generation 2016-02-24 09:22:38 -08:00
Ivan Kozlovic
7becd0ceeb Fix ports for cluster bcrypt auth config files in server package
The ports were conflicting with the 'test' package when running
the test suite in parallel (go test -race -v ./...)
2016-02-23 21:32:48 -07:00
Derek Collison
7237972420 support for bcrypt in cluster auth 2016-02-23 12:47:46 -08:00
Waldemar Quevedo
7ac3eae82e Set IP and Port for connections using TLS in /connz 2016-02-15 17:40:13 -08:00
Derek Collison
1f143a7b3e beta tag was being overloaded with lots of changes, so bumped 2016-02-11 16:40:22 -08:00
Ivan Kozlovic
ce79f524be Fix scheme for routes returned
When server returns routes through INFO, use "nats-route://" scheme.
A test was checking that.
Add test to check that hostname is replaced with IP.
2016-02-11 17:20:33 -07:00
Ivan Kozlovic
fc38a8336f Fix wrong check for error 2016-02-11 13:29:34 -07:00
Ivan Kozlovic
cef87212b9 Fix route url to use remote IP instead of configured url when sending in INFO protocol. 2016-02-11 11:23:41 -07:00
Ivan Kozlovic
112413a466 Fix infinite server attempt to connect route to itself
Attempt to address issue #175.
Instead of trying to detect if route URL will point to route listen address, detects that the route remoteID is server's ID.
If so, closes the connection and stop trying.
2016-02-10 14:19:54 -07:00
Ivan Kozlovic
193597dbab Update test that would catch incorrect NumConns
- Updating TestConnzWithOffsetAndLimit() to test for c.NumConns.
This would have caught the issue that was fixed in my previous change.

- Use of variable sortValue set to pair.Val to help readability. No functional change.
2016-02-09 12:40:20 -07:00
Ivan Kozlovic
e5f0dabe08 Reduce memory allocations + fix c.NumConns that may have been wrong.
c.NumConns was set early to len(s.clients). However, after the sort, it was possible that the actual Conns[] array be much smaller due to minoff/maxoff.
So c.NumConns is now updated only after applying the offsets.
In order to pre-allocate the Conns buffer, I no longer skip a client if tlsRequired is true and connection is gone. I will simply not update the TLSVersion and TLSCipher.
2016-02-08 20:46:22 -07:00
Ivan Kozlovic
08b8dd796a Fix test to check Idle instead of relying on client id.
Since client connections are handled in go routines, we don't have a guarantee that the second client's id will be > than the first.
2016-02-08 15:51:41 -07:00
Ivan Kozlovic
ecec51a771 Reduce number of objects require to sort connection in HandleConnz
- Use 'Pair' again, but this time, the key is an int64 that the selected sort field will be casted to.
We therefore have now only one type of sort.
- Check validity of sort string early on.
- Ensure that the ConnInfo's field used by the sort is not the value from 'client', but really the one
that was used for the sort.
- Added a test for sort by Idle time.
2016-02-08 15:40:42 -07:00
Ivan Kozlovic
b6292d6d6d Fix monitor port usage for parallel tests.
Use a different MONITOR_PORT for different test packages.
2016-02-08 09:33:39 -07:00