Commit Graph

71 Commits

Author SHA1 Message Date
tidwall 7fa2dc4419 Better FSET tests
Execute oom check immediately after setting maxmemory
2022-09-23 12:42:39 -07:00
tidwall 960c860b3a Better RENAME/RENAMENX tests 2022-09-23 11:18:01 -07:00
tidwall ede1ce0269 Better GET/DROP tests 2022-09-23 10:42:43 -07:00
tidwall db380a4fee Better DEL/PDEL/TYPE tests 2022-09-23 09:04:01 -07:00
tidwall ef95f04aca Better coverage BOUNDS 2022-09-23 07:51:05 -07:00
tidwall 2c643996e7 Immutable Object type 2022-09-20 14:20:53 -07:00
tidwall d5c148ca41 Field overhaul 2022-09-19 17:47:38 -07:00
tidwall 1177bbb80c Moved root collection keys into generic btree.
Also updated the background expires logic to remove an extra
allocation.
2022-09-13 08:16:41 -07:00
tidwall 023433a963 Fix server hang on shared address 2022-09-12 16:38:45 -07:00
tidwall fc39090e94 Workaround for lettuce handshake to work.
Issue #636
2022-03-10 12:44:40 -07: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 29a6d05f3f Minor refactor 2021-12-09 09:24:26 -07: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 18438e5783 Use same input args for command functions 2021-09-13 10:52:20 -07:00
tidwall 8829b8ffc3 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-13 10:02:36 -07:00
tidwall 83094b2740 Update hook expiration logic 2021-09-12 09:55:58 -07:00
tidwall 06a92d8a21 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-08 11:07:07 -07:00
tidwall a737a78d6f Add unix socket support 2021-09-07 05:51:15 -07:00
tidwall fc4a627aa6 Use struct for server options 2021-09-06 08:55:13 -07: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
tidwall 694ad1fb62 Update btree/buntdb 2021-07-31 07:42:58 -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 d2f747933f clear linter messages 2021-07-10 03:59:27 -07:00
tidwall df8d3d7b12 Close follower files before finishing aofshrink
fixes #449
2021-06-13 07:53:27 -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 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 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 72dfaaec63 Updated dependencies 2021-02-07 17:54:56 -07:00
tidwall 016f397124 Replace tinybtree 2021-01-25 14:34: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 d819db5f8b Added MONITOR command
closes #571
2020-08-12 12:38:52 -07: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 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 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
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 2571ce5106 Minimize AOF buffer releases 2019-09-03 17:01:26 -07:00
tidwall 3ae59274e3 Removed evio option 2019-04-26 11:50:49 -07:00
Alex Roitman cbf10b7472 Rework timeouts to allow prepending any command with the TIMEOUT seconds 2019-04-25 14:15:53 -07:00
Alex Roitman 31525487c3 Add timeout tests. Fix a bug. 2019-04-24 13:20:57 -07:00
Alex Roitman e514a0287f Add timeout subcommand to scan/search commands.
Use per-query timeout for those commands, if it was given.
2019-04-24 12:02:39 -07:00
tidwall 0aecef6a5c Added TIMEOUT command 2019-04-24 05:09:41 -07:00
tidwall 762607dc0a Added geofence delivery counter 2019-03-14 11:23:23 -07:00
tidwall 5333fab870 Recycle aof buffer 2019-03-10 10:48:14 -07:00
Josh Baker 6fffa75b58
Merge pull request #409 from rshura/test_cmd
Test command
2019-02-12 05:05:50 -07:00