Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for single-primary, multi-secondary instances #4899

Closed
wants to merge 33 commits into from

Conversation

riversand963
Copy link
Contributor

@riversand963 riversand963 commented Jan 18, 2019

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 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. (Similar to Support non-blocking, retryable record reading #4602). Add FragmentBufferedReader to handle partially-read, trailing record at the end of a log from where future read can continue.

  3. (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.

  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.

Test plan
A general check of all tests.

$make clean && make -j32 all
$make check

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

$./log_test

To test the basic functionality of DBImplSecondary, run the following

./db_secondary_test

All tests must pass. It's also highly recommended to repeat the tests with ASAN.

@riversand963 riversand963 self-assigned this Jan 18, 2019
@riversand963 riversand963 force-pushed the multiproc branch 2 times, most recently from e923fdb to c00aeb3 Compare January 29, 2019 22:36
@riversand963 riversand963 changed the title Support for single-primary, multi-secondary processes [ABANDONED] Support for single-primary, multi-secondary processes Jan 29, 2019
@riversand963 riversand963 reopened this Jan 29, 2019
@riversand963 riversand963 changed the title [ABANDONED] Support for single-primary, multi-secondary processes Support for single-primary, multi-secondary processes Jan 29, 2019
db/db_impl_secondary.cc Outdated Show resolved Hide resolved
db/db_impl_secondary.cc Outdated Show resolved Hide resolved
db/db_impl_secondary.cc Outdated Show resolved Hide resolved
db/db_impl_secondary.cc Show resolved Hide resolved
db/db_impl_secondary.cc Outdated Show resolved Hide resolved
db/db_impl_secondary.cc Show resolved Hide resolved
db/db_impl_secondary.cc Outdated Show resolved Hide resolved
db/db_impl_secondary.cc Outdated Show resolved Hide resolved
db/version_set.cc Outdated Show resolved Hide resolved
db/log_reader.cc Show resolved Hide resolved
db/version_set.cc Outdated Show resolved Hide resolved
Copy link
Contributor

@siying siying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's awesome to see this complicated feature to close to the final line!

@riversand963 riversand963 force-pushed the multiproc branch 4 times, most recently from 3a0cd70 to 6d1864a Compare February 20, 2019 17:34
@riversand963 riversand963 force-pushed the multiproc branch 6 times, most recently from 95abeec to eaa0001 Compare March 4, 2019 05:05
@riversand963 riversand963 requested a review from siying March 4, 2019 21:57
@facebook-github-bot
Copy link
Contributor

@riversand963 has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@riversand963 has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

include/rocksdb/db.h Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@riversand963 has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@riversand963 merged this pull request in 9358178.

@riversand963 riversand963 deleted the multiproc branch March 27, 2019 00:26
@rockeet
Copy link
Contributor

rockeet commented Mar 27, 2019

as in 3.3: Tailing WAL will be in a future PR.

@riversand963 How long does this future mean? We are eager to using this feature.

@riversand963
Copy link
Contributor Author

Thanks @rockeet for the interest. We plan to start this next week. Since we also have other items, the new feature can be ready anytime between next month or middle of this year depending on our task prioritization.

@rockeet
Copy link
Contributor

rockeet commented Mar 29, 2019

Thanks @riversand963, This is a very great feature!

jwasinger pushed a commit to jwasinger/rocksdb that referenced this pull request Apr 1, 2019
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
facebook-github-bot pushed a commit that referenced this pull request Apr 24, 2019
Summary: PR #4899 implemented the general framework for RocksDB secondary instances. This PR adds the support for WAL tailing in `OpenAsSecondary`, which means after the `OpenAsSecondary` call, the secondary is now able to see primary's writes that are yet to be flushed. The secondary can see primary's writes in the WAL up to the moment of `OpenAsSecondary` call starts.

Differential Revision: D15059905

Pulled By: miasantreble

fbshipit-source-id: 44f71f548a30b38179a7940165e138f622de1f10
vagogte pushed a commit to vagogte/rocksdb that referenced this pull request Jun 18, 2019
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
vagogte pushed a commit to vagogte/rocksdb that referenced this pull request Jun 18, 2019
Summary: PR facebook#4899 implemented the general framework for RocksDB secondary instances. This PR adds the support for WAL tailing in `OpenAsSecondary`, which means after the `OpenAsSecondary` call, the secondary is now able to see primary's writes that are yet to be flushed. The secondary can see primary's writes in the WAL up to the moment of `OpenAsSecondary` call starts.

Differential Revision: D15059905

Pulled By: miasantreble

fbshipit-source-id: 44f71f548a30b38179a7940165e138f622de1f10
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.

5 participants