diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2014-07-09 17:18:40 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2014-07-09 17:18:40 +1000 |
commit | 846822379ae9f54d5edbf9bf2e8139141f456676 (patch) | |
tree | 9e944e3758dd2a36d326287522f2297afb2d2333 | |
parent | 5e9075f7babe22a77900c127280bdbfc7dcb6e40 (diff) | |
download | mongo-846822379ae9f54d5edbf9bf2e8139141f456676.tar.gz |
Handle Deletes of nonexistent keys via the LevelDB API: that is OK. Also add resets to the RocksDB column family operations.
-rw-r--r-- | api/leveldb/leveldb_wt.cc | 9 | ||||
-rw-r--r-- | api/leveldb/rocks_wt.cc | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/api/leveldb/leveldb_wt.cc b/api/leveldb/leveldb_wt.cc index e126b47469c..fa735d5d329 100644 --- a/api/leveldb/leveldb_wt.cc +++ b/api/leveldb/leveldb_wt.cc @@ -322,8 +322,11 @@ DbImpl::Delete(const WriteOptions& options, const Slice& key) // Reset the WiredTiger cursor so it doesn't keep any pages pinned. Track // failures in debug builds since we don't expect failure, but don't pass // failures on - it's not necessary for correct operation. - int t_ret = cursor->reset(cursor); - assert(t_ret == 0); + if (ret == 0) { + int t_ret = cursor->reset(cursor); + assert(t_ret == 0); + } else if (ret == WT_NOTFOUND) + ret = 0; return WiredTigerErrorToStatus(ret, NULL); } @@ -351,7 +354,7 @@ void WriteBatchHandler::Delete(const Slice& key) { item.size = key.size(); cursor->set_key(cursor, &item); int ret = cursor->remove(cursor); - if (ret != 0 && status_ == 0) + if (ret != 0 && ret != WT_NOTFOUND && status_ == 0) status_ = ret; } diff --git a/api/leveldb/rocks_wt.cc b/api/leveldb/rocks_wt.cc index 469eed1029d..6ccab2c1e78 100644 --- a/api/leveldb/rocks_wt.cc +++ b/api/leveldb/rocks_wt.cc @@ -176,6 +176,11 @@ WriteBatchHandler::DeleteCF(uint32_t column_family_id, const Slice& key) item.size = key.size(); cursor->set_key(cursor, &item); ret = cursor->remove(cursor); + if (ret == 0) { + int t_ret = cursor->reset(cursor); + assert(t_ret == 0); + } else if (ret == WT_NOTFOUND) + ret = 0; return WiredTigerErrorToStatus(ret); } @@ -255,8 +260,10 @@ DbImpl::Get(ReadOptions const &options, ColumnFamilyHandle *cfhp, Slice const &k item.size = key.size(); cursor->set_key(cursor, &item); if ((ret = cursor->search(cursor)) == 0 && - (ret = cursor->get_value(cursor, &item)) == 0) + (ret = cursor->get_value(cursor, &item)) == 0) { *value = std::string((const char *)item.data, item.size); + ret = cursor->reset(cursor); + } if (ret == WT_NOTFOUND) errmsg = "DB::Get key not found"; return WiredTigerErrorToStatus(ret, errmsg); |