Commit Graph

135 Commits

Author SHA1 Message Date
tidwall af43d5a7c7 Fix invalid healthz output 2021-06-09 10:55:07 -07:00
tidwall 27335c37f1 Always OK for leader 2021-05-25 16:42:26 -07:00
tidwall 30c3e81e0d Added HEALTHZ command
Returns 'ok' if the server is the leader or a follower with
a 'caught up' log.

This is mainly for HTTP connections that are using an
orchestration environment like kubernetes, but will work as a
general RESP command.

For HTTP a '200 OK' for 'caught up' and
'500 Internal Server Error' otherwise.

See #608
2021-05-25 16:36:49 -07:00
Oliver 6b0282d960 add more metrics, add metrics index page 2021-05-13 21:14:05 -04:00
Oliver 7ec4d58392 cleanup / fix tests 2021-05-13 21:14:05 -04:00
Oliver c3d7b92026 don't rely on stats code for new metrics if we can avoid it 2021-05-13 21:14:05 -04:00
Oliver 30f7226705 add prometheus metrics endpoint 2021-05-13 21:14:04 -04:00
tidwall 47a4e16c0b Add comment 2021-04-28 05:09:48 -07:00
tidwall d37ce505f5 Allow for all command types for roaming event
Prior to this commit roaming geofences only registered changes to
the SET command. Now it will work for SET/DEL/FSET, just like
non-roaming geofences.

To opt out of these events, explicitly choose which event you
would like to register when you create the geofences.

For example:

  NEARBY fleet FENCE COMMANDS set,del ROAM fleet * 5000

Will only fire off events from SET and DEL command.

Closes #597
2021-04-01 14:59:12 -07:00
tidwall 6b08f7fa9e Code cleanup
- Removed unused functions and variables
- Wrapped client formatted errors
- Updated deprecated packages
- Changed suggested code patterns
2021-03-31 08:13:44 -07:00
tidwall 40105e6b7e Include "distance" to output when user specifically requests
fixes #599
2021-03-30 11:49:01 -07:00
tidwall 72dfaaec63 Updated dependencies 2021-02-07 17:54:56 -07:00
tidwall 016f397124 Replace tinybtree 2021-01-25 14:34:40 -07:00
tidwall 9ce20331e4 Fixed fields being shuffled after AOFSHRINK 2020-11-09 14:45:40 -07:00
tidwall 1a7d8d6431 Added ENV var for 500 http errors 2020-11-07 05:22:11 -07:00
tidwall 9998e03f6f Optimization for non-cross geofence detection
This commit fixes a performance issue with the algorithm that
determines with geofences are potential candidates for
notifications following a SET operation.

Details

Prior to commit b471873 (10 commits ago) there was a bug where
the "cross" detection was not firing in all cases. This happened
because when looking for candidates for "cross" due to a SET
operation, only the geofences that overlapped the previous
position of the object and the geofences that overlapped the new
position where searched. But, in fac, all of the geofences that
overlapped the union rectangle of the old and new position should
have been searched.

That commit fixed the problem by searching a union rect of the
old and new positions. While this is an accurate solution, it
caused a slowdown on systems that have big/wild position changes
that might cross a huge number of geofences, even when those
geofences did not need actually need "cross" detection.

The fix

With this commit the geofences that have a "cross" detection
are stored in a seperated tree from those that do not. This
allows for a hybrid of the functionality prior and post b471873.

Fixes #583
2020-10-23 09:51:27 -07:00
tidwall 93e3a067b7 Truncate trailing zeros from AOF at startup
This commit addresses issue #230, where an AOF file will sometimes
not load due to the file being padded with trailing zeros. It's
uncertain what is causing this corruption, but it appears to be
coming from outside of the tile38-server process. I suspect it's
due to some block store layer in Kubernetes/Docker cloud
environments.

This fix allows for Tile38 to start up by discovering the trailing
zeros while loading the AOF and safely truncating the file as to
not include the zeros in the future.
2020-10-07 09:52:32 -07:00
tidwall b47187349b Fix "cross" detection on firing in some cases
Fixes #578
2020-09-22 16:19:49 -07:00
tidwall d819db5f8b Added MONITOR command
closes #571
2020-08-12 12:38:52 -07:00
tidwall 9093926135 Limit geohash precision to 12 2020-08-12 10:58:49 -07:00
Terra Brown 9202fd0206
s/64/12/ 2020-08-11 18:11:06 -04:00
tidwall f23b46cfc0 Hotfix for previous commit 2020-07-04 10:35:07 -07:00
tidwall f3622c3756 Fixed wrong order for fields with SCAN
This commit fixes an issue that happens when running SCAN on a
collection that has objects with fields, causing field values
to be mismatched with their respective keys.

This only occured with json output, and is a regression from #534.

Fixes #569
2020-07-04 10:12:06 -07:00
Lars Wilhelmsen 4fdbade7a4
Fix crash in fenceMatchRoam causing an index out of range panic 2020-06-18 15:43:18 +02:00
tidwall b7978f2cf4 Fix OUTPUT client command requiring authentication
This commit fixes an issue where the OUTPUT command requires
authentication when a server password has been set with
CONFIG SET requirepass. This was causing problems with clients
that use json responses, like the tile38-cli.

Fixes #564
2020-06-04 12:57:23 -07:00
tidwall 951fc58e02 Match geometry indexing to server config 2020-03-25 15:35:31 -07:00
tidwall 5162ac5fd7 Stable sort roam notifications 2020-03-25 13:01:11 -07:00
tidwall a99df2892a Fixed false faraway notifications 2020-03-25 12:47:55 -07:00
tidwall ff48054d3d Fixed a missing faraway event for roaming geofences
This commit fixes a case where a roaming geofence will not fire
a "faraway" event when it's supposed to.

The fix required rewriting the nearby/faraway detection logic. It
is now much more accurate and takes overall less memory, but it's
also a little slower per operation because each object proximity
is checked twice per update. Once to compare the old object's
surrounding, and once to evaulated the new object. The two lists
are then used to generate accurate "nearby" and "faraway" results.
2020-03-22 11:54:56 -07:00
Josh Baker 0997f2e82b
Merge pull request #534 from rshura/optimize-scanwriter
Avoid sorting fields for each written object.
2020-03-22 06:33:33 -07:00
tidwall 65943e8f1a Fixed DEL geofence notifications missing "key" field
Closed #538
2020-03-21 17:48:31 -07:00
Mike Poindexter 84cabd77f9 Fix a concurrent write/read on the server conn map 2020-03-20 16:47:13 -07:00
Alex Roitman 5faccc3b4c Avoid sorting fields for each written object. 2020-03-03 13:39:43 -08:00
tidwall 66af8ab094 Fix tile38-cli from freezing with non-quoted geojson
This commit addresses an issue that began on 1.19 where the
deprecated tile38 native line protocol was removed in favor of
the more robust resp protocol. In turn the tile38 cli required
that all args are quoteless or quote escaped.

The commit ensures that the server returns the correct error
message and also loosens the strictness of the need for quoted
arguments in the tile38-cli.

fixes #513
2019-12-11 11:08:33 -07:00
tidwall 474ff810c0 Fixed panic on AOFSHRINK
closes #508
2019-11-17 07:25:25 -07:00
tidwall c084aeedc2 Code cleanup
This commit cleans up various Go code in the internal directory.
- Ensures comments on exported functions
- Changes all *Server receiver in all files to be "s", instead
  of mixed "c", "s", "server", etc.
- Silenced Go warnings for if/else with returns.
- Cleaned up import ordering.
2019-10-30 10:17:59 -07:00
Josh Baker 981d9ece42
Merge pull request #503 from JordanArmstrong/fix-stats-cpu
Fix fprintf type error in stats_cpu.go for non-linux/darwin builds
2019-10-29 15:29:38 -07:00
Josh Baker 90c2474e3d
Merge pull request #501 from JordanArmstrong/strict-jset-numbers
Strictly check if values passed to JSET are numbers
2019-10-29 15:28:40 -07:00
tidwall 23b016d192 Fix excessive memory usage for objects with TTLs
This commit fixes an issue where Tile38 was using lots of extra
memory to track objects that are marked to expire. This was
creating problems with applications that set big TTLs.

How it worked before:

Every collection had a unique hashmap that stores expiration
timestamps for every object in that collection. Along with
the hashmaps, there's also one big server-wide list that gets
appended every time a new SET+EX is performed.

From a background routine, this list is looped over at least
10 times per second and is randomly searched for potential
candidates that might need expiring. The routine then removes
those entries from the list and tests if the objects matching
the entries have actually expired. If so, these objects are
deleted them from the database. When at least 25% of
the 20 candidates are deleted the loop is immediately
continued, otherwise the loop backs off with a 100ms pause.

Why this was a problem.

The list grows one entry for every SET+EX. When TTLs are long,
like 24-hours or more, it would take at least that much time
before the entry is removed. So for databased that have objects
that use TTLs and are updated often this could lead to a very
large list.

How it was fixed.

The list was removed and the hashmap is now search randomly. This
required a new hashmap implementation, as the built-in Go map
does not provide an operation for randomly geting entries. The
chosen implementation is a robinhood-hash because it provides
open-addressing, which makes for simple random bucket selections.

Issue #502
2019-10-29 11:19:33 -07:00
Jordan Armstrong 324b3b06d9 Fix go vet error in stats_cpu.go for non-linux/darwin builds 2019-10-28 22:39:27 -03:00
Jordan Armstrong e0eca0d55e Replace isJsonNumber with version from gjson 2019-10-28 22:35:44 -03:00
Josh Baker df477bf3f4
Merge pull request #464 from rshura/area-expression
Add area expressions.
2019-10-28 13:45:10 -07:00
tidwall 10f7bfc445 Fix invalid pubsub format for json output
This commit fixes a bug that causes bad formatting for geofence
notifications when a client's output is set to JSON.

closes #499
2019-10-28 12:51:44 -07:00
Jordan Armstrong 41fb410e2e Strictly check if values to JSET are numbers
Fixes #493
2019-10-26 23:37:48 -03:00
tidwall 87185319b2 Fix JSET cancels expiry
issue #498
2019-10-08 09:45:46 -07:00
tidwall 639f6e2deb Replaced boxtree for rbang 2019-09-12 18:42:53 -07:00
tidwall 3d96b17258 GC pauses be gone 2019-09-04 12:47:30 -07:00
tidwall 2571ce5106 Minimize AOF buffer releases 2019-09-03 17:01:26 -07:00
tidwall 4bd6b4b838 Moved ReadMemStats into a background polling function
This will keep profile commands such as SERVER and STATS from
stopping the world.
2019-09-03 16:57:49 -07:00
tidwall e167e88e8f removed diag 2019-09-03 16:39:51 -07:00