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

DeleteRange doesn't work well with row_cache #4122

Open
jonahgao opened this issue Jul 12, 2018 · 4 comments
Open

DeleteRange doesn't work well with row_cache #4122

jonahgao opened this issue Jul 12, 2018 · 4 comments
Assignees

Comments

@jonahgao
Copy link
Contributor

Expected behavior & Actual behavior

when row_cache is enabled,
after we delete a key by a DeleteRange call,
we can still Get the key and its value from the db

Steps to reproduce the behavior

#include <iostream>
#include <rocksdb/db.h>

int main() {
    rocksdb::Options ops;
    ops.max_write_buffer_number = 1;
    ops.create_if_missing = true;
    ops.row_cache = rocksdb::NewLRUCache(1024);

    rocksdb::DB *db = nullptr;
    auto s = rocksdb::DB::Open(ops, "./db", &db);
    assert(s.ok());

    const std::string key = "mykey";

    s = db->Put(rocksdb::WriteOptions(), key, "myvalue");
    assert(s.ok());

    // flush so we can use the row cache, not memtable
    s = db->Flush(rocksdb::FlushOptions());
    assert(s.ok());
    std::string value;
    s = db->Get(rocksdb::ReadOptions(), key, &value);
    assert(s.ok());

    s = db->DeleteRange(rocksdb::WriteOptions(), db->DefaultColumnFamily(), "a", "z");
    assert(s.ok());

    value.clear();
    s = db->Get(rocksdb::ReadOptions(), key, &value);
    // status should be NotFound, but the program's output is an OK
    std::cout << "status: " << s.ToString() << ", value: " << value << std::endl;

    return 0;
}
@ajkr
Copy link
Contributor

ajkr commented Jul 12, 2018

Thanks for reporting. I think the most we can promise right now is making it explicitly unsupported, i.e., disallow range deletions when row cache is enabled. If you want to contribute code for purging the row cache when DeleteRange happens, we should be able to review and land it.

@ajkr ajkr self-assigned this Jul 12, 2018
@jonahgao
Copy link
Contributor Author

Thank for your reply @ajkr , I'll look into this and try to fix it.

@XinzeChi
Copy link

XinzeChi commented Feb 3, 2024

@ajkr Could you tell me which PR fix this BUG, thanks?

@cbi42
Copy link
Member

cbi42 commented Apr 5, 2024

Re-open the issue so we remember to add some safeguard before it's supported.

The above test passes now. But if DeleteRange() and row key is from the same SST file, then it still fails.

const Snapshot* snap = db_->GetSnapshot();
ASSERT_OK(db_->DeleteRange(rocksdb::WriteOptions(),
                           db_->DefaultColumnFamily(), "a", "z"));
ASSERT_OK(Flush());

std::string value;
Status s = db_->Get(ReadOptions(), "a", &value);
std::cout << "status: " << s.ToString() << ", value: " << value << std::endl;
value.clear();
s = db_->Get(ReadOptions(), "a", &value);

// status should be NotFound, but the program's output is an OK
std::cout << "status: " << s.ToString() << ", value: " << value << std::endl;


status: NotFound: , value:
status: OK, value: myval

@cbi42 cbi42 reopened this Apr 5, 2024
facebook-github-bot pushed a commit that referenced this issue Apr 29, 2024
Summary:
...since this feature combination is not supported yet (#4122).

Pull Request resolved: #12512

Test Plan: new unit test.

Reviewed By: jaykorean, jowlyzhang

Differential Revision: D55820323

Pulled By: cbi42

fbshipit-source-id: eeb5e97d15c9bdc388793a2fb8e52cfa47e34bcf
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

4 participants