more instructions for 2.5 and 2.6
Signed-off-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
@@ -32,7 +32,7 @@ src/lsm_storage.rs
|
|||||||
src/compact.rs
|
src/compact.rs
|
||||||
```
|
```
|
||||||
|
|
||||||
For now, we only use two types of the manifest records: SST flush and compaction. SST flush record stores the SST id that gets flushed to the disk. Compaction record stores the compaction task and the produced SST ids. Every time you write some new files the the disk, first sync the files and the storage directory, and then write to the manifest and sync the manifest.
|
For now, we only use two types of the manifest records: SST flush and compaction. SST flush record stores the SST id that gets flushed to the disk. Compaction record stores the compaction task and the produced SST ids. Every time you write some new files the the disk, first sync the files and the storage directory, and then write to the manifest and sync the manifest. The manifest file should be written to `<path>/MANIFEST`.
|
||||||
|
|
||||||
To sync the directory, you may implement the `sync_dir` function, where you can use `File::open(dir).sync_all()?` to sync it. On Linux, directory is a file that contains the list of files in the directory. By doing fsync on the directory, you will ensure that the newly-written (or removed) files can be visible to the user if the power goes off.
|
To sync the directory, you may implement the `sync_dir` function, where you can use `File::open(dir).sync_all()?` to sync it. On Linux, directory is a file that contains the list of files in the directory. By doing fsync on the directory, you will ensure that the newly-written (or removed) files can be visible to the user if the power goes off.
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ src/lsm_storage.rs
|
|||||||
|
|
||||||
`MemTable` has a WAL field. If the `wal` field is set to `Some(wal)`, you will need to append to the WAL when updating the memtable. In your LSM engine, you will need to create WALs if `enable_wal = true`. You will also need update the manifest using the `ManifestRecord::NewMemtable` record when new memtable is created.
|
`MemTable` has a WAL field. If the `wal` field is set to `Some(wal)`, you will need to append to the WAL when updating the memtable. In your LSM engine, you will need to create WALs if `enable_wal = true`. You will also need update the manifest using the `ManifestRecord::NewMemtable` record when new memtable is created.
|
||||||
|
|
||||||
|
You can create a memtable with WAL by using the `create_with_wal` function. WAL should be written to `<memtable_id>.wal` in the storage directory. The memtable id should be the same as the SST id if this memtable gets flushed as an L0 SST.
|
||||||
|
|
||||||
## Task 3: Recover from the WALs
|
## Task 3: Recover from the WALs
|
||||||
|
|
||||||
In this task, you will need to modify:
|
In this task, you will need to modify:
|
||||||
@@ -51,6 +53,8 @@ If WAL is enabled, you will need to recover the memtables based on WALs when loa
|
|||||||
cargo run --bin mini-lsm-cli -- --enable-wal
|
cargo run --bin mini-lsm-cli -- --enable-wal
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Remember to recover the correct `next_sst_id` from the state, which should be `max{memtable id, sst id}` + 1. In your `close` function, you should not flush memtables to SSTs if `enable_wal` is set to true, as WAL itself provides persistency.
|
||||||
|
|
||||||
## Test Your Understanding
|
## Test Your Understanding
|
||||||
|
|
||||||
* When can you tell the user that their modifications (put/delete) have been persisted?
|
* When can you tell the user that their modifications (put/delete) have been persisted?
|
||||||
|
|||||||
Reference in New Issue
Block a user