Perform post-flush updates of memtable list in a callback#6069
Perform post-flush updates of memtable list in a callback#6069riversand963 wants to merge 3 commits intofacebook:masterfrom
Conversation
ab05811 to
c21a816
Compare
|
Cleaned up from #6064 |
c4b9a57 to
14be29e
Compare
create a pull to show our trivial fix ... |
I am hesitant about adding a member variable, 'callback' of type |
Our online service needs to be fixed right away :( Adding a callback to |
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.
|
Can this bug also cause issue for |
I think it's possible, though I have not used sync points to verify. Update: |
d4eae43 to
a92d0e4
Compare
|
@riversand963 has updated the pull request. Re-import the pull request |
a92d0e4 to
7d29681
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.
7d29681 to
57afc41
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.
57afc41 to
a7ac4a3
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.
7df9c03 to
709022d
Compare
|
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
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.
709022d to
59afbd1
Compare
|
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
59afbd1 to
fbbd640
Compare
|
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
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.
db/memtable_list.cc
Outdated
There was a problem hiding this comment.
I didn't read every line of this method, but I assume it just wraps the deleted contents of this file.
db/merge_test.cc
Outdated
There was a problem hiding this comment.
The bug may also affect delete? Can we add a test case for delete too?
There was a problem hiding this comment.
It should not. Can you elaborate on how delete can be affected?
|
Thanks @Cheng-Chang for the review! |
fbbd640 to
0746d73
Compare
|
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
|
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
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.
|
@riversand963 merged this pull request in 6134ce6. |
| * Since 6.14, fix false positive flush/compaction `Status::Corruption` failure when `paranoid_file_checks == true` and range tombstones were written to the compaction output files. | ||
| * Since 6.14, fix a bug that could cause a stalled write to crash with mixed of slowdown and no_slowdown writes (`WriteOptions.no_slowdown=true`). | ||
| * Fixed a bug which causes hang in closing DB when refit level is set in opt build. It was because ContinueBackgroundWork() was called in assert statement which is a no op. It was introduced in 6.14. | ||
| * Perform post-flush updates of in-memory data structures of memtable list in a callback that will be called by the thread writing to MANIFEST file before signaling other threads and releasing db mutex. |
There was a problem hiding this comment.
When looking at the release notes, I wasn't able to think of the user-visible bug that this referred to. Only by looking at the PR I learned it's a Get() correctness issue. Is it possible to write the note more in terms of what a user would observe?
There was a problem hiding this comment.
Sure, will submit a PR to address your comment.
) Summary: Currently, the following interleaving of events can lead to SuperVersion containing both immutable memtables as well as the resulting L0. This can cause Get to return incorrect result if there are merge operands. This may also affect other operations such as single deletes. ``` time main_thr bg_flush_thr bg_compact_thr compact_thr set_opts_thr 0 | WriteManifest:0 1 | issue compact 2 | wait 3 | Merge(counter) 4 | issue flush 5 | wait 6 | WriteManifest:1 7 | wake up 8 | write manifest 9 | wake up 10 | Get(counter) 11 | remove imm V ``` The reason behind is that: one bg flush thread's installing new `Version` can be batched and performed by another thread that is the "leader" MANIFEST writer. This bg thread removes the memtables from current super version only after `LogAndApply` returns. After the leader MANIFEST writer signals (releasing mutex) this bg flush thread, it is possible that another thread sees this cf with both memtables (whose data have been flushed to the newest L0) and the L0 before this bg flush thread removes the memtables. To address this issue, each bg flush thread can pass a callback function to `LogAndApply`. The callback is responsible for removing the memtables. Therefore, the leader MANIFEST writer can call this callback and remove the memtables before releasing the mutex. Test plan (devserver) ``` $make merge_test $./merge_test --gtest_filter=MergeTest.MergeWithCompactionAndFlush $make check ``` Pull Request resolved: facebook#6069 Reviewed By: cheng-chang Differential Revision: D18790894 Pulled By: riversand963 fbshipit-source-id: e41bd600c0448b4f4b2deb3f7677f95e3076b4ed
Currently, the following interleaving of events can lead to SuperVersion containing both immutable memtables as well as the resulting L0. This can cause Get to return incorrect result if there are merge operands. This may also affect other operations such as single deletes.
The reason behind is that: one bg flush thread's installing new
Versioncan be batched and performed by another thread that is the "leader" MANIFEST writer. This bg thread removes the memtables from current super version only afterLogAndApplyreturns. After the leader MANIFEST writer signals (releasing mutex) this bg flush thread, it is possible that another thread sees this cf with both memtables (whose data have been flushed to the newest L0) and the L0 before this bg flush thread removes the memtables.To address this issue, each bg flush thread can pass a callback function to
LogAndApply. The callback is responsible for removing the memtables. Therefore, the leader MANIFEST writer can call this callback and remove the memtables before releasing the mutex.Test plan (devserver)