Skip to content

[ABANDON] Support for single-primary, multi-secondary processes#4931

Closed
riversand963 wants to merge 5 commits intofacebook:masterfrom
riversand963:multiproc
Closed

[ABANDON] Support for single-primary, multi-secondary processes#4931
riversand963 wants to merge 5 commits intofacebook:masterfrom
riversand963:multiproc

Conversation

@riversand963
Copy link
Copy Markdown
Contributor

This PR allows RocksDB to run in single-primary, multi-secondary process mode.
The writer is a regular RocksDB (e.g. an DBImpl) instance playing the role of a primary.
Multiple DBImplSecondary processes (secondaries) share the same set of SST files, MANIFEST, WAL files with the primary. Secondaries tail the MANIFEST of the primary and apply updates to their own in-memory state of the file system, e.g. VersionStorageInfo.

This PR has three components:

  1. (Originally in Add PathNotFound subcode to IOError #4745). Add a 'PathNotFound' subcode to IOError to denote the failure when a secondary tries to open a file which has been deleted by the primary.

  2. (Originally in Support non-blocking, retryable record reading #4602). Add TryReadRecord method to log::Reader so that caller can call TryReadRecord
    multiple times until a complete record is read. When a complete record is read,
    TryReadRecord returns true; when a record has remaining part yet to be
    read, or an error has occurred, TryReadRecord returns false. The caller can
    implement different retry policies.
    Example usage:

log::Reader reader(...);
Slice record;
std::string scratch;
while (reader.TryReadRecord(&record, &scratch)) {
  // process record
}
if (reader.reader_error_) {
 // handle error
} else {
 // consider retry
}

Note that reader_error_ is not exposed at the moment. Furthermore, we need
finer-grained error handling according to error type that is not exposed
either.

  1. (Originally in Add support for MANIFEST tailing #4710 and Add unit test for DBImplSecondary #4820). Add implementation of the secondary, i.e. DBImplSecondary.
    3.1 Tail the primary's MANIFEST during recovery.
    3.2 Tail the primary's MANIFEST during normal processing by calling ReadAndApply.
    3.3 Tailing WAL will be in a future PR.

Test plan
A general check of all tests.

$make clean && make -j32 all check

Specifically, if you are interested in testing log reader related changes, run the following

$./log_test
$./log_test --gtest_filter=bool/RetriableLogTest.NonBlockingReadFullRecord/*

To test the basic functionality of DBImplSecondary, run the following

./db_secondary_test

All tests must pass.

Summary: As titled. Returning error about non-existing path can help user
better handle them.

Test Plan:
```
$make clean && make -j32 all check
```

Reviewers:

Subscribers:

Tasks:

Tags:
Add TryReadRecord method to log::Reader so that caller can call `TryReadRecord`
multiple times until a complete record is read. When a complete record is read,
`TryReadRecord` returns `true`; when a record has remaining part yet to be
read, or an error has occurred, `TryReadRecord` returns false. The caller can
implement different retry *policies*.

Also add unit test for non-blocking record read.

Example usage:
```
log::Reader reader(...);
Slice record;
std::string scratch;
while (reader.TryReadRecord(&record, &scratch)) {
  // process record
}
if (reader.reader_error_) {
 // handle error
} else {
 // consider retry
}
```
Note that `reader_error_` is not exposed at the moment. Furthermore, we need
finer-grained error handling according to error type that is not exposed
either.

Update log test and rebase.

Test plan:
```
$make clean && make -j32 all check
$./log_test
$./log_test --gtest_filter=bool/RetriableLogTest.NonBlockingReadFullRecord/*
```
Test plan (to be updated)
```
$make clean && make -j32 all check
```

All tests must pass.
Summary: as title

Test Plan:
```
$make clean && make -j32 db_secondary_test
$./db_secondary_test
```
All tests must pass.
@riversand963 riversand963 self-assigned this Jan 29, 2019
@riversand963 riversand963 changed the title Support for single-primary, multi-secondary processes [ABANDON] Support for single-primary, multi-secondary processes Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants