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

fetch callback needs documented requirements #53

Open
vinniefalco opened this issue Mar 23, 2017 · 0 comments
Open

fetch callback needs documented requirements #53

vinniefalco opened this issue Mar 23, 2017 · 0 comments

Comments

@vinniefalco
Copy link
Member

The documentation needs to be explicit about the restrictions and limitations of what can be performed in the fetch callback:

From
https://www.reddit.com/r/cpp/comments/60px64/nudb_100_released_a_keyvalue_database_for_ssds/dfaj3z7/

db.insert(the_key, ...);
db.fetch(the_key, [&](void const* buffer, std::size_t size) {
    unexpectedly_slow_operation();
    // wow that really took a long time
    //
    // did you know that we're still holding the internal rwlock?
    //
    // it's "never held during disk reads and writes"
    // but our request was fetched from the write queue,
    // which is probed by every reader and writer in order to
    // maintain consistency
    //
    // now guess who is currently waiting to get exclusive access...
    // ...it's the background worker!
    //
    // Q: are other readers still able to acquire the rwlock?
    // A: of course not, we don't want writer starvation :)
    //
    // TL;DR: a reader can block the whole system forever ... :D
    db.fetch(some_other_key, [&](...) { /* let's deadlock */ });                
}, ...);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant