Support non-blocking, retryable record reading#4602
Support non-blocking, retryable record reading#4602riversand963 wants to merge 1 commit intofacebook:masterfrom
Conversation
|
@siying and @miasantreble , could you take a look and see if this looks good? If so, I'll continue to add more tests. p.s. I'm considering removing Update: Update on 10/31/2018: |
bea41cf to
0005dc3
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
348fa48 to
a4eb6d6
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
a4eb6d6 to
6c1df23
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
6c1df23 to
1da0c00
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
1da0c00 to
a7015ae
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
a7015ae to
b78e421
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
b78e421 to
9426c03
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
9426c03 to
d0d668f
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
d0d668f to
bbfe187
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
bbfe187 to
a92d1ff
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
a92d1ff to
6c445cd
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
6c445cd to
7b43698
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
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/*
```
7b43698 to
5b8452b
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Moved to #4899 |
Summary: 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 several components: 1. (Originally in #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. (Similar to #4602). Add `FragmentBufferedReader` to handle partially-read, trailing record at the end of a log from where future read can continue. 3. (Originally in #4710 and #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. 4. Add an example in 'examples/multi_processes_example.cc' to demonstrate the usage of secondary RocksDB instance in a multi-process setting. Instructions to run the example can be found at the beginning of the source code. Pull Request resolved: #4899 Differential Revision: D14510945 Pulled By: riversand963 fbshipit-source-id: 4ac1c5693e6012ad23f7b4b42d3c374fecbe8886
Summary: 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 several components: 1. (Originally in facebook#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. (Similar to facebook#4602). Add `FragmentBufferedReader` to handle partially-read, trailing record at the end of a log from where future read can continue. 3. (Originally in facebook#4710 and facebook#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. 4. Add an example in 'examples/multi_processes_example.cc' to demonstrate the usage of secondary RocksDB instance in a multi-process setting. Instructions to run the example can be found at the beginning of the source code. Pull Request resolved: facebook#4899 Differential Revision: D14510945 Pulled By: riversand963 fbshipit-source-id: 4ac1c5693e6012ad23f7b4b42d3c374fecbe8886
Summary: 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 several components: 1. (Originally in facebook#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. (Similar to facebook#4602). Add `FragmentBufferedReader` to handle partially-read, trailing record at the end of a log from where future read can continue. 3. (Originally in facebook#4710 and facebook#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. 4. Add an example in 'examples/multi_processes_example.cc' to demonstrate the usage of secondary RocksDB instance in a multi-process setting. Instructions to run the example can be found at the beginning of the source code. Pull Request resolved: facebook#4899 Differential Revision: D14510945 Pulled By: riversand963 fbshipit-source-id: 4ac1c5693e6012ad23f7b4b42d3c374fecbe8886
Add TryReadRecord method to log::Reader so that caller can call
TryReadRecordmultiple times until a complete record is read. When a complete record is read,
TryReadRecordreturnstrue; when a record has remaining part yet to beread, or an error has occurred,
TryReadRecordreturns false. The caller canimplement different retry policies.
Also add unit test for non-blocking record read.
Example usage:
Note that
reader_error_is not exposed at the moment. Furthermore, we needfiner-grained error handling according to error type that is not exposed
either.
Test plan: