Commit Graph

384 Commits

Author SHA1 Message Date
tidwall 67916f38f8 Reset wheres while geofencing 2022-08-30 16:50:19 -07:00
tidwall cc9320e246 Allow for WHERE for on geofence detection 2022-08-26 16:23:28 -07:00
tidwall b883f358d5 Add pending_events stat 2022-07-11 08:39:40 -07:00
Erik Serating b256d4752b Issue #642 - Renamed config property to replica-priority and added config set/get functionality 2022-06-22 12:50:43 -04:00
Erik Serating 2be07e4762 Issue #642 - Expose config and INFO response for slave_priority 2022-06-20 09:50:40 -04:00
tidwall a1cc8e6e46 Fix eof error for incomplete commands.
This commit fixes an issue where Tile38 will fail to start
because the AOF file contains a partially written command, which
is caused by the server not having enough disk space to complete
the previous write.

This was discovered and reported by a Theresa D on the Tile38
Slack channel.
2022-04-12 15:43:55 -07:00
tidwall fc39090e94 Workaround for lettuce handshake to work.
Issue #636
2022-03-10 12:44:40 -07:00
tidwall 10f85640c0 Added option to "not found" for DEL 2022-03-08 15:58:23 -07:00
tidwall b6833a2dba Auto assign server_id for bootstrapped config files.
This commit fixes an issue where the server may start up without
a "server_id" assigned, which in turn will cause a follower to
be unable to connect.

This issues is caused by including a pre-generated "data/config"
file that does not include the "server_id" field.
2022-01-04 05:13:16 -07:00
tidwall 517bc57e9c Ensure inlined logs
Move the LogJSON check into the log function so that the caller
function can be inlined. This is helpful for hot functions like
`log.Debug` where it's likely that the `-vv` flag is not set thus
the to avoid the extra function call.
2021-12-28 16:33:46 -07:00
Benjamin Ramser bd5f8ddccd fix: disable caller 2021-12-28 11:18:44 +01:00
Benjamin Ramser 407fd4c71c refactor: set log encoding early 2021-12-27 12:20:14 +01:00
Benjamin Ramser 20cc624918 feat: add option to cmd, add default config
feat: add zap logger

test: add additional

refactor: dont export logger, use set/get/build

fix: getter and benchmark

feat: extend server config with log configuration

fix: log config write

fix: log
2021-12-26 16:06:34 +01:00
tidwall 241117c7ba Added BUFFER option for Within and Intersects
This commit allows for buffering any GeoJSON object.

For example:

    INTERSECTS fleet BUFFER 1000 OBJECT {...LineString...}

This will buffer add a 1 kilometer buffer to a linesting and
search the 'fleet' collection for all objects that
intersect the buffered linestring.

This commit also allows for performing INTERSECTS with a POINT
type. Thus allowing for a polygon-over-point operation, which is
an inverted point-in-polygon.
2021-12-09 18:14:50 -07:00
tidwall 29a6d05f3f Minor refactor 2021-12-09 09:24:26 -07:00
Simon Tuohy 4454995e06 Azure EventHub hook support 2021-10-15 15:22:41 +01:00
tidwall 9e552c3629 Allow some basic client commands before AOF data loads
This commit accepts incoming connections even before the AOF
dataset has been loaded into memory. Though only a very limited
command set is allowed.

Allowed commands:
  PING, ECHO, OUTPUT, QUIT

All other commands will return:
  LOADING Tile38 is loading the dataset in memory

This is useful for establishing connections for the purpose of
checking process and network state.
2021-10-01 17:18:07 -07:00
tidwall a3c808e97f Increase verbosity for warning messages 2021-10-01 07:45:37 -07:00
tidwall 6174c6434d Fix aofshrink panic
fixes #624
2021-09-29 11:15:53 -07:00
tidwall de59d23ac4 Fixed Z not matching on where clause Feature points.
This issues fixes an issue where a search command with a where
clause using the "z" field would not match correctly for point
that where contained inside a GeoJSON Feature type.

Tile38 now extracts the Z coordinate from Point and Feature/Point
types.

fixes #622
2021-09-29 07:19:00 -07:00
tidwall 19deea10c0 Use same input args for command functions 2021-09-29 07:19:00 -07:00
tidwall 7ff0d18868 Change hooks collection type from hashmap to btree
This commit changes the collection type that holds all of the
hooks from a hashmap to a btree. This allows for better
flexibility for operations that need to perform range searches
and scanning of the collection.
2021-09-29 07:19:00 -07:00
tidwall decafae2d7 Update hook expiration logic 2021-09-29 07:19:00 -07:00
tidwall 7e10a80319 Return hook ttl with HOOKS request 2021-09-29 07:19:00 -07:00
tidwall d38aed4d2b Increase the precision of TIMEOUT
This commit ensures that the TIMEOUT is always checked prior to
returning data to the client, and that the elapsed command time
cannot be greater than the timeout value.
2021-09-29 07:19:00 -07:00
tidwall 9b760ffdd5 Add unix socket support 2021-09-29 07:19:00 -07:00
tidwall f9e6f74753 Use struct for server options 2021-09-29 07:19:00 -07:00
Benjamin Ramser 6eb1cca78c fix: point -> circle fallthrough 2021-09-05 12:05:33 +02:00
Benjamin Ramser bc62edb692 feat: add sector 2021-09-05 11:48:34 +02:00
tidwall c8389fe52c Fix memory leak with group id
This commit fixes a memory leak that was being caused by hooks
hanging on to the geofence group ids past the life of the object.
2021-08-20 05:00:14 -07:00
Josh Baker 148d581dcf
Merge pull request #620 from iwpnd/master
kafka authentication methods
2021-08-04 14:31:04 -07:00
Benjamin Ramser 9ee91ca5c3 refactor: kafka auth 2021-08-03 14:46:40 +02:00
tidwall 694ad1fb62 Update btree/buntdb 2021-07-31 07:42:58 -07:00
tidwall 401670e621 Fix NEARBY with SPARSE returning too many results
fixes #618
2021-07-22 08:39:57 -07:00
tidwall 9e68703841 Update expiration logic
This commit changes the logic for managing the expiration of
objects in the database.

Before: There was a server-wide hashmap that stored the
collection key, id, and expiration timestamp for all objects
that had a TTL. The hashmap was occasionally probed at 20
random positions, looking for objects that have expired. Those
expired objects were immediately deleted, and if there was 5
or more objects deleted, then the probe happened again, with
no delay. If the number of objects was less than 5 then the
there was a 1/10th of a second delay before the next probe.

Now: Rather than a server-wide hashmap, each collection has
its own ordered priority queue that stores objects with TTLs.
Rather than probing, there is a background routine that
executes every 1/10th of a second, which pops the expired
objects from the collection queues, and deletes them.

The collection/queue method is a more stable approach than
the hashmap/probing method. With probing, we can run into
major cache misses for some cases where there is wide
TTL duration, such as in the hours or days. This may cause
the system to occasionally fall behind, leaving should-be
expired objects in memory. Using a queue, there is no
cache misses, all objects that should be expired will be
right away, regardless of the TTL durations.

Fixes #616
2021-07-12 13:37:50 -07:00
tidwall dd4d31ae1b Fix last merge 2021-07-11 10:09:51 -07:00
tidwall 579a41abae Merge branch 'housecanary-fix-knn' 2021-07-11 10:02:59 -07:00
tidwall 991963268a Fix last merge 2021-07-10 19:32:21 -07:00
tidwall f2bbf10c36 Merge branch 'mpoindexter-optimize-field-value-access' 2021-07-10 19:26:29 -07:00
tidwall 0d83b1ca53 Merge branch 'rshura-optimize-field-match' 2021-07-10 17:59:22 -07:00
Josh 1467cba769
Merge pull request #552 from rshura/clip-by
Add CLIPBY subcommand to INTERSECTS/WITHIN
2021-07-10 09:24:57 -07:00
tidwall d2f747933f clear linter messages 2021-07-10 03:59:27 -07:00
Josh d3d4694691
Merge pull request #504 from tidwall/nats-tls
Added TLS support for Nats webhook provider
2021-07-08 07:42:54 -07:00
tidwall e60cbac7cf Merge distance updates 2021-07-08 07:03:36 -07:00
tidwall aea7d77de5 Fix Memory Leak in Kafka Producer
This commit addresses an issue where the sarama kafka library
leaks memory when a connection closes unless the metrics
configuration that was passed to new connection is also closed.

Fixes #613
2021-07-08 06:46:58 -07:00
tidwall 1497663b6d Close follower files before finishing aofshrink
fixes #449
2021-07-08 06:46:58 -07:00
Benjamin Ramser bb2253204c Add option to select sha function 2021-07-08 06:46:57 -07:00
Benjamin Ramser 6dfcf896d4 Leave ClientID default untouched 2021-07-08 06:46:57 -07:00
Benjamin Ramser e4b03ca174 Add endpoint option for sasl 2021-07-08 06:46:57 -07:00
Mathieu 55e503c378 Add sasl 2021-07-08 06:46:57 -07:00
tidwall f067e3ba67 Fix invalid healthz output 2021-07-08 06:46:57 -07:00
tidwall 87702b3e29 Always OK for leader 2021-07-08 06:46:57 -07:00
tidwall 5a37198602 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-07-08 06:46:57 -07:00
Oliver fc0ff42297 add more metrics, add metrics index page 2021-07-08 06:46:57 -07:00
Oliver f448599e72 cleanup / fix tests 2021-07-08 06:46:57 -07:00
Oliver a233aaa66e don't rely on stats code for new metrics if we can avoid it 2021-07-08 06:46:57 -07:00
tidwall 5b3aeb5db7 add prometheus metrics endpoint 2021-07-08 06:46:52 -07:00
tidwall 0b8254e7c2 Change 255 to 256 2021-07-08 06:46:13 -07:00
tidwall 5cf6c4e9f4 Add comment 2021-07-08 06:46:13 -07:00
tidwall b5691f7dd5 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-07-08 06:46:13 -07:00
tidwall 6bb9f8f54c Remove deprecated function
Go recommends not calling BuildNameToCertificate and to allow
for the names to be selected automatically.
2021-07-08 06:46:12 -07:00
tidwall 58221adccb Code cleanup
- Removed unused functions and variables
- Wrapped client formatted errors
- Updated deprecated packages
- Changed suggested code patterns
2021-07-08 06:46:08 -07:00
tidwall 6a55c8de8f fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
tidwall 901919c4e3 Include "distance" to output when user specifically requests
fixes #599
2021-07-08 06:36:45 -07:00
Benjamin Ramser 8234f6dc6d refactor: dont set client id 2021-07-08 06:36:10 -07:00
tidwall b64c87004f Expose log output writer 2021-07-08 06:36:10 -07:00
Benjamin Ramser 248c3d8b72 add kafka tls config
fix endpoint, add logging to tlsconfig creation

add logging if log.Level > 2
2021-07-08 06:36:10 -07:00
tidwall 60678020fa Updated dependencies 2021-07-08 06:36:10 -07:00
tidwall 094d35757c Various updates
- Updated all dependencies
- Updated geoindex Box api
2021-07-08 06:36:05 -07:00
tidwall f44bae43ca Replace tinybtree 2021-07-08 06:35:15 -07:00
tidwall 67f443dbbd Fixed fields being shuffled after AOFSHRINK 2021-07-08 06:35:06 -07:00
tidwall 07dc10262a Added ENV var for 500 http errors 2021-07-08 06:35:06 -07:00
tidwall 076cd4b009 Updated btree deps 2021-07-08 06:35:01 -07:00
tidwall 9d9c2b9aeb 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
2021-07-08 06:34:47 -07:00
tidwall 2eb6da5f21 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.
2021-07-08 06:34:47 -07:00
tidwall 6aab7ee309 Fix "cross" detection on firing in some cases
Fixes #578
2021-07-08 06:34:15 -07:00
tidwall 3d7242d06c Added MONITOR command
closes #571
2021-07-08 06:34:15 -07:00
tidwall 5f5c4d9f03 Limit geohash precision to 12 2021-07-08 06:34:15 -07:00
Terra Brown 019995e5f6 s/64/12/ 2021-07-08 06:34:15 -07:00
tidwall b606f23bd0 Hotfix for previous commit 2021-07-08 06:34:15 -07:00
tidwall 67abcefd25 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
2021-07-08 06:34:15 -07:00
tidwall 1477026721 Updated Kafka version 2021-07-08 06:34:15 -07:00
Lars Wilhelmsen 47ac560f83 Fix crash in fenceMatchRoam causing an index out of range panic 2021-07-08 06:33:38 -07:00
tidwall 97c1ec5c5d 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
2021-07-08 06:33:38 -07:00
Jan Pacák 71fa16a19e amqp: removal of queue and binding creation 2021-05-13 00:44:27 +02:00
tidwall b467c6f1cb Change 255 to 256 2021-04-28 05:10:18 -07: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 5e440b621b Remove deprecated function
Go recommends not calling BuildNameToCertificate and to allow
for the names to be selected automatically.
2021-03-31 08:15:52 -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 0d69799653 Merge branch 'kafka-tls' of https://github.com/iwpnd/tile38 into iwpnd-kafka-tls 2021-02-18 15:34:09 -07:00
tidwall 9ac25647ad Expose log output writer 2021-02-18 15:34:01 -07:00
Benjamin Ramser d7c0c5b855 refactor: dont set client id 2021-02-18 22:35:49 +01:00
Benjamin Ramser 734d33365a add kafka tls config
fix endpoint, add logging to tlsconfig creation

add logging if log.Level > 2
2021-02-17 14:35:42 +01:00
tidwall 72dfaaec63 Updated dependencies 2021-02-07 17:54:56 -07:00
tidwall 3ed048242e Various updates
- Updated all dependencies
- Updated geoindex Box api
2021-02-03 14:30:55 -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 79bee8523b Updated btree deps 2020-10-27 15:29:50 -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
tidwall 68e2b6d736 Updated Kafka version 2020-07-03 11:57:15 -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
Mads Schou-Andreasen cf757802a3 fixed default credentials 2020-05-30 10:26:25 +02:00
Mads Schou-Andreasen bff11ad0ae minor documentation fix 2020-05-19 17:24:06 +02:00
Mads Schou-Andreasen 37224791f4 added geofence webhook for GCP Pubsub 2020-05-19 17:11:31 +02:00
tidwall 3718cd766b Added priority option for AMQP endpoints 2020-05-16 14:31:52 -07:00
tidwall 70cd167fc0 Fixed clip test #558 2020-05-03 09:59:49 -07:00
Alex Roitman 25579a052c Fix a bug in WHEREIN -- 0 values would always match, incorrectly. 2020-04-12 16:06:10 -07:00
Alex Roitman 914f51de11 Fixes 2020-04-09 09:59:24 -07:00
Alex Roitman fe0216c42c Restore previous behavior where non-existing fields are treated as zero-value. 2020-04-09 09:54:47 -07:00
Alex Roitman f3cc365d24 Pre-allocate where and wherein arrays. 2020-04-09 09:36:12 -07:00
Mike Poindexter 042582aef3 Update comment 2020-04-08 11:38:12 -07:00
Mike Poindexter 2a4272c95f Improve kNN behavior
The current KNN implementation has two areas that can be improved:

- The current behavior is somewhat incorrect. When performing a kNN
query, the current code fetches k items from the index, and then sorts
these items according to Haversine distance. The problem with this
approach is that since the items fetched from the index are ordered by
a Euclidean metric, there is no guarantee that item k + 1 is not closer
than item k in great circle distance, and hence incorrect results can be
returned when closer items beyond k exist.

- The secondary sort is a performance killer. This requires buffering
all k items (again...they were already run through a priority queue in)
the index, and then a sort. Since the items are mostly sorted, and
Go's sort implementation is a quickSort this is the worst case for the
sort algorithm.

Both of these can be fixed by applying a proper distance metric in
the index nearby operation. In addition, this cleans up the code
considerably, removing a number of special cases that applied only
to NEARBY operations.

This change implements a geodetic distance metric that ensures that
the order from the index is correct, eliminating the need for the
secondary sort and special filtering cases in the ScanWriter code.
2020-04-07 20:10:58 -07:00
Alex Roitman 34cb2affdc Add clipby subcommand to INTERSECTS/WITHIN 2020-04-03 16:49:06 -07:00
Josh Baker f02dee3db2
Merge pull request #545 from tidwall/index-kind-geometry-nooverride
Match geometry indexing to server config
2020-04-02 08:15:38 -07:00
Josh Baker 12a98c53e4
Merge pull request #543 from rshura/fix-clip-empty-rings
Skip empty rings when clipping polygons.
2020-04-02 08:15:14 -07:00
tidwall 951fc58e02 Match geometry indexing to server config 2020-03-25 15:35:31 -07:00
Alex Roitman d5132a9eae Map field names to array indices in scanwriter, once per query. 2020-03-25 15:15:06 -07:00
Alex Roitman 9e7766b346 Array of values instead of map for whereins. 2020-03-25 15:14:51 -07:00
Alex Roitman 27c6980f82 Copy array and only loop if we need to pad. 2020-03-25 15:14:37 -07:00
Alex Roitman 91ef777771 Add benchmark for fieldMatch. 2020-03-25 14:49:21 -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
Mike Poindexter 625a83f81e Add scan benchmark, with/without fields benchmarks 2020-03-25 11:09:50 -07:00
Mike Poindexter 9a5d608c21 Switch field storage to an array vs map 2020-03-25 10:24:02 -07:00
Alex Roitman c4b1dd3a72 Skip empty rings when clipping polygons.
Add a test for skipping empty rings.
2020-03-23 16:11:46 -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
tidwall b482206894 Minimize sorting of collection fields 2020-03-22 07:58:03 -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 fa4a1dd436 Added .github directory 2019-11-17 09:00:45 -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
tidwall feba00040e Added TLS support for Nats webhook provider
Use the `tls=1` and the set the the `tlscert` and `tlskey` query
string params. The cert and key files must be on the tile38
server and the Nats server must be started using the same files.

nats://54.12.34.121:4222/fleet?tls=1&tlscert=cert.crt&tlskey=cert.key
2019-10-30 08:17:40 -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