Skip to content

Fix ingested file and direcotry not being sync#5435

Closed
yiwu-arbug wants to merge 10 commits intofacebook:masterfrom
yiwu-arbug:sync_ingest
Closed

Fix ingested file and direcotry not being sync#5435
yiwu-arbug wants to merge 10 commits intofacebook:masterfrom
yiwu-arbug:sync_ingest

Conversation

@yiwu-arbug
Copy link
Copy Markdown
Contributor

@yiwu-arbug yiwu-arbug commented Jun 10, 2019

Summary:
It it not safe to assume application had sync the SST file before ingest it into DB. Also the directory to put the ingested file needs to be fsync, otherwise the file can be lost. For integrity of RocksDB we need to sync the ingested file and directory before apply the change to manifest.

Also syncing after writing global sequence when write_global_seqno=true was removed in #4172. Adding it back.

Fixes #5287.

Test Plan:
Test ingest file with ldb command and observe fsync/fdatasync in strace output. Tried both move_files=true and move_files=false.
https://gist.github.com/yiwu-arbug/650a4023f57979056d83485fa863bef9

More test suggestions are welcome.

Yi Wu added 2 commits June 10, 2019 20:52
Signed-off-by: Yi Wu <yiwu@pingcap.com>
Signed-off-by: Yi Wu <yiwu@pingcap.com>
@yiwu-arbug
Copy link
Copy Markdown
Contributor Author

@siying @riversand963 IMO this is a critical fix. PTAL. Thanks.

@ajkr If you have suggestion for test that's welcome. Thanks as well.

Signed-off-by: Yi Wu <yiwu@pingcap.com>
Signed-off-by: Yi Wu <yiwu@pingcap.com>
@yiwu-arbug
Copy link
Copy Markdown
Contributor Author

@riversand963 Do you have more comments? thanks!

Copy link
Copy Markdown
Contributor

@riversand963 riversand963 left a comment

Choose a reason for hiding this comment

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

Thanks @yiwu-arbug for the fix. I have taken a pass and left a few comments.

Signed-off-by: Yi Wu <yiwu@pingcap.com>
@riversand963
Copy link
Copy Markdown
Contributor

The AppVeyor error should have been fixed in master, and I believe it's irrelevant to this PR.
I think the feature LGTM, since it does not weaken the guarantee that RocksDB already provides. Do you plan to add unit test using fault injection env? For example, you can test the behavior of the db when syncing the sst fails.

Copy link
Copy Markdown
Contributor

@riversand963 riversand963 left a comment

Choose a reason for hiding this comment

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

LGTM

@yiwu-arbug
Copy link
Copy Markdown
Contributor Author

@riversand963 sure, I'll add the test.

Signed-off-by: Yi Wu <yiwu@pingcap.com>
@yiwu-arbug
Copy link
Copy Markdown
Contributor Author

@riversand963 test added. mind take another look? Thanks.

Yi Wu added 2 commits June 18, 2019 22:13
Signed-off-by: Yi Wu <yiwu@pingcap.com>
@yiwu-arbug
Copy link
Copy Markdown
Contributor Author

I didn't notice I left some debug log and failing CI. Fixed. @riversand963 mind take another look? Thanks.

@yiwu-arbug
Copy link
Copy Markdown
Contributor Author

@riversand963 kindly ping

@riversand963
Copy link
Copy Markdown
Contributor

I think there is compilation error:

In file included from test_util/fault_injection_test_env.cc:14:
./test_util/fault_injection_test_env.h:99:10: error: 'GetRequiredBufferAlignment' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
  size_t GetRequiredBufferAlignment() const {
         ^
./include/rocksdb/env.h:888:18: note: overridden virtual function is here
  virtual size_t GetRequiredBufferAlignment() const { return kDefaultPageSize; }
                 ^
1 error generated.

Yi Wu added 2 commits June 20, 2019 22:38
Signed-off-by: Yi Wu <yiwu@pingcap.com>
@yiwu-arbug
Copy link
Copy Markdown
Contributor Author

sorry. fixed.

Copy link
Copy Markdown
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.

@riversand963
Copy link
Copy Markdown
Contributor

LGTM

@yiwu-arbug yiwu-arbug deleted the sync_ingest branch June 21, 2019 17:54
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@riversand963 merged this pull request in 2730fe6.

merryChris pushed a commit to merryChris/rocksdb that referenced this pull request Nov 18, 2019
Summary:
It it not safe to assume application had sync the SST file before ingest it into DB. Also the directory to put the ingested file needs to be fsync, otherwise the file can be lost. For integrity of RocksDB we need to sync the ingested file and directory before apply the change to manifest.

Also syncing after writing global sequence when write_global_seqno=true was removed in facebook#4172. Adding it back.

Fixes facebook#5287.
Pull Request resolved: facebook#5435

Test Plan:
Test ingest file with ldb command and observe fsync/fdatasync in strace output. Tried both move_files=true and move_files=false.
https://gist.github.com/yiwu-arbug/650a4023f57979056d83485fa863bef9

More test suggestions are welcome.

Differential Revision: D15941675

Pulled By: riversand963

fbshipit-source-id: 389533f3923065a96df2cdde23ff4724a1810d78
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.

fsync directory after file ingestion

4 participants