421 Commits (efec980fa6aa89c1a90ae13bf6f50af8b6d393d2)

Author SHA1 Message Date
Sayan Nandan efec980fa6 Add basic `BufferBlockReader` definition 3 years ago
Sayan Nandan bdc4b3483f Add basic `KVEngine` definition 3 years ago
Sayan 552d454940
Enable TLS port to be configured via CLI args (#186)
* Enable TLS port to be configured via CLI

* Add changelog entry
3 years ago
Sayan Nandan 141e39eee1 Use env var to determine TLS cert location 3 years ago
Sayan d43e6f41da
Use `QuickLock` instead of mutex (#185)
* Use our own lock instead of parking_lot::Mutex

* Account for spurious failures in cmpxchg weak

* Ignore send error because parent may have panicked

The parent thread may have already panicked, dropping the rx.
3 years ago
Sayan Nandan 3a363d18cb Simplify artwork [skip ci] 3 years ago
Sayan bae2b8354c
Release v0.6.3 (#184)
* Bump up version to 0.6.3

* Update changelog entry
3 years ago
Sayan 2d7b9d7667
Add automated tests for TLS (#183)
* Auto start with TLS

* Add automated tests for SSL

* Add cert generation script

* Use script to generate SSL cert
3 years ago
Sayan 864c6d461f
Enable maximum connections to be configured manually (#182)
* Enable maximum connections to be configured

* Add arbiter for handling server startup

* Add handling of maxcon for command-line args

* Add changelog entry
3 years ago
Sayan Nandan 79f657b462 Add more LLVM specific optimizations
Just to reduce LLVM bloat
3 years ago
Sayan e30d51a599
Release v0.6.2 (#180)
* Bump up version and add changelog entry

* Use separate cache object for release workflows
3 years ago
Sayan Nandan 0f06f7b26f Add some LLVM specific optims for O1 builds 3 years ago
Sayan d53a0cb505
Fix handling of SIGTERM on *nix (#178)
* Fix handling of SIGTERM on *nix

This is just for future extensibility

* Fix error codes

I have been silly enough to break error codes
3 years ago
Sayan 66e5d41302
Simplify overall locks (#176)
* Remove the need for TableLockStateGuard

The htable impl uses locks under the hood making external locks
redundant.

* Use atomics instead of rwlock for poisoned state

* Simplify snapshot locking
3 years ago
Sayan Nandan 2a2addfa6d Upgrade deps and add changelog entries 3 years ago
Sayan Nandan 0f1264d312 Decompose linearity tests and utils into modules
Also fixed license headers
3 years ago
Sayan Nandan a87478dcba Optimize dependencies 3 years ago
Sayan Nandan 76acde2f4f Fix missing action argument in setkeys macro 3 years ago
Sayan Nandan 26775924ac Add tests for pop 3 years ago
Sayan Nandan 57c957d4e7 Add `pop` action 3 years ago
Sayan cdae667cb0
Fix pid file creation (#170)
* Remove the pid file if runtime errors occur

* Clean up error handling and fix pid file creation

The pid file was being created before evaluating the args, now it may
happen that incorrect args or --help was passed: in that event, the pid
file remains created. This was also fixed, besides some refactoring.
3 years ago
Sayan ca9e482f47
Deter other processes from using the same data dir (#169)
* Deter other processes from using the same data dir

For more information, see #167

* Don't lock `pid_file`

Windows has mandatory locking so second instance won't be able to read
the PID of the other process. We'll just keep the file descriptor/handle
open
3 years ago
Sayan 7349e461e6
Try to auto recover the save operation on termination (#166)
This is very useful because it removes the need for user intervention in
the event save on termination fails. Say the save operation fails due to
'some bad daemon' changing the directory's perms. Now skyd reports this
error while trying to save upon termination. Our sysadmin now fixes the
perms issue. The previous design would force the sysadmin to _somehow_
foreground skyd and hit enter. That is silly. The new design just
attempts to do a save operation every 10 seconds. So in case the issue
is fixed, the save operation will recover on its own.

Why not exponential backoff?
That's because the issue can be fixed some long time later and we may
have reached a large backoff value so the save that could have succeeded
would have to wait for a long duration before it can do anything
meaningful.

This also fixes a bug that caused BGSAVE errors to be reported as info
class log entries.
3 years ago
Sayan 8df9901740
Upgrade deps and actiondoc (#165) 3 years ago
Sayan e553c5172b
Release v0.6.1 (#164)
* Explicitly fsync and relax CPU on snap busy-loop

This commit also switches to using global `VERSION` and `URL` statics
than defining it per-crate.

* Add changelog entry and bump up version

* Optimize `dbtest` macro and rm redundant allocs

* Upgrade deps
3 years ago
Sayan Nandan 0c33395a09 Add some general optimizations 3 years ago
Sayan 1bde8b197d
Fix file-locking on solaris (#162) 3 years ago
Sayan Nandan 72d871ed3f Upgrade deps 3 years ago
Sayan Nandan 1bec90baac Optimize `sset` and `sdel` implementations 3 years ago
Sayan Nandan 2eedb041bb Make `gen_constants_and_matches!` macro logical
This commit imporves the overall 'look' of the macro and makes it appear
more logical
3 years ago
Sayan Nandan 58830edc80 Use iterators for actions 3 years ago
Sayan Nandan a839137643 Move actions into an `actions` module
These are actions and shouldn't be called the `kvengine`.
3 years ago
Sayan Nandan f8ea4c33de ucase for ASCII only
This is a silly optimization but can be significantly faster for larger
action names. Also, since there are (should be) no UTF-8 characters in
the first argument, this is absolutely fine and sensible.
3 years ago
Sayan Nandan a68c42f720 Document missing instances of `unsafe` 3 years ago
Sayan 952c5caa86
Poison the database by default if snapshotting fails (#160)
* Stop accepting writes if snapshotting fails

This is an important consideration: if BGSAVE fails and poisons the
database, snapshotting can and should too. But this is debatable in some
parts. For example, users may configure snapshots to be on a network
file system (symlinked maybe) and this can fail.
Now in some cases, this failure 'may be acceptable'. This commit adds a
way to customize this behavior through the `failsafe` key in the
snapshots section of the cfg file and through the --stop-write-on-fail
option passed to `skyd` on startup. However, BGSAVE remains unchanged:
it will always poison the database if it fails. If the user doesn't want
this, they can simply disable BGSAVE.

* Add changelog
3 years ago
Sayan Nandan ac336ff821 Add missing changes in changelog
Use `pat` token instead of `path` in query engine
3 years ago
Sayan Nandan eea0f86c97 Upgrade skytable client driver version 3 years ago
Sayan 6c9a36d397
Improve compat to use storage formats for upgrades (#158) 3 years ago
Sayan Nandan 260b336bf6 Add tests for races and synchronized unlocks 3 years ago
Sayan a1320da52b
Migrate to using `Coremap` (#156)
* Upgrade all interfaces to use new HTable

* Document `HTable`
3 years ago
Sayan Nandan 966c2594bf Fix `lskeys` tests 3 years ago
Sayan Nandan b77b783064 Add tests for lskeys 3 years ago
Sayan Nandan ea7891fba7 Implement lskeys 3 years ago
Sayan Nandan 449da56308 Upgrade all interfaces to use new in-memory table 3 years ago
Sayan Nandan 975e953426 Add compat module for upgrading old files 3 years ago
Sayan Nandan c2a20d4476 Implement serialize/deserialize for `HTable` 3 years ago
Sayan Nandan a7f5d84ef4 Bump dependencies
Also use `tokio::join` in-place of `futures::join`
3 years ago
Sayan 790558d2c7
Improve reliability, simplicity and recoverability of BGSAVE (#153)
* Create a new file on writing to flock-ed file

This fix is a very important one in two ways. Say we have an user A.
They go ahead and launch skyd. skyd creates a data.bin file. Now A just
deletes the data.bin file for fun. Funny enough, this never causes flock
to error!
Why? Well because the descriptor/handle is still valid and was just
unlinked from the current directory. But this might seem silly since
the user exits with a 'successfully saved notice' only to find that the
file never existed and all of their data was lost. That's bad.
There's a hidden problem in our current approach too, apart from this.
Our writing process begins by truncating the old file and then writing
to it by placing the cursor at 0. Nice, but what if this operation just
crashes. So we lost the current data AND the old data. Not good.

This commit does a better thing: it creates a new temporary file, locks
it before writing and then flushes the current data to the temporary
file. Once that succeeds, it replaces the old data.bin file with the
newly created file.

This solves both the problems mentioned here for us:
1. No more of the silly error
2. If BGSAVE crashes in between, we can be sure that at least the last
data.bin file is in proper shape and not half truncated or so.

This commit further moves the background services into their
own module(s) for easy management.

* Fix CI scripts

Fixes:
1. Our custom runner (drone/.ci.yml) was modified to kill the skyd
process once done since this pipeline is not ephemeral.
2. GHA for some reason ignores any error in the test step and proceeds
to kill the skyd process without erroring. Since GHA runners are
ephemeral, we don't need to do this manually.
3 years ago
Sayan Nandan 85616544ef Ensure that the entire file is locked
Although this is barely documented, setting the nNumberOfBytesToLockLow
and nNumberOfBytesToLockHigh to MAXDWORD apparently locks the entire
file
3 years ago
Sayan Nandan 42ad5680ff Fix missing imports on Windows
I'm not on a Windows machine, so I don't get these errors reported!
3 years ago