This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 31e345b9d fix(list): check the status of rocksdb iterator (#3168)
31e345b9d is described below
commit 31e345b9d3d7d3fde95077da7c85352922a58a96
Author: Jonah Gao <[email protected]>
AuthorDate: Thu Sep 11 17:49:00 2025 +0800
fix(list): check the status of rocksdb iterator (#3168)
In case of an I/O error when iterating, abort the operation; otherwise,
it may return incomplete results or partially update a list.
---
src/types/redis_list.cc | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/types/redis_list.cc b/src/types/redis_list.cc
index ceb268214..0f8ddd79e 100644
--- a/src/types/redis_list.cc
+++ b/src/types/redis_list.cc
@@ -206,6 +206,9 @@ rocksdb::Status List::Rem(engine::Context &ctx, const Slice
&user_key, int count
if (static_cast<int>(to_delete_indexes.size()) == abs(count)) break;
}
}
+ if (auto s = iter->status(); !s.ok()) {
+ return s;
+ }
if (to_delete_indexes.empty()) {
return rocksdb::Status::NotFound();
}
@@ -240,6 +243,9 @@ rocksdb::Status List::Rem(engine::Context &ctx, const Slice
&user_key, int count
processed++;
}
}
+ if (auto s = iter->status(); !s.ok()) {
+ return s;
+ }
for (uint64_t idx = 0; idx < to_delete_indexes.size(); ++idx) {
buf.clear();
@@ -293,6 +299,9 @@ rocksdb::Status List::Insert(engine::Context &ctx, const
Slice &user_key, const
break;
}
}
+ if (auto s = iter->status(); !s.ok()) {
+ return s;
+ }
if (pivot_index == (metadata.head - 1)) {
*new_size = -1;
return rocksdb::Status::NotFound();
@@ -321,6 +330,9 @@ rocksdb::Status List::Insert(engine::Context &ctx, const
Slice &user_key, const
s = batch->Put(to_update_key, iter->value());
if (!s.ok()) return s;
}
+ if (auto s = iter->status(); !s.ok()) {
+ return s;
+ }
buf.clear();
PutFixed64(&buf, new_elem_index);
std::string to_update_key = InternalKey(ns_key, buf, metadata.version,
storage_->IsSlotIdEncoded()).Encode();
@@ -398,6 +410,10 @@ rocksdb::Status List::Range(engine::Context &ctx, const
Slice &user_key, int sta
if (index > metadata.head + stop) break;
elems->push_back(iter->value().ToString());
}
+ if (auto s = iter->status(); !s.ok()) {
+ elems->clear();
+ return s;
+ }
return rocksdb::Status::OK();
}
@@ -453,6 +469,10 @@ rocksdb::Status List::Pos(engine::Context &ctx, const
Slice &user_key, const Sli
offset++;
!reversed ? iter->Next() : iter->Prev();
}
+ if (auto s = iter->status(); !s.ok()) {
+ indexes->clear();
+ return s;
+ }
return rocksdb::Status::OK();
}