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

Fix OnFlushCompleted fired before flush result write to MANIFEST #5908

Closed
wants to merge 15 commits into from
Closed

Fix OnFlushCompleted fired before flush result write to MANIFEST #5908

wants to merge 15 commits into from

Conversation

yiwu-arbug
Copy link
Contributor

@yiwu-arbug yiwu-arbug commented Oct 11, 2019

Summary:
When there are concurrent flush job on the same CF, OnFlushCompleted can be called before the flush result being install to LSM. Fixing the issue by passing FlushJobInfo through MemTable, and the thread who commit the flush result can fetch the FlushJobInfo and fire OnFlushCompleted on behave of the thread actually writing the SST.

Fix #5892

Test Plan:
Add new test. The test will fail without the fix.

Yi Wu added 4 commits October 11, 2019 05:26
Signed-off-by: Yi Wu <yiwu@pingcap.com>
Signed-off-by: Yi Wu <yiwu@pingcap.com>
Signed-off-by: Yi Wu <yiwu@pingcap.com>
Signed-off-by: Yi Wu <yiwu@pingcap.com>
db/flush_job.h Outdated Show resolved Hide resolved
Yi Wu added 5 commits October 14, 2019 18:32
Signed-off-by: Yi Wu <yiwu@pingcap.com>
Signed-off-by: Yi Wu <yiwu@pingcap.com>
Signed-off-by: Yi Wu <yiwu@pingcap.com>
Copy link
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 minor comments.
The appveyor is still failing.

db/db_flush_test.cc Outdated Show resolved Hide resolved
db/db_flush_test.cc Outdated Show resolved Hide resolved
db/db_flush_test.cc Show resolved Hide resolved
db/db_flush_test.cc Outdated Show resolved Hide resolved
db/db_impl/db_impl.h Show resolved Hide resolved
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.

Signed-off-by: Yi Wu <yiwu@pingcap.com>
@facebook-github-bot
Copy link
Contributor

@yiwu-arbug has updated the pull request. Re-import the pull request

@facebook-github-bot
Copy link
Contributor

@yiwu-arbug has updated the pull request. Re-import the pull request

Signed-off-by: Yi Wu <yiwu@pingcap.com>
@facebook-github-bot
Copy link
Contributor

@yiwu-arbug has updated the pull request. Re-import the pull request

Copy link
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. Let's wait for CI tests results.

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.

@yiwu-arbug
Copy link
Contributor Author

What's the linter error? Thanks.

@riversand963
Copy link
Contributor

There are several of them.

  1. db_flush_test.cc
  • line 365, seq1 uninitialized.
  • line 366, seq2 uninitizlized.
  • line 371, first_flush_pending unused.
  1. db_impl_compaction_flush.cc
  • line 386, Getting a pointer to the first element of a vector can be UB If a vector is empty, getting a pointer to the start of its data block through &v[0] is undefined behaviour. If you want a pointer to the vector's memory, please call .data()
  • line 508, Array accesses with [] or calls to front() or back() will segfault when called on empty arrays. Please make sure that you use them in a safe context by either explicitly checking the arrays size before you access it or by asserting that it is not empty. Local variable all_mutable_cf_options accessed at line 508 may be empty.

Signed-off-by: Yi Wu <yiwu@pingcap.com>
@facebook-github-bot
Copy link
Contributor

@yiwu-arbug 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.

@riversand963
Copy link
Contributor

Still lint error. I can push to your branch if you want. @yiwu-arbug

@yiwu-arbug
Copy link
Contributor Author

Still lint error. I can push to your branch if you want. @yiwu-arbug

go ahead. I think you can edit the PR from github UI.

Assert `file_meta` is non-empty before accessing it via subscription.
@facebook-github-bot
Copy link
Contributor

@yiwu-arbug 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

@yiwu-arbug 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.

@riversand963
Copy link
Contributor

Double checked the lint error and suggested change shown as below. I think we can just ignore it given that we assert the non-emptiness of file_meta.

-        jobs[0]->Run(&logs_with_prep_tracker_, &file_meta[0]);
+        jobs[0]->Run(&logs_with_prep_tracker_, file_meta.data());

@yiwu-arbug yiwu-arbug deleted the flush_fix branch October 16, 2019 17:45
@yiwu-arbug
Copy link
Contributor Author

@riversand963 thanks much for merging!

@facebook-github-bot
Copy link
Contributor

@riversand963 merged this pull request in 1f9d7c0.

yiwu-arbug pushed a commit to tikv/rocksdb that referenced this pull request Oct 30, 2019
…ebook#5908) (#127)

Summary:
When there are concurrent flush job on the same CF, `OnFlushCompleted` can be called before the flush result being install to LSM. Fixing the issue by passing `FlushJobInfo` through `MemTable`, and the thread who commit the flush result can fetch the `FlushJobInfo` and fire `OnFlushCompleted` on behave of the thread actually writing the SST.

Fix facebook#5892
Pull Request resolved: facebook#5908

Test Plan: Add new test. The test will fail without the fix.

Differential Revision: D17916144

Pulled By: riversand963

fbshipit-source-id: e18df67d9533b5baee52ae3605026cdeb05cbe10
merryChris pushed a commit to merryChris/rocksdb that referenced this pull request Nov 18, 2019
…ebook#5908)

Summary:
When there are concurrent flush job on the same CF, `OnFlushCompleted` can be called before the flush result being install to LSM. Fixing the issue by passing `FlushJobInfo` through `MemTable`, and the thread who commit the flush result can fetch the `FlushJobInfo` and fire `OnFlushCompleted` on behave of the thread actually writing the SST.

Fix facebook#5892
Pull Request resolved: facebook#5908

Test Plan: Add new test. The test will fail without the fix.

Differential Revision: D17916144

Pulled By: riversand963

fbshipit-source-id: e18df67d9533b5baee52ae3605026cdeb05cbe10
Connor1996 pushed a commit to tikv/rocksdb that referenced this pull request Nov 19, 2019
…ebook#5908) (#127) (#130)

Summary:
When there are concurrent flush job on the same CF, `OnFlushCompleted` can be called before the flush result being install to LSM. Fixing the issue by passing `FlushJobInfo` through `MemTable`, and the thread who commit the flush result can fetch the `FlushJobInfo` and fire `OnFlushCompleted` on behave of the thread actually writing the SST.

Fix facebook#5892
Pull Request resolved: facebook#5908

Test Plan: Add new test. The test will fail without the fix.

Differential Revision: D17916144

Pulled By: riversand963

fbshipit-source-id: e18df67d9533b5baee52ae3605026cdeb05cbe10
Signed-off-by: Yi Wu <yiwu@pingcap.com>
facebook-github-bot pushed a commit that referenced this pull request Aug 3, 2021
Summary:
PR #5908 added `flush_jobs_info_` to `FlushJob` to make sure
`OnFlushCompleted()` is called after committing flush results to
MANIFEST. However, `flush_jobs_info_` is not updated in atomic
flush, causing `NotifyOnFlushCompleted()` to skip `OnFlushCompleted()`.

This PR fixes this, in a similar way to #5908 that handles regular flush.

Pull Request resolved: #8585

Test Plan: make check

Reviewed By: jay-zhuang

Differential Revision: D29913720

Pulled By: riversand963

fbshipit-source-id: 4ff023c98372fa2c93188d4a5c8a4e9ffa0f4dda
ltamasi pushed a commit that referenced this pull request Aug 4, 2021
Summary:
PR #5908 added `flush_jobs_info_` to `FlushJob` to make sure
`OnFlushCompleted()` is called after committing flush results to
MANIFEST. However, `flush_jobs_info_` is not updated in atomic
flush, causing `NotifyOnFlushCompleted()` to skip `OnFlushCompleted()`.

This PR fixes this, in a similar way to #5908 that handles regular flush.

Pull Request resolved: #8585

Test Plan: make check

Reviewed By: jay-zhuang

Differential Revision: D29913720

Pulled By: riversand963

fbshipit-source-id: 4ff023c98372fa2c93188d4a5c8a4e9ffa0f4dda
jaepil pushed a commit to deepsearch-hq/rocksdb-backup that referenced this pull request Aug 5, 2021
Summary:
PR facebook#5908 added `flush_jobs_info_` to `FlushJob` to make sure
`OnFlushCompleted()` is called after committing flush results to
MANIFEST. However, `flush_jobs_info_` is not updated in atomic
flush, causing `NotifyOnFlushCompleted()` to skip `OnFlushCompleted()`.

This PR fixes this, in a similar way to facebook#5908 that handles regular flush.

Pull Request resolved: facebook#8585

Test Plan: make check

Reviewed By: jay-zhuang

Differential Revision: D29913720

Pulled By: riversand963

fbshipit-source-id: 4ff023c98372fa2c93188d4a5c8a4e9ffa0f4dda
empiredan pushed a commit to empiredan/pegasus-rocksdb that referenced this pull request Dec 21, 2021
Summary:
PR facebook/rocksdb#5908 added `flush_jobs_info_` to `FlushJob` to make sure
`OnFlushCompleted()` is called after committing flush results to
MANIFEST. However, `flush_jobs_info_` is not updated in atomic
flush, causing `NotifyOnFlushCompleted()` to skip `OnFlushCompleted()`.

This PR fixes this, in a similar way to facebook/rocksdb#5908 that handles regular flush.

Pull Request resolved: facebook/rocksdb#8585

Test Plan: make check

Reviewed By: jay-zhuang

Differential Revision: D29913720

Pulled By: riversand963

fbshipit-source-id: 4ff023c98372fa2c93188d4a5c8a4e9ffa0f4dda
acelyc111 pushed a commit to XiaoMi/pegasus-rocksdb that referenced this pull request Dec 23, 2021
Summary:
PR facebook/rocksdb#5908 added `flush_jobs_info_` to `FlushJob` to make sure
`OnFlushCompleted()` is called after committing flush results to
MANIFEST. However, `flush_jobs_info_` is not updated in atomic
flush, causing `NotifyOnFlushCompleted()` to skip `OnFlushCompleted()`.

This PR fixes this, in a similar way to facebook/rocksdb#5908 that handles regular flush.

Pull Request resolved: facebook/rocksdb#8585

Test Plan: make check

Reviewed By: jay-zhuang

Differential Revision: D29913720

Pulled By: riversand963

fbshipit-source-id: 4ff023c98372fa2c93188d4a5c8a4e9ffa0f4dda

Co-authored-by: Yanqin Jin <yanqin@fb.com>
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.

OnFlushCompleted is called before flush completed
3 participants