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

can I reuse a rocksdb writebatch by calling rocksdb_writebatch_clear? #12410

Closed
979357361 opened this issue Mar 6, 2024 · 0 comments
Closed

Comments

@979357361
Copy link

979357361 commented Mar 6, 2024

Hi friends,
I use rocksdb by C API (V8.6.7). Sometimes I need to write a batch of KV, calling rocksdb_writebatch_create() everytime seems expensive, so I use a mempool to buffer about 1024 writebatch struct and alloc one when I need, I use rocksdb_writebatch_clear to wipe away old data before writing to it, but I got stucked when I call rocksdb_writebatch_clear, it seems it never ends at empty() func. thanks for your time~

void WriteBatch::Clear() {
rep_.clear();
rep_.resize(WriteBatchInternal::kHeader);

content_flags_.store(0, std::memory_order_relaxed);

if (save_points_ != nullptr) {
while (!save_points_->stack.empty()) {
save_points_->stack.pop();
}
}

if (prot_info_ != nullptr) {
prot_info_->entries_.clear();
}
wal_term_point_.clear();
default_cf_ts_sz_ = 0;
}

#0 size (this=0x2046f5594c10, this=0x2046f5594c10) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_vector.h:671
#1 size (this=) at ./util/autovector.h:188
#2 empty (this=) at ./util/autovector.h:210
#3 empty (this=) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_stack.h:186
#4 rocksdb::WriteBatch::Clear (this=0x2046f5594b58) at db/write_batch.cc:252
#5 0x00000000008be2e5 in rocksdb_writebatch_clear (b=) at db/c.cc:1947

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