Skip to content

Commit 4bc2f52

Browse files
committed
Add deployment notes and update docs on storage
1 parent 2c57a0c commit 4bc2f52

File tree

6 files changed

+73
-33
lines changed

6 files changed

+73
-33
lines changed

deploy.sh

100644100755
File mode changed.

docs/4.persistence.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
id: persistence
33
title: Persistence
44
---
5+
56
Skytable supports the persistent storage of data, which is an inherently obvious need for any database. In this document we explore how Skytable's persistence works.
67

78
## Data directory structure
89

910
Whenever you start Skytable, it will create a number of directories under a root 'data' directory. This is what the
1011
data directory structure looks like:
12+
1113
```
1214
|__user-files (your other files)
1315
|__data
@@ -18,34 +20,44 @@ data directory structure looks like:
1820
|___<snapshotname>.snapshot (many)
1921
```
2022

21-
The `data.bin` file is primarily used for persistence while the snapshots folder contains automatically created
23+
The `data.bin` file is primarily used for persistence while the snapshots folder contains automatically created
2224
snapshots and remotely created snapshots.
2325

2426
## How Skytable stores data
2527

26-
As soon as you start Skytable, it will look for a `data.bin` file in the data directory and then fall back to the
27-
`data.bin` file in the current directory for backwards compatibility. The database daemon will then attempt to
28-
migrate the older data into the structure noted above if required.
29-
:::note
30-
This backward compatibility will possibly be removed in future releases
31-
:::
32-
If the data file is found and successfully read, then the previous data is moved into the in-memory table. If no
28+
As soon as you start Skytable, it will look for a `data.bin` file in the data directory;
29+
if the data file is found and successfully read, then the previous data is moved into the in-memory table. If no
3330
file was found, then the database server will create one. Once you terminate the daemon, it will flush all data
34-
to this file. There are more features like [BGSAVE](#automated-background-saving) and [snapshots](/snapshots) that
35-
can be configured and used by users.
31+
to this file. All writes are `fsync`ed by the time they complete.
32+
33+
### Save failure during termination
3634

35+
The server would attempt to do a _final_ save operation before it terminates and if this fails, the
36+
server would enter into a retry loop. It will try the save operation after every 10 seconds.
37+
Exponential backoff was not chosen because it could increase to extremely large values that may hurt
38+
a sysadmin's time and productivity.
39+
40+
You might be interested in more features like [BGSAVE](#automated-background-saving) and [snapshots](/snapshots) that
41+
can be configured and used by users.
3742

3843
## Automated background saving
3944

4045
Skytable supports automated saving of data in the background, via `BGSAVE`. `BGSAVE`, runs every two minutes to flush all the data in the in-memory table onto disk, unless customized through the [configuration file](config-files/#an-example-configuration). BGSAVE is enabled by default and we don't recommend disabling it until you're sure that
4146
your hardware will never fail; it is likely that this will never be the case. First BGSAVE will create a temporary
42-
file and then flush the current in-memory table onto disk. It will then replace the old `data.bin` file.
47+
file and then flush the current in-memory table onto disk. It will then replace the old `data.bin` file. The daemon automatically `fsync`s after every successful write (whether to the buffers or
48+
to the actual disk).
4349

4450
### Reliability of BGSAVE
4551

46-
It can happen that BGSAVE fails to flush data to the disk due to some unforeseen system issues (such as lack of
52+
It can happen that BGSAVE fails to flush data to the disk due to some unforeseen system issues (such as lack of
4753
empty disk space, permission errors, etc). But if we continue to accept modifications to the data, it is a bad idea
4854
because this data may never get updated! This is why if BGSAVE fails, it will automatically _poison_ the in-memory
4955
table preventing it from accepting any write/update operations. Poisioning is nothing but a global flag set in the
5056
database that indicates that the DB shouldn't accept any more updates/writes to data and in such a poisoned state,
51-
only reads are permitted.
57+
only reads are permitted.
58+
59+
### BGSAVE Recovery
60+
61+
BGSAVE will automatically try to recover on every 120s (or whatever duration was set). If the problem
62+
was corrected (say it was a permissions issue), then the database server will automatically resume
63+
writes and _unpoison_ the database.

docs/5.cfg-files.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,36 @@
22
id: config-files
33
title: Configuration Files
44
---
5+
56
Skytable supports custom configuration files to let users customize the functioning of Sky. Arguably, Sky has one of the simplest configuration files around. Skytable also allows configuration via [command line arguments](config-cmd).
67

78
## An example configuration
89

9-
A configuration file is a TOML file, which looks like:
10+
A configuration file is a TOML file, which has the following basic structure:
1011

11-
``` toml
12+
```toml
1213
[server]
1314
host = "127.0.0.1"
1415
port = 2003
15-
noart = false
16+
noart = false # optional
1617

1718
[bgsave]
1819
enabled = true
1920
every = 120 # Every 120 seconds
2021
```
2122

22-
This is the default configuration used by Sky when you don't specify a configuration file. Let's understand what each of the keys mean:
23+
This is the default configuration used by Sky when you don't specify a configuration file. Let's understand what each of the keys mean along with some other keys that can be used for more
24+
advanced configuration:
2325

24-
* `server` :
25-
- `host` : This is the IP address to which you want the database server to bind to. It can be any valid IPv4 *or* IPv6 address, as a quoted string
26-
- `port` : This is the port to which you want Sky to bind to
27-
- `noart` (OPTIONAL): This is **an optional argument** and is recommended for secure environments where displaying terminal artwork might cause problems
28-
* `bgsave`:
29-
- `enabled` : This is an optional key, which is to be set to true to enable BGSAVE or false to disable it. If this key is not specified, Sky will enable BGSAVE by default
30-
- `every` : Run BGSAVE `every` seconds. So, for example, if you set this to 120, BGSAVE will run every two minutes. This is also an optional key, and if you don't provide it, the default BGSAVE duration of 120 seconds is used
31-
* `snapshot` (OPTIONAL): This key can be used to configure snapshots and is not enabled by default. See [this](snapshots) for more information.
32-
* `ssl`: This key can be used to configure SSL/TLS options. See [this](ssl) for more information.
26+
- `server` :
27+
- `host` : This is the IP address to which you want the database server to bind to. It can be any valid IPv4 _or_ IPv6 address, as a quoted string
28+
- `port` : This is the port to which you want Sky to bind to
29+
- `noart`: This is **an optional argument** and is recommended for secure environments where displaying terminal artwork might cause problems
30+
- `bgsave`:
31+
- `enabled`: This is an optional key, which is to be set to true to enable BGSAVE or false to disable it. If this key is not specified, Sky will enable BGSAVE by default
32+
- `every` : Run BGSAVE `every` seconds. So, for example, if you set this to 120, BGSAVE will run every two minutes. This is also an optional key, and if you don't provide it, the default BGSAVE duration of 120 seconds is used
33+
- `snapshot` (OPTIONAL): This key can be used to configure snapshots and is not enabled by default. See [this](snapshots) for more information.
34+
- `ssl`: This key can be used to configure SSL/TLS options. See [this](ssl) for more information.
3335

3436
## Using a configuration file
3537

@@ -44,11 +46,15 @@ If you're confused about creating a configuration file, we always recommend you
4446
That's all that's there for using configuration files!
4547
:::tip Bonus tip
4648
If you're using a custom host/port, then you can bind `skysh` to a custom host/port by starting `skysh` like:
49+
4750
```shell
4851
skysh -h [HOST] -p [PORT]
4952
```
53+
5054
You can do the same for `sky-bench`:
55+
5156
```shell
5257
sky-bench -h [HOST] -p [PORT]
5358
```
54-
:::
59+
60+
:::

docs/deployment-notes.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
id: deployment-notes
3+
title: Deployment notes
4+
---
5+
6+
Here are some _good to know_ things about deploying Skytable:
7+
8+
- Skytable is under active development. If you do find any rough edges, [please open an issue](https://github.com/skytable/skytable/issues)
9+
- The daemon will create a `.sky_pid` file in its working directory which functions as a PID file
10+
and indicates other processes to not use the data directory. If the daemon is somehow forcefully
11+
stopped, the file may not be removed. In that case, you should manually remove the file
12+
- Skytable currently has a hardcoded limit of 50000 connections on a single daemon instance. This limit will be user accessible in the (near) future
13+
- Skytable is inherently multithreaded. As of now, there is no way to stop Skytable from using
14+
multiple threads
15+
- The best way to deploy Skytable is as a service (and passing `--noart` to avoid terminal artwork
16+
in logs)

docs/snapshots.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@
22
id: snapshots
33
title: Snapshots
44
---
5-
Skytable supports automated snapshots that can be used for periodic backups.
5+
6+
Skytable supports automated snapshots that can be used for periodic backups.
67
Skytable's snapshotting system is dead simple and works in a similar way to [BGSAVE](persistence).
78

89
## Enabling snapshots
910

10-
Snapshots aren't enabled by default - you have to enable them by using the configuration file or [command line arguments](config-cmd) To your existing configuration file, just add the following block:
11+
Snapshots aren't enabled by default - you have to enable them by using the configuration file or [command line arguments](config-cmd) To your existing configuration file, just add the following block:
1112

12-
``` toml
13+
```toml
1314
[snapshot]
1415
every = 3600
1516
atmost = 4
17+
failsafe = true # optional
1618
```
1719

1820
Here's what these values mean:
1921

20-
* `every` - Number of seconds to wait before creating another snapshot
21-
* `atmost` - The maximum number of snapshots to keep
22+
- `every` - Number of seconds to wait before creating another snapshot
23+
- `atmost` - The maximum number of snapshots to keep
24+
- `failsafe` - This indicates whether the database should stop accepting write operations if
25+
snapshotting fails
2226

2327
## Storage of snapshots
2428

@@ -32,4 +36,4 @@ As mentioned earlier, snapshots work just like `BGSAVE` . A task is spawned that
3236

3337
## Methods of creating snapshots
3438

35-
Snapshots can be created automatically by using the configuration file. However, if you want to create snapshots remotely, you can use the [ `MKSNAP` ](actions/mksnap) action. Do note that this **requires snapshotting to be enabled** before it can create snapshots.
39+
Snapshots can be created automatically by using the configuration file. However, if you want to create snapshots remotely, you can use the [ `MKSNAP` ](actions/mksnap) action. Do note that this **requires snapshotting to be enabled** before it can create snapshots.

sidebars.auto.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
"snapshots",
1212
"ssl",
1313
"benchmarking",
14+
"deployment-notes",
1415
"building-from-source",
1516
{
1617
"type": "category",
@@ -28,6 +29,7 @@ module.exports = {
2829
"actions/mksnap",
2930
"actions/mset",
3031
"actions/mupdate",
32+
"actions/pop",
3133
"actions/sdel",
3234
"actions/set",
3335
"actions/sset",

0 commit comments

Comments
 (0)