310 Commits (63708d58f49c97b725ab93454d933b74d766dcfb)

Author SHA1 Message Date
Sayan Nandan b257b7286d
Further reduce the size of the docker image
Also the deps were upgraded (there's no point of dependabot creating
multiple commits for upgrading deps)

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan 792351108d
Rollout 0.5.0
Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan bfb4b920df
Bump up version and add changelog entry
Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan 5ecc6f55f4
Drop the read lock to avoid perpetual waits
We previously made a big mistake: we tried to set poisoned to true, an
operation that requires a write lock, without dropping the read lock.
This commit ensures that we first drop `rlock` before doing anything
else. At the same time, if BGSAVE has failed, we'll just shut down the
service.

The error descriptions were improved for a failed `get_saved`
operation. And finally, a couple of variables in `MKSNAP` were renamed
to make them sound more sensible.

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan 106c5bc219
Use refs instead of cloning for pre-compiled resps
For this, `Writable` was implemented for `&'static [u8]`.
Although this won't have a very noticeable impact on performance, we
will stick to using references instead of cloning the data and then
referencing it again.

Along with this, the docs for MKSNAP were updated.

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan 76e6232242
Stop accepting writes if BGSAVE fails
Let's say that BGSAVE fails for some reason or the other. As it is
our responsibility to ensure the integrity of the user's data and
to enforce the reliability of the overall database, we should
immediately stop accepting writes, so that new changes aren't made
since the last time flushing data to the disk succeeded.

The functions under kvengine were modified as a consequence, and they
will return an "Internal Server Error" which is response code 5 if
the database is poisoned.

To put it in one line: If running BGSAVE fails, we'll `poison` the
in-memory table and stop accepting write operations, which ideally is
any operation that attempts to obtain a write lock.

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan 824944e30e
Don't use an explicit `enabled` flag in `snapshot`
There is no merit in having a redundant `enabled` key under
`snapshot` in the configuration file; if a `snapshot` key is present,
it is inherently obvious that snapshotting is enabled

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan b09beefe60
Don't check remote dir every time MKSNAP is called
Instead of checking to see if the remote snapshots directory exists
whenever MKSNAP is called, we'll create the directory when the server
starts up

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan a0fea2ee08
Enable remote snapshots even if disabled
Since creating snapshots is quite an important utility,
there may be scenarios where creating one may be needed,
even if it is disabled on the server side. This commit
enables such snapshots to be created. This is achieved by
enabling MKSNAP to accept two arguments, where a 'named'
snapshot can be created, which is our "special" snapshot.

All these "special" snapshots are stored in a separate
"snapshots/remote" dir that is ignored by the
`SnapshotEngine`.

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan 951880817b
Let snapshots and bgsave opts be set via cmd args
Following on from ab9561258e, we'll allow
the user to configure snapshots and BGSAVE via command-line arguments

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan ab9561258e
Enable command line configuration
Until now, the database server could only be configured via the
configuration file. This commit enables the host, port and noart
options to be configured via command-line arguments.

This is important as there may be scenarios where creating a file
presents a challenge to the user.

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan cf3d213b3f
Enable data to be restored from a snapshot
The user can now run `tdb -r <snapshotname>` to restore data from the
snapshot. Also, we'll show a note in the logs when trying to restore from
a snapshot

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan f06f81cd5c
Remove the `CyanSFW` module
This module isn't doing anything good staying here, as it does nothing!
More work needs to be done on the file storage format internally before
a public rollout.

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan ac37769b7a
Rollout v0.4.5
Also, the actiondoc for `MKSNAP` was updated and a changelog entry was
added for this release

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan bc1a6fd456
Upgrade tokio to 0.3.2
Upstream changes in tokio have required several changes.
For example, `delay_until` was renamed to `sleep_until`. Similarly,
`notify` was renamed to `notify_one`.
Also, in tdb-macros, the `runtime::Builder::new()` line was changed into
`runtime::Builder::new_multi_thread()` due to changes upstream

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan 71e020db59
Ensure that duration values are not zero
If the duration for a periodic operation is set to zero in the
config file then it is likely that the thread would crash.
We want to prevent this at all costs, which is why
we're adding this check.

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan 0ea02f846a
Add tests for MKSNAP and bump up version
We don't need tests for MKSNAP when it is enabled as we already have
tests for snapshotting in `diskstore::snapshot`

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan 11a9223e6b
Make MKSNAP return code 3 for `howmany != 0`
To streamline the actions we'll make sure that mksnap returns code 3
if an incorrect number of arguments are provided
The actiondoc for the `mksnap` action was added and the contributing
guide was also updated

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan a3c5135022
Provide `asyncdb` for `dbtest` macro functions
In `cli` other errors are now formatted in a `[ERR]` format
Also the documentation across the project was updated

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
4 years ago
Sayan Nandan f8fea34e18
Fix tests for snapshots not setting `SnapshotStatus`
Also upgrade syn from 1.0.46 to 1.0.48 (#31)
4 years ago
Sayan Nandan 4ce95c6d42
Make sure that only one snapshot is made at a time
`CoreDB` now has a `SnapshotStatus` object for this purpose
This object holds the current state of the service in an `RWLock`
When `mksnap` is called, `SnapEngine` sets `in_progress` to true
When the snapshot is created, `SnapEngine` sets `in_progress` to false
This prevents multiple entities from creating snapshots at the same time
4 years ago
Sayan Nandan 037064e8d9
Improve `Writable` impl for `terrapipe::RespCodes` 4 years ago
Sayan Nandan 6e27bd256f
Exit block if `SnapEngine` failed to initialize 4 years ago
Sayan Nandan 3b3d2c6994
Implement `mksnap` action 4 years ago
Sayan Nandan c31788754c
Enable module-level imports in `dbtest` proc macro
Also, the macro now unpacks the `__private` module into `super`
4 years ago
Sayan Nandan 980d47a3be
Improve `dbtest` macro docs 4 years ago
Sayan Nandan 5d499fa36d
Remove `testsuite` crate and decompose a few tests 4 years ago
Sayan Nandan 425afbe8c7
Fix lower bound for ports in dbtest compiler macro
Redundant test objects were also removed
4 years ago
Sayan Nandan 3d1dd04b0d
Improved testing to use custom compiler macros
Also, multi-threaded tests were re-enabled
4 years ago
Sayan Nandan 47831252b3
Fix the `dbtest` macro using a `#[test]` attribute
Also several misc. fixes were made to the `dbtest` compiler macro
The macro now creates a TcpListener and closes the socket once finished
4 years ago
Sayan 44cb12955d
Fix `tokio` version 4 years ago
Sayan Nandan 147f13a020
Rename `tdb-derive` to `tdb-macros`
The proc_macro can now be applied on modules only
All functions within the module will be considered to be a test
This has the advantage of not having to flag every test function
4 years ago
Sayan Nandan 8a8c4450bf
Add outline for `mksnap` action 4 years ago
Sayan Nandan 3ce9ea6eeb
Bump up version 4 years ago
Sayan Nandan cbe5c5767d
Improve test for `test_pre_existing_snapshots` 4 years ago
Sayan Nandan 945226f3d8
Add tests for existing snapshots 4 years ago
Sayan Nandan 87ef3f3ae2
Enable previous snapshots to be parsed 4 years ago
Sayan Nandan 441676ee13
Improve docs for background services 4 years ago
Sayan Nandan 62fe32f723
Enable automated snapshots 4 years ago
Sayan Nandan 9828c88a4f
Simplify `CoreDB::run_bgsave` to return a `bool` 4 years ago
Sayan Nandan 89ad505a52
Simplify the `BGSave` object by making it an enum 4 years ago
Sayan Nandan aa4714bded
Enable snapshots to be configured
The snapshots section in the config file can now be parsed
4 years ago
Sayan Nandan b30e71354d
Enable all snapshots to be kept by user preference
There can be use cases where the user wants to keep all the snapshots
This commit adds a way to keep all the snapshots, by setting maxtop to 0
When `maxtop` is set to 0, all the snapshots will be kept
4 years ago
Sayan Nandan 98752cf481
Add method to get a deep-clone of the `HashMap` 4 years ago
Sayan Nandan 4c4586c9c1
Re-implement snapshots and add tests 4 years ago
Sayan Nandan 66a447640b
Release read lock immediately
This helps us to avoid writer starvation
4 years ago
Sayan Nandan a527f3c39d
Implement `mksnap` so that snapshots can be made 4 years ago
Sayan Nandan 6ead5ebe6c
Rollout v0.4.4 4 years ago
Sayan Nandan 8e429c17f4
Add basic `Snapshot` object 4 years ago
Sayan Nandan f9672558d3
Update project metadata and add tests for `KEYLEN` 4 years ago
Sayan Nandan 0a72ea60ed
Add `KEYLEN` query 4 years ago
Sayan Nandan 9e6b455231
Document responses 4 years ago
Sayan Nandan 53f4d00e30
Add tests for `USET` 4 years ago
Sayan Nandan 26a1c4f92d
Add `USET` to actions doc 4 years ago
Sayan Nandan 09a15fd35c
Add `USET` query 4 years ago
Sayan Nandan e6250ae68a
Rollout v0.4.3 4 years ago
Sayan Nandan d2284834c7
Add `FLUSHDB` query 4 years ago
Sayan Nandan 31146f9908
Impl `Writable` for `u64` and remove redundancies 4 years ago
Sayan Nandan f6be0cd781
Bump up version 4 years ago
Sayan Nandan 07195a1d9e
Add `DBSIZE` query 4 years ago
Sayan Nandan 05ed0261ed
Add tests for pipelined queries 4 years ago
Sayan Nandan a2b25441f1
Add tests for `SDEL` 4 years ago
Sayan Nandan 2d5b40f41f
Add tests for `SSET` 4 years ago
Sayan Nandan 8b881d9dbd
Add tests for `SUPDATE` 4 years ago
Sayan Nandan 20041e41a4
Add `SUPDATE` query 4 years ago
Sayan Nandan 3dbc2bce40
Add `SSET` and `SDEL` for automated doc generation 4 years ago
Sayan Nandan f6f96c10c2
Add `SDEL` query 4 years ago
Sayan Nandan 01f43bcd88
Add `SSET` to `queryengine`
The `SSET` tag was added under tags and matched against
4 years ago
Sayan Nandan c9aa602542
Add `SSET` query 4 years ago
Sayan Nandan adb4e4b9f6
Add `strong` module 4 years ago
Sayan Nandan 1488a7786b
Add information on the Cyan Snapstore format
Also, `CyanSWF` was renamed to `CyanSFW` for consistency
4 years ago
Sayan Nandan b96a7831a2
Add `CyanSWF`, the streaming file writer object 4 years ago
Sayan Nandan ed6e990572
Fix incorrect versions
A mass rename was done in 1ac8dd8
This action incorrectly replaced versions in deps
This commit reverts the changes made to the dependency versions
4 years ago
Sayan Nandan 1ac8dd896a
Rollout v0.4.2 4 years ago
Sayan Nandan b2a5237191
Bump up version 4 years ago
Sayan Nandan a0ccf059de
Make `every` and `enabled` keys in bgsave optional
If there is no `enabled` key, then assume that BGSAVE is enabled
If there is an `every` and no `enabled`, assume that BGSAVE is enabled
4 years ago
Sayan Nandan 74c9d62fe0
Update docs for the `bgsave_scheduler` 4 years ago
Sayan Nandan 511e227f81
Enable BGSAVE to be configured via config file 4 years ago
Sayan Nandan 3a84feb14e
Cleanup to use `BGSave` as a configuration object
Also a test for a config file with a custom BGSAVE has been added
4 years ago
Sayan Nandan f2f0d2d4bd
Enable bgsave config to be read from the cfg file
Now, the `bgsave` key can be read and parsed from the config file
4 years ago
Sayan Nandan 20d0b3bf1f
Revert to using vector based tests
A custom testing macro would be made in the future.
For now, we will use the `QueryVec` based test to test the queries
4 years ago
Sayan Nandan b3500ee3b9
Use jemalloc for non-MSVC targets 4 years ago
Sayan Nandan d366f887a9
Close transport once every test is over 4 years ago
Sayan Nandan d1a04bdf23
Manually drop server in tests 4 years ago
Sayan Nandan 7dcf8b92d7
Enable tests for all queries 4 years ago
Sayan Nandan 3ad2d573a0
Add tests for mupdate 4 years ago
Sayan Nandan 7574e4bc58
Add tests for exists 4 years ago
Sayan Nandan ffaa1a563b
Add tests for mset 4 years ago
Sayan Nandan 42a8d145a1
Fix mset and mupdate not detecting an action error 4 years ago
Sayan Nandan f8a1980898
Add tests for mget 4 years ago
Sayan Nandan d8c385bf2d
Add tests for del 4 years ago
Sayan Nandan ea8d9d2108
Add syntax error tests for get, set and update 4 years ago
Sayan Nandan cab2ce733b
Add tests for heya, get, set and update queries 4 years ago
Sayan Nandan 096a0c901b
Remove unused functions and duplicates
`proc_query` is used by both by `tdb-bench` and `tsh` so it was moved.
Also, the `println`s in the query tests were moved into the macros
4 years ago
Sayan Nandan 9064c0aca3
Enable tests for `get`, `mget` and `heya` 4 years ago
Sayan aeb5899050
Fix test in `server::config`
We're checking from a TOML `String` and not from a location
4 years ago
Sayan Nandan 59a2b42615
Implement logging 4 years ago
Sayan Nandan 432e19dd71
Make docker build use `latest` tag 4 years ago
Sayan Nandan fc274ff95f
Improve docs in server 4 years ago
Sayan Nandan 40fea56801
Make some `fn`s `const` 4 years ago
Sayan Nandan fb38acd392
Implement BGSAVE 4 years ago
Sayan ae5da090ec
Don't ignore `heya` test 4 years ago
Sayan Nandan 85662e1f83
Enable tsh to connect to different ports 4 years ago
Sayan Nandan f69bef7308
Improve terminal output and bump up version
We will show a syntax error when we get an invalid config file.
4 years ago
Sayan Nandan c26a319877
Bump up version 4 years ago
Sayan Nandan b06dedc8bd
Enable configuration files to be used 4 years ago
Sayan Nandan 340eaaebcb
Add support for IPv6 addressing 4 years ago
Sayan Nandan 914b1f06e3
Added port, host and noart options in config file 4 years ago
Sayan Nandan 86d15120e4
Add methods to parse cli arguments 4 years ago
Sayan Nandan 0690be4d4e
Add module to handle configuration files 4 years ago
Sayan Nandan 308e57c846
Add `BuiltJSON` and `JSONBlob` objs to build JSON 4 years ago
Sayan Nandan 3163b6a0e8
Add outline for `jget` 4 years ago
Sayan Nandan 6ad417e7ce
Bump up version to 0.4.0 4 years ago
Sayan Nandan e23cd5ffcd
Update version and labels 4 years ago
Sayan Nandan 00730ee9d4
Fix wrong length in pre-compiled responses
Length of "Unknown action" should be 14 and not 15
4 years ago
Sayan Nandan e0baf0ac8d
Classify `fresp`s and `group`s 4 years ago
Sayan Nandan d8408a45cd
Bump up version 4 years ago
Sayan Nandan eee6ddbd45
Fix precompiled responses 4 years ago
Sayan Nandan b9d059b510
Advance the buffer instead of clearing it 4 years ago
Sayan Nandan faa0a1386b
Fix size check operator in read_query 4 years ago
Sayan Nandan 6b2d603618
Fix buffer not being flushed 4 years ago
Sayan Nandan faaaf79bd8
Make `exists` return the number of keys that exist 4 years ago
Sayan Nandan a5d121c767
Make `update` accept single key/value pairs only 4 years ago
Sayan Nandan 167a9dcaab
Add `mupdate` query 4 years ago
Sayan Nandan 5bc7a60c06
Make `del` return the number of keys deleted 4 years ago
Sayan Nandan f214d38e4a
Make `mset` return the number of keys set 4 years ago
Sayan Nandan de1e8e9e87
Fix parser tests 4 years ago
Sayan Nandan e49df70aef
Update license headers 4 years ago
Sayan Nandan 43f9bc83f7
Fix buffer being advanced to a pos larger than len 4 years ago
Sayan Nandan 96a29d6b6c
Fix all data in the buffer being discarded 4 years ago
Sayan Nandan f80911e4c1
Added `MGET` and `MSET` queries 4 years ago
Sayan Nandan bbd94e50ba
Fix `proc_query` in `cli` generating wrong length 4 years ago
Sayan Nandan 2e4e9f662a
Fix parsing of sizes greater than 9 4 years ago
Sayan Nandan c5c9709e9b
Upgrade `cli` to use the new protocol 4 years ago
Sayan Nandan 819a6030b0
Use timeout for the background thread to start 4 years ago
Sayan Nandan a29831d7ab
Improve testing 4 years ago
Sayan Nandan 12634858c0
Add automated tests for `get` queries 4 years ago
Sayan Nandan 004c6d0e21
Add automated test for `heya` queries 4 years ago
Sayan Nandan 8446b3ffae
Enable actions to be executed in `queryengine` 4 years ago
Sayan Nandan b15fda9d65
Upgrade `set` and `update` to use the new protocol 4 years ago
Sayan Nandan e65ee21f82
Upgrade `get` to the new protocol 4 years ago
Sayan Nandan c6f2504b30
Fix comment for the `Writable` trait 4 years ago
Sayan Nandan f9d5b94d31
Upgrade `del` and `exists` to use the new protocol 4 years ago
Sayan Nandan 77db07ae63
Remove `VecWrapper` as we can use a `Vec<u8>` 4 years ago
Sayan Nandan cef28375c0
Impl Writable for `BytesWrapper` and `VecWrapper` 4 years ago
Sayan Nandan 6aee3bf5f4
Remove `libtdb` deps from `server` 4 years ago
Sayan Nandan a0ea3b6c61
Upgrade server::protocol to the new protocol 4 years ago
Sayan Nandan 59c41407b0
Fix terminal art 4 years ago
Sayan Nandan 67dc83764a
Rename `corelib` to `libtdb` 4 years ago
Sayan Nandan 085a71dc3d
Add more tests to the parser 4 years ago